@bitbybit-dev/mcp 1.4.1 → 1.5.0-rc.0
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 +3 -3
- package/dist/descriptions.d.ts.map +1 -1
- package/dist/descriptions.js +10 -5
- package/dist/descriptions.js.map +1 -1
- package/dist/guides-split.d.ts +6 -0
- package/dist/guides-split.d.ts.map +1 -1
- package/dist/guides-split.js +17 -3
- package/dist/guides-split.js.map +1 -1
- package/dist/guides.generated.d.ts +4 -3
- package/dist/guides.generated.d.ts.map +1 -1
- package/dist/guides.generated.js +249 -17
- package/dist/guides.generated.js.map +1 -1
- package/dist/index-loader.d.ts.map +1 -1
- package/dist/index-loader.js +10 -5
- package/dist/index-loader.js.map +1 -1
- package/dist/index-reader.d.ts +11 -1
- package/dist/index-reader.d.ts.map +1 -1
- package/dist/index-reader.js +87 -22
- package/dist/index-reader.js.map +1 -1
- package/dist/index-shape.d.ts.map +1 -1
- package/dist/index-shape.js +4 -2
- package/dist/index-shape.js.map +1 -1
- package/dist/index-types.d.ts +7 -0
- package/dist/index-types.d.ts.map +1 -1
- package/dist/index-url.d.ts.map +1 -1
- package/dist/index-url.js +2 -1
- package/dist/index-url.js.map +1 -1
- package/dist/installed-version.d.ts.map +1 -1
- package/dist/installed-version.js +14 -7
- package/dist/installed-version.js.map +1 -1
- package/dist/json-schema.d.ts.map +1 -1
- package/dist/json-schema.js +16 -8
- package/dist/json-schema.js.map +1 -1
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +6 -3
- package/dist/registry.js.map +1 -1
- package/dist/render.d.ts +3 -1
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +55 -21
- package/dist/render.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +4 -2
- package/dist/server.js.map +1 -1
- package/dist/stdio.js +4 -2
- package/dist/stdio.js.map +1 -1
- package/dist/tools/describe.d.ts.map +1 -1
- package/dist/tools/describe.js +13 -3
- package/dist/tools/describe.js.map +1 -1
- package/dist/tools/fetch.d.ts.map +1 -1
- package/dist/tools/fetch.js +3 -2
- package/dist/tools/fetch.js.map +1 -1
- package/dist/tools/get-examples.d.ts.map +1 -1
- package/dist/tools/get-examples.js +8 -4
- package/dist/tools/get-examples.js.map +1 -1
- package/dist/tools/get-guide.d.ts.map +1 -1
- package/dist/tools/get-guide.js +52 -7
- package/dist/tools/get-guide.js.map +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
- package/src/__fixtures__/index.sample.json +261 -0
- package/src/__fixtures__/load.ts +1 -0
- package/src/descriptions.ts +10 -5
- package/src/guides-split.ts +27 -3
- package/src/guides.generated.ts +249 -17
- package/src/guides.test.ts +41 -7
- package/src/index-loader.test.ts +3 -1
- package/src/index-loader.ts +15 -5
- package/src/index-reader.ts +116 -21
- package/src/index-shape.ts +6 -2
- package/src/index-types.ts +8 -0
- package/src/index-url.ts +3 -1
- package/src/installed-version.test.ts +3 -1
- package/src/installed-version.ts +21 -7
- package/src/json-schema.ts +21 -7
- package/src/registry.ts +9 -3
- package/src/render.test.ts +153 -1
- package/src/render.ts +78 -20
- package/src/server.ts +6 -2
- package/src/stdio.test.ts +15 -5
- package/src/stdio.ts +6 -2
- package/src/tools/describe.ts +13 -3
- package/src/tools/docs-tools.test.ts +57 -1
- package/src/tools/fetch.ts +4 -2
- package/src/tools/get-examples.ts +12 -4
- package/src/tools/get-guide.ts +54 -7
package/dist/guides.generated.js
CHANGED
|
@@ -1,93 +1,325 @@
|
|
|
1
|
-
/** Where the guide is published; every section links back to
|
|
1
|
+
/** Where the first guide is published; every section links back to its own page. */
|
|
2
2
|
export const GUIDE_PAGE_URL = "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/agentic-cad";
|
|
3
3
|
/**
|
|
4
|
-
* The sections of the public
|
|
5
|
-
* docs/learn/using-ai-with-bitbybit/agentic-cad.md.
|
|
4
|
+
* The sections of the public guides, generated by scripts/sync-guides.mjs from
|
|
5
|
+
* docs/learn/using-ai-with-bitbybit/agentic-cad.md, docs/learn/using-ai-with-bitbybit/cad-geometry.md, docs/learn/using-ai-with-bitbybit/design-documents.md, docs/learn/using-ai-with-bitbybit/ifc-models.md.
|
|
6
|
+
* Do not edit: run `npm run sync:guides`.
|
|
6
7
|
*/
|
|
7
8
|
export const GUIDES = [
|
|
8
9
|
{
|
|
9
10
|
"id": "what-we-believe",
|
|
10
11
|
"title": "What we believe",
|
|
11
12
|
"level": 2,
|
|
12
|
-
"body": "Agents write the code. Bitbybit provides verified geometry algorithms and, where it is needed, hosted compute. The open-source packages are the vocabulary that everyone learns, human or agent: one dotted API (`bitbybit.occt.shapes.solid.createBox`, `bitbybit.manifold.booleans.union`, ...) that reads the same in a browser, on a server and in the online editors.\n\nAn agent that knows the API from memory guesses. An agent that looks it up gets the exact signature, defaults and examples for the version your project has installed. That lookup is what the MCP server is for."
|
|
13
|
+
"body": "Agents write the code. Bitbybit provides verified geometry algorithms and, where it is needed, hosted compute. The open-source packages are the vocabulary that everyone learns, human or agent: one dotted API (`bitbybit.occt.shapes.solid.createBox`, `bitbybit.manifold.booleans.union`, ...) that reads the same in a browser, on a server and in the online editors.\n\nAn agent that knows the API from memory guesses. An agent that looks it up gets the exact signature, defaults and examples for the version your project has installed. That lookup is what the MCP server is for.",
|
|
14
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/agentic-cad"
|
|
13
15
|
},
|
|
14
16
|
{
|
|
15
17
|
"id": "three-layers-you-can-use",
|
|
16
18
|
"title": "Three layers you can use",
|
|
17
19
|
"level": 2,
|
|
18
|
-
"body": "1. **The npm packages** (MIT). `@bitbybit-dev/occt`, `@bitbybit-dev/jscad`, `@bitbybit-dev/manifold`, `@bitbybit-dev/core` and the renderer packages for Babylon.js, three.js and PlayCanvas. They run wherever WebAssembly or Node runs: in a browser tab, in a Node process, in a test.\n2. **The Bitbybit CAD MCP** (free). `npx -y @bitbybit-dev/mcp` locally, or `https://mcp.bitbybit.dev/mcp` remotely. Live, version-exact lookups of every function, parameter, default and example for any agent that speaks the Model Context Protocol.\n3. **CAD Cloud** (paid, with an API key). Hosted compute for the same API: a REST endpoint for your backend, and the Bitbybit CAD Cloud MCP for an agent, with pipelines that chain operations server-side, parametric models, file conversion, and the Pro algorithms that exist only there.\n\nEvery member of the API carries a tier, and the MCP server reports it:\n\n| Tier | Meaning |\n|---|---|\n| `oss` | in the npm packages, runs anywhere |\n| `platform-pro` | available only when scripting inside bitbybit.dev; not on npm |\n| `cloud-pro` | runs only on CAD Cloud, with an API key |"
|
|
20
|
+
"body": "1. **The npm packages** (MIT). `@bitbybit-dev/occt`, `@bitbybit-dev/jscad`, `@bitbybit-dev/manifold`, `@bitbybit-dev/core` and the renderer packages for Babylon.js, three.js and PlayCanvas. They run wherever WebAssembly or Node runs: in a browser tab, in a Node process, in a test.\n2. **The Bitbybit CAD MCP** (free). `npx -y @bitbybit-dev/mcp` locally, or `https://mcp.bitbybit.dev/mcp` remotely. Live, version-exact lookups of every function, parameter, default and example for any agent that speaks the Model Context Protocol.\n3. **CAD Cloud** (paid, with an API key). Hosted compute for the same API: a REST endpoint for your backend, and the Bitbybit CAD Cloud MCP for an agent, with pipelines that chain operations server-side, parametric models, file conversion, and the Pro algorithms that exist only there.\n\nEvery member of the API carries a tier, and the MCP server reports it:\n\n| Tier | Meaning |\n|---|---|\n| `oss` | in the npm packages, runs anywhere |\n| `platform-pro` | available only when scripting inside bitbybit.dev; not on npm |\n| `cloud-pro` | runs only on CAD Cloud, with an API key |",
|
|
21
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/agentic-cad"
|
|
19
22
|
},
|
|
20
23
|
{
|
|
21
24
|
"id": "how-an-agent-should-integrate-bitbybit",
|
|
22
25
|
"title": "How an agent should integrate Bitbybit",
|
|
23
26
|
"level": 2,
|
|
24
|
-
"body": "```mermaid\n%%{init: {\"flowchart\": {\"wrappingWidth\": 420}}}%%\nflowchart TD\n Q1{\"Can your users' browsers or<br/>your own Node servers run the kernels?\"}\n Q2{\"Do you need a Pro algorithm,<br/>or a backend that cannot host a kernel?\"}\n P[\"The npm packages, in the browser or in Node.<br/>Free, and nothing of ours in the loop.\"]\n C[\"CAD Cloud: one pipeline per model from your backend,<br/>or the CAD Cloud MCP when an agent does the work.\"]\n Q1 -->|yes| Q2\n Q1 -->|no: edge or serverless| C\n Q2 -->|no| P\n Q2 -->|yes| C\n```\n\n### The honest default\n\nIf public code and your users' own compute are acceptable, the packages are the whole answer. They are free, they need no account, and nothing of ours sits in the loop. Start there, and move a step only for a reason named below.\n\n### Browser apps\n\nUse the packages, or the runner bundle for a page that only needs a script. The kernels run inside the tab: the user's device does the work, results appear without a network round trip, and your geometry logic ships with your app. This is how the Bitbybit editors themselves work. A model that takes seconds on a laptop is fine here; a model that takes minutes is not, and belongs on a server.\n\n### Lightweight backends\n\nCloudflare Workers, serverless functions and edge runtimes do not have the memory or the CPU time to run the CAD kernels. Do not try. Call CAD Cloud instead, with one pipeline per model so a request is one round trip, keep the API key in the backend and never in the client, and cache results by their input parameters, because identical inputs always produce identical geometry.\n\n### Node servers with headroom\n\nA Node server can run the packages in-process; `@bitbybit-dev/occt` loads the same kernel a browser does. That is the right choice for moderate load and for logic you want to keep private on your own machines. Move to CAD Cloud when you need scale without managing kernels, when you need a Pro algorithm, or when you convert files at volume and would rather not run that work yourself.\n\n### Inside the Bitbybit editors\n\nScripts written in the editors at bitbybit.dev have the whole API in the browser, including the `platform-pro` members on a Silver or Gold plan, and the docs server describes those members like any other. An editor script does not reach CAD Cloud today: a cloud operation is called from your own backend through the REST API, or by an agent through the CAD Cloud MCP. Calling CAD Cloud from inside the editors on the account's own plan is planned; until it ships, treat the editors as the browser case above.\n\n### What runs where\n\n| Question | Packages in the browser | Packages in Node | CAD Cloud |\n|---|---|---|---|\n| Whose compute | your users' devices, free | your servers | Bitbybit's servers, metered |\n| Memory and CPU | the tab's limits | your machine's | sized per plan |\n| Latency | none beyond the computation | none beyond the computation | one HTTPS round trip plus queueing |\n| Concurrency | one user per tab | what you provision | per plan |\n| Privacy of your logic | ships to the client | stays on your servers | stays in your backend; the geometry passes through Bitbybit |\n| Pro algorithms | no | no | yes |\n\nThe only work that must run on Bitbybit's servers is a Pro algorithm, or compute you cannot provide."
|
|
27
|
+
"body": "```mermaid\n%%{init: {\"flowchart\": {\"wrappingWidth\": 420}}}%%\nflowchart TD\n Q1{\"Can your users' browsers or<br/>your own Node servers run the kernels?\"}\n Q2{\"Do you need a Pro algorithm,<br/>or a backend that cannot host a kernel?\"}\n P[\"The npm packages, in the browser or in Node.<br/>Free, and nothing of ours in the loop.\"]\n C[\"CAD Cloud: one pipeline per model from your backend,<br/>or the CAD Cloud MCP when an agent does the work.\"]\n Q1 -->|yes| Q2\n Q1 -->|no: edge or serverless| C\n Q2 -->|no| P\n Q2 -->|yes| C\n```\n\n### The honest default\n\nIf public code and your users' own compute are acceptable, the packages are the whole answer. They are free, they need no account, and nothing of ours sits in the loop. Start there, and move a step only for a reason named below.\n\n### Browser apps\n\nUse the packages, or the runner bundle for a page that only needs a script. The kernels run inside the tab: the user's device does the work, results appear without a network round trip, and your geometry logic ships with your app. This is how the Bitbybit editors themselves work. A model that takes seconds on a laptop is fine here; a model that takes minutes is not, and belongs on a server.\n\n### Lightweight backends\n\nCloudflare Workers, serverless functions and edge runtimes do not have the memory or the CPU time to run the CAD kernels. Do not try. Call CAD Cloud instead, with one pipeline per model so a request is one round trip, keep the API key in the backend and never in the client, and cache results by their input parameters, because identical inputs always produce identical geometry.\n\n### Node servers with headroom\n\nA Node server can run the packages in-process; `@bitbybit-dev/occt` loads the same kernel a browser does. That is the right choice for moderate load and for logic you want to keep private on your own machines. Move to CAD Cloud when you need scale without managing kernels, when you need a Pro algorithm, or when you convert files at volume and would rather not run that work yourself.\n\n### Inside the Bitbybit editors\n\nScripts written in the editors at bitbybit.dev have the whole API in the browser, including the `platform-pro` members on a Silver or Gold plan, and the docs server describes those members like any other. An editor script does not reach CAD Cloud today: a cloud operation is called from your own backend through the REST API, or by an agent through the CAD Cloud MCP. Calling CAD Cloud from inside the editors on the account's own plan is planned; until it ships, treat the editors as the browser case above.\n\n### What runs where\n\n| Question | Packages in the browser | Packages in Node | CAD Cloud |\n|---|---|---|---|\n| Whose compute | your users' devices, free | your servers | Bitbybit's servers, metered |\n| Memory and CPU | the tab's limits | your machine's | sized per plan |\n| Latency | none beyond the computation | none beyond the computation | one HTTPS round trip plus queueing |\n| Concurrency | one user per tab | what you provision | per plan |\n| Privacy of your logic | ships to the client | stays on your servers | stays in your backend; the geometry passes through Bitbybit |\n| Pro algorithms | no | no | yes |\n\nThe only work that must run on Bitbybit's servers is a Pro algorithm, or compute you cannot provide.",
|
|
28
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/agentic-cad"
|
|
25
29
|
},
|
|
26
30
|
{
|
|
27
31
|
"id": "the-honest-default",
|
|
28
32
|
"title": "The honest default",
|
|
29
33
|
"level": 3,
|
|
30
|
-
"body": "If public code and your users' own compute are acceptable, the packages are the whole answer. They are free, they need no account, and nothing of ours sits in the loop. Start there, and move a step only for a reason named below."
|
|
34
|
+
"body": "If public code and your users' own compute are acceptable, the packages are the whole answer. They are free, they need no account, and nothing of ours sits in the loop. Start there, and move a step only for a reason named below.",
|
|
35
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/agentic-cad"
|
|
31
36
|
},
|
|
32
37
|
{
|
|
33
38
|
"id": "browser-apps",
|
|
34
39
|
"title": "Browser apps",
|
|
35
40
|
"level": 3,
|
|
36
|
-
"body": "Use the packages, or the runner bundle for a page that only needs a script. The kernels run inside the tab: the user's device does the work, results appear without a network round trip, and your geometry logic ships with your app. This is how the Bitbybit editors themselves work. A model that takes seconds on a laptop is fine here; a model that takes minutes is not, and belongs on a server."
|
|
41
|
+
"body": "Use the packages, or the runner bundle for a page that only needs a script. The kernels run inside the tab: the user's device does the work, results appear without a network round trip, and your geometry logic ships with your app. This is how the Bitbybit editors themselves work. A model that takes seconds on a laptop is fine here; a model that takes minutes is not, and belongs on a server.",
|
|
42
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/agentic-cad"
|
|
37
43
|
},
|
|
38
44
|
{
|
|
39
45
|
"id": "lightweight-backends",
|
|
40
46
|
"title": "Lightweight backends",
|
|
41
47
|
"level": 3,
|
|
42
|
-
"body": "Cloudflare Workers, serverless functions and edge runtimes do not have the memory or the CPU time to run the CAD kernels. Do not try. Call CAD Cloud instead, with one pipeline per model so a request is one round trip, keep the API key in the backend and never in the client, and cache results by their input parameters, because identical inputs always produce identical geometry."
|
|
48
|
+
"body": "Cloudflare Workers, serverless functions and edge runtimes do not have the memory or the CPU time to run the CAD kernels. Do not try. Call CAD Cloud instead, with one pipeline per model so a request is one round trip, keep the API key in the backend and never in the client, and cache results by their input parameters, because identical inputs always produce identical geometry.",
|
|
49
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/agentic-cad"
|
|
43
50
|
},
|
|
44
51
|
{
|
|
45
52
|
"id": "node-servers-with-headroom",
|
|
46
53
|
"title": "Node servers with headroom",
|
|
47
54
|
"level": 3,
|
|
48
|
-
"body": "A Node server can run the packages in-process; `@bitbybit-dev/occt` loads the same kernel a browser does. That is the right choice for moderate load and for logic you want to keep private on your own machines. Move to CAD Cloud when you need scale without managing kernels, when you need a Pro algorithm, or when you convert files at volume and would rather not run that work yourself."
|
|
55
|
+
"body": "A Node server can run the packages in-process; `@bitbybit-dev/occt` loads the same kernel a browser does. That is the right choice for moderate load and for logic you want to keep private on your own machines. Move to CAD Cloud when you need scale without managing kernels, when you need a Pro algorithm, or when you convert files at volume and would rather not run that work yourself.",
|
|
56
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/agentic-cad"
|
|
49
57
|
},
|
|
50
58
|
{
|
|
51
59
|
"id": "inside-the-bitbybit-editors",
|
|
52
60
|
"title": "Inside the Bitbybit editors",
|
|
53
61
|
"level": 3,
|
|
54
|
-
"body": "Scripts written in the editors at bitbybit.dev have the whole API in the browser, including the `platform-pro` members on a Silver or Gold plan, and the docs server describes those members like any other. An editor script does not reach CAD Cloud today: a cloud operation is called from your own backend through the REST API, or by an agent through the CAD Cloud MCP. Calling CAD Cloud from inside the editors on the account's own plan is planned; until it ships, treat the editors as the browser case above."
|
|
62
|
+
"body": "Scripts written in the editors at bitbybit.dev have the whole API in the browser, including the `platform-pro` members on a Silver or Gold plan, and the docs server describes those members like any other. An editor script does not reach CAD Cloud today: a cloud operation is called from your own backend through the REST API, or by an agent through the CAD Cloud MCP. Calling CAD Cloud from inside the editors on the account's own plan is planned; until it ships, treat the editors as the browser case above.",
|
|
63
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/agentic-cad"
|
|
55
64
|
},
|
|
56
65
|
{
|
|
57
66
|
"id": "what-runs-where",
|
|
58
67
|
"title": "What runs where",
|
|
59
68
|
"level": 3,
|
|
60
|
-
"body": "| Question | Packages in the browser | Packages in Node | CAD Cloud |\n|---|---|---|---|\n| Whose compute | your users' devices, free | your servers | Bitbybit's servers, metered |\n| Memory and CPU | the tab's limits | your machine's | sized per plan |\n| Latency | none beyond the computation | none beyond the computation | one HTTPS round trip plus queueing |\n| Concurrency | one user per tab | what you provision | per plan |\n| Privacy of your logic | ships to the client | stays on your servers | stays in your backend; the geometry passes through Bitbybit |\n| Pro algorithms | no | no | yes |\n\nThe only work that must run on Bitbybit's servers is a Pro algorithm, or compute you cannot provide."
|
|
69
|
+
"body": "| Question | Packages in the browser | Packages in Node | CAD Cloud |\n|---|---|---|---|\n| Whose compute | your users' devices, free | your servers | Bitbybit's servers, metered |\n| Memory and CPU | the tab's limits | your machine's | sized per plan |\n| Latency | none beyond the computation | none beyond the computation | one HTTPS round trip plus queueing |\n| Concurrency | one user per tab | what you provision | per plan |\n| Privacy of your logic | ships to the client | stays on your servers | stays in your backend; the geometry passes through Bitbybit |\n| Pro algorithms | no | no | yes |\n\nThe only work that must run on Bitbybit's servers is a Pro algorithm, or compute you cannot provide.",
|
|
70
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/agentic-cad"
|
|
61
71
|
},
|
|
62
72
|
{
|
|
63
73
|
"id": "pro-algorithms",
|
|
64
74
|
"title": "Pro algorithms",
|
|
65
75
|
"level": 2,
|
|
66
|
-
"body": "Some algorithms are available on CAD Cloud only, such as sheet-metal unfolding. They are verified against reference parts, expensive to maintain, and priced for it. An agent discovers them the same way as everything else: `describe` reports the tier `cloud-pro`, the endpoint and the API key scope. The [CAD Cloud page](https://bitbybit.dev/cad-cloud) lists the plans."
|
|
76
|
+
"body": "Some algorithms are available on CAD Cloud only, such as sheet-metal unfolding. They are verified against reference parts, expensive to maintain, and priced for it. An agent discovers them the same way as everything else: `describe` reports the tier `cloud-pro`, the endpoint and the API key scope. The [CAD Cloud page](https://bitbybit.dev/cad-cloud) lists the plans.",
|
|
77
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/agentic-cad"
|
|
67
78
|
},
|
|
68
79
|
{
|
|
69
80
|
"id": "for-companies",
|
|
70
81
|
"title": "For companies",
|
|
71
82
|
"level": 2,
|
|
72
|
-
"body": "Bitbybit builds and operates private algorithm namespaces for companies that need their own operations on the same infrastructure. Write to us through the [contact page](https://bitbybit.dev/contact)."
|
|
83
|
+
"body": "Bitbybit builds and operates private algorithm namespaces for companies that need their own operations on the same infrastructure. Write to us through the [contact page](https://bitbybit.dev/contact).",
|
|
84
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/agentic-cad"
|
|
73
85
|
},
|
|
74
86
|
{
|
|
75
87
|
"id": "trust",
|
|
76
88
|
"title": "Trust",
|
|
77
89
|
"level": 2,
|
|
78
|
-
"body": "Every cloud algorithm is graded by automated geometry verification: invariants that must hold for any input, and reference parts whose results are known. The summary is published with each release, so what an agent calls has been checked by something other than a person reading the output."
|
|
90
|
+
"body": "Every cloud algorithm is graded by automated geometry verification: invariants that must hold for any input, and reference parts whose results are known. The summary is published with each release, so what an agent calls has been checked by something other than a person reading the output.",
|
|
91
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/agentic-cad"
|
|
79
92
|
},
|
|
80
93
|
{
|
|
81
94
|
"id": "what-we-do-not-do",
|
|
82
95
|
"title": "What we do not do",
|
|
83
96
|
"level": 2,
|
|
84
|
-
"body": "We do not host your application, run your scripts for you, sell you a chatbot, or train on your models. The packages are yours to run; CAD Cloud runs the operations you send it and nothing else."
|
|
97
|
+
"body": "We do not host your application, run your scripts for you, sell you a chatbot, or train on your models. The packages are yours to run; CAD Cloud runs the operations you send it and nothing else.",
|
|
98
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/agentic-cad"
|
|
85
99
|
},
|
|
86
100
|
{
|
|
87
101
|
"id": "get-started",
|
|
88
102
|
"title": "Get started",
|
|
89
103
|
"level": 2,
|
|
90
|
-
"body": "- Scaffold a project: `npm init @bitbybit-dev/app my-project`, then point your agent at the MCP server as the next step says.\n- Give your agent the API. Claude Code: `claude mcp add --transport http bitbybit https://mcp.bitbybit.dev/mcp`, or a local server with `claude mcp add --transport stdio bitbybit -- npx -y @bitbybit-dev/mcp`. Cursor and VS Code read the same server from `.cursor/mcp.json` and `.vscode/mcp.json`; the [MCP page](./mcp/bitbybit-mcp) has every snippet.\n- Let the agent run geometry for you: the [CAD Cloud MCP](./mcp/cad-cloud-mcp) with a key from [plans and keys](https://bitbybit.dev/cad-cloud)."
|
|
104
|
+
"body": "- Scaffold a project: `npm init @bitbybit-dev/app my-project`, then point your agent at the MCP server as the next step says.\n- Give your agent the API. Claude Code: `claude mcp add --transport http bitbybit https://mcp.bitbybit.dev/mcp`, or a local server with `claude mcp add --transport stdio bitbybit -- npx -y @bitbybit-dev/mcp`. Cursor and VS Code read the same server from `.cursor/mcp.json` and `.vscode/mcp.json`; the [MCP page](./mcp/bitbybit-mcp) has every snippet.\n- Let the agent run geometry for you: the [CAD Cloud MCP](./mcp/cad-cloud-mcp) with a key from [plans and keys](https://bitbybit.dev/cad-cloud).",
|
|
105
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/agentic-cad"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"id": "geometry-in-bitbybit",
|
|
109
|
+
"title": "Geometry in Bitbybit",
|
|
110
|
+
"level": 2,
|
|
111
|
+
"body": "- **Three kernels, one API.** `occt` is OpenCascade, an exact kernel: solids bounded by true curves and surfaces, fillets and chamfers, booleans that keep a cylinder a cylinder, STEP and IGES. `manifold` is Manifold, a mesh kernel whose booleans are fast and always give a closed solid. `jscad` is JSCAD, polygon modelling with text and simple extrusions. Each is an MIT npm package with a worker beside it: `@bitbybit-dev/occt`, `@bitbybit-dev/manifold`, `@bitbybit-dev/jscad`.\n- **It runs locally.** The kernels run in the browser and in Node; the methods `describe` marks `oss` need no account and no server.\n- **Shapes are values.** Every operation returns a new shape and leaves its inputs as they were, so a part is a chain of calls, each starting from the result of the one before.\n- **One object in, one result out.** Every method takes a single object of named fields, most of them with defaults: `createBox({ width: 80, length: 50, height: 8 })`. `describe` lists each field with its default and range. A field left out takes its default, and a misspelt one is ignored, so look the names up rather than recall them.",
|
|
112
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/cad-geometry"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"id": "which-kernel-to-use",
|
|
116
|
+
"title": "Which kernel to use",
|
|
117
|
+
"level": 2,
|
|
118
|
+
"body": "- **OpenCascade (`occt`)** for parts: exact geometry, fillets and chamfers, measurements, STEP, IGES, STL and DXF, and assemblies with names and colours. An operation takes milliseconds to seconds, so it suits parts of tens or hundreds of features rather than thousands of booleans.\n- **Manifold (`manifold`)** for many booleans and for meshes: a panel with a thousand holes, a lattice, imported or scanned meshes, anything that must stay watertight. It has no fillets and no exact curves: a cylinder is a prism of `circularSegments` sides.\n- **JSCAD (`jscad`)** for quick solids and 3D text.\n- **Between them.** `occt.shapeToManifoldMesh` meshes an OpenCascade shape into the form `manifold.manifold.shapes.manifoldFromMesh` takes, so a part can be modelled exactly and then cut a thousand times in Manifold. A mesh comes back into OpenCascade only as flat triangles, never as true curves.",
|
|
119
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/cad-geometry"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"id": "two-ways-to-call-a-kernel",
|
|
123
|
+
"title": "Two ways to call a kernel",
|
|
124
|
+
"level": 2,
|
|
125
|
+
"body": "The methods have the same paths and the same inputs everywhere. What differs is how they answer.\n\n- **In the browser, through the renderer packages, and in scripts in the Bitbybit editors**, each kernel runs in a web worker as `bitbybit.occt`, `bitbybit.manifold` and `bitbybit.jscad`. Every call is asynchronous, and a shape is a small handle, `{ hash, type }`, to the shape the worker holds. Pass it to the next call; it cannot be read or changed.\n\n ```typescript\n const box = await bitbybit.occt.shapes.solid.createBox({ width: 80, length: 50, height: 8 });\n const rounded = await bitbybit.occt.fillets.filletEdges({ shape: box, radius: 2 });\n ```\n\n- **In Node, with the package alone**, the kernel runs in the process and its methods are synchronous:\n\n ```typescript\n import initOpenCascade from \"@bitbybit-dev/occt/bitbybit-dev-occt/index.js\";\n import { OCCTService, OccHelper, ShapesHelperService, VectorHelperService } from \"@bitbybit-dev/occt\";\n\n const occ = await initOpenCascade({ print: () => undefined });\n const occt = new OCCTService(occ, new OccHelper(new VectorHelperService(), new ShapesHelperService(), occ));\n const box = occt.shapes.solid.createBox({ width: 80, length: 50, height: 8 });\n ```\n\n `print` keeps the kernel's progress lines, such as a STEP writer's statistics, off the console. Run the TypeScript with `tsx` (`npx tsx part.ts`): the package's own imports leave out file extensions, as bundlers expect, so plain `node` cannot load them.\n\nWrite geometry so it runs both ways: `await` every call, as the projects `npm init @bitbybit-dev/app` creates do. Their `src/model.ts` holds a `buildModel(occt, params)` that the page calls with `bitbybit.occt` and the Node smoke test calls with the in-process service, typed as the worker's API through one cast.\n\nA few members differ between the two. Only the worker has `occt.deleteShape`, `occt.deleteShapes` and `occt.cleanAllCache`, which free the shapes it holds; in Node a shape is freed with its own `.delete()`. Through the worker `io.saveShapeSTEP` starts a browser download and `io.saveShapeSTEPAndReturn` returns the text; in Node `io.saveShapeSTEP` returns the text, so call it on the service itself rather than through code typed as the worker's API, which sees it return nothing. The worker also remembers results: the same call with the same inputs gives back the same handle without running again.\n\n`describe` shows the worker form, `createBox(inputs: Inputs.OCCT.BoxDto): Promise<Inputs.OCCT.TopoDSSolidPointer>`; in Node the same method returns the shape itself. A method's answer also names the types it returns, such as `Models.OCCT.SolidDebugInfo` for `occt.shapes.solid.debugInfo`; `describe` with that name lists their fields.",
|
|
126
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/cad-geometry"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"id": "how-the-occt-kernel-thinks",
|
|
130
|
+
"title": "How the OCCT kernel thinks",
|
|
131
|
+
"level": 2,
|
|
132
|
+
"body": "- **Y is up.** The ground is the XZ plane. A box's `height` runs along Y, a cylinder grows along its `direction`, `[0, 1, 0]` unless given, and a rectangle or circle wire lies flat on the ground unless its `direction`, the normal of its plane, says otherwise. Manifold and JSCAD build along Z instead: their cylinders stand on the XY plane.\n- **Shapes nest.** A vertex is a point, an edge a curve between vertices, a wire a chain of edges, a face a surface bounded by wires, a shell faces joined at their edges, a solid the volume a closed shell bounds, and a compound a group of shapes kept apart. Each method says which kinds it takes and gives: `operations.extrude` turns a face into a solid, but a wire only into a shell.\n- **Units are plain numbers.** STEP files are written in millimetres, so model in millimetres when the part goes to another CAD tool. Angles are degrees, and tolerances are in the model's units.\n- **Right-handed.** OpenCascade is right-handed, as three.js and PlayCanvas are. A Babylon.js scene is left-handed, and shows every part mirrored, unless `scene.useRightHandedSystem` is set when it is created.\n- **Colours** are hex strings such as `\"#ff8000\"`, or arrays of three numbers from 0 to 1.",
|
|
133
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/cad-geometry"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"id": "the-order-to-build-a-part-in",
|
|
137
|
+
"title": "The order to build a part in",
|
|
138
|
+
"level": 2,
|
|
139
|
+
"body": "Each step starts from what the step before made, so this order avoids most failures:\n\n1. **A profile.** A wire from `shapes.wire.createRectangleWire`, `createCircleWire` or `createPolygonWire`, or a pen sketch of lines and arcs with `occt.sketch`. `fillets.fillet2d` rounds a flat wire's corners.\n2. **A face.** `shapes.face.createFaceFromWire`, with `planar: true` for a flat profile.\n3. **A solid.** `operations.extrude` along a vector whose length is the distance, `operations.revolve` about an axis, `operations.loft` through several wires, or `operations.pipe` along a path; or a primitive, such as `shapes.solid.createBox` or `shapes.solid.createCylinder`.\n4. **Booleans.** `booleans.union` fuses, `booleans.difference` cuts, `booleans.intersection` keeps what the shapes share. Cut round holes with cylinders rather than as holes in the profile.\n5. **Fillets and chamfers.** `fillets.filletEdges`, `fillets.chamferEdges` and their list forms, on edges chosen by their geometry. Round an edge once the booleans that make it are done; a hole cut afterwards leaves a fillet it does not touch as it was.\n6. **Placement.** `transforms.translate`, `transforms.rotate` (degrees, about an axis through the origin) and `transforms.mirror`.\n7. **Checks, then drawing or export**, as the sections below describe.",
|
|
140
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/cad-geometry"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"id": "a-part-to-start-from",
|
|
144
|
+
"title": "A part to start from",
|
|
145
|
+
"level": 2,
|
|
146
|
+
"body": "A mounting bracket: a plate with rounded corners, a boss with a bore, a fillet where the boss meets the plate, and four holes. It follows the order above, chooses the edge to fillet by where it is, and runs unchanged in the browser and in Node:\n\n```typescript\nimport type { BitByBitBase, Inputs } from \"@bitbybit-dev/threejs\";\n\ntype Occt = BitByBitBase[\"occt\"];\ntype Shape = Awaited<ReturnType<Occt[\"booleans\"][\"difference\"]>>;\n\nconst PLATE = { width: 80, length: 50, thickness: 8, cornerRadius: 6 };\nconst BOSS = { radius: 12, height: 20, bore: 6 };\nconst HOLE = { radius: 3.5, inset: 10 };\nconst ROOT_FILLET = 3;\nconst TOLERANCE = 1e-6;\nconst UP: Inputs.Base.Vector3 = [0, 1, 0];\n\nfunction isAt(point: Inputs.Base.Point3 | undefined, target: Inputs.Base.Point3): boolean {\n return point !== undefined && Math.hypot(point[0] - target[0], point[1] - target[1], point[2] - target[2]) < TOLERANCE;\n}\n\nexport async function buildBracket(occt: Occt): Promise<Shape> {\n const outline = await occt.shapes.wire.createRectangleWire({ width: PLATE.width, length: PLATE.length, center: [0, 0, 0], direction: UP });\n const rounded = await occt.fillets.fillet2d({ shape: outline, radius: PLATE.cornerRadius });\n const face = await occt.shapes.face.createFaceFromWire({ shape: rounded, planar: true });\n const plate = await occt.operations.extrude({ shape: face, direction: [0, PLATE.thickness, 0] });\n const boss = await occt.shapes.solid.createCylinder({ radius: BOSS.radius, height: PLATE.thickness + BOSS.height, center: [0, 0, 0], direction: UP });\n const body = await occt.booleans.union({ shapes: [plate, boss] });\n\n const edges = await occt.shapes.edge.getEdges({ shape: body });\n const centers = await occt.shapes.edge.getEdgesCentersOfMass({ shapes: edges });\n const root = edges.filter((_edge, index) => isAt(centers[index], [0, PLATE.thickness, 0]));\n const filleted = await occt.fillets.filletEdgesListOneRadius({ shape: body, edges: root, radius: ROOT_FILLET });\n\n const x = PLATE.width / 2 - HOLE.inset;\n const z = PLATE.length / 2 - HOLE.inset;\n const corners: Inputs.Base.Point3[] = [[x, 0, z], [-x, 0, z], [-x, 0, -z], [x, 0, -z]];\n const holes = await Promise.all(corners.map((center) => occt.shapes.solid.createCylinder({ radius: HOLE.radius, height: PLATE.thickness, center, direction: UP })));\n const bore = await occt.shapes.solid.createCylinder({ radius: BOSS.bore, height: PLATE.thickness + BOSS.height, center: [0, 0, 0], direction: UP });\n return occt.booleans.difference({ shape: filleted, shapes: [...holes, bore] });\n}\n```\n\nThe result is a valid solid of 18 faces, 80 by 28 by 50 mm, of about 36,556 mm³. The plate lies on the ground and the boss rises along Y. The only circle centred on the boss's axis at the plate's top is where the boss meets the plate, so that is the edge the fillet rounds, whatever number the kernel gave it. In a scaffolded project the function goes into `src/model.ts`, whose `Occt` and `Shape` types are the same; in a script in the editors, make the same calls on `bitbybit.occt`. In Node, hand it the in-process service through one cast and write a STEP file standing upright for a Z-up CAD tool:\n\n```typescript\nimport { writeFileSync } from \"node:fs\";\nimport initOpenCascade from \"@bitbybit-dev/occt/bitbybit-dev-occt/index.js\";\nimport { OCCTService, OccHelper, ShapesHelperService, VectorHelperService } from \"@bitbybit-dev/occt\";\nimport { buildBracket } from \"./bracket.ts\";\n\ntype Occt = Parameters<typeof buildBracket>[0];\ntype KernelShape = Parameters<OCCTService[\"io\"][\"saveShapeSTEP\"]>[0][\"shape\"];\n\nfunction asWorkerApi(service: object): Occt {\n return service as Occt;\n}\n\nfunction asKernelShape(shape: object): KernelShape {\n return shape as KernelShape;\n}\n\nconst occ = await initOpenCascade({ print: () => undefined });\nconst service = new OCCTService(occ, new OccHelper(new VectorHelperService(), new ShapesHelperService(), occ));\nconst bracket = asKernelShape(await buildBracket(asWorkerApi(service)));\nconst upright = service.transforms.rotate({ shape: bracket, axis: [1, 0, 0], angle: 90 });\nwriteFileSync(\"bracket.step\", service.io.saveShapeSTEP({ shape: upright, fileName: \"bracket.step\" }));\n```",
|
|
147
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/cad-geometry"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"id": "choosing-edges-and-faces",
|
|
151
|
+
"title": "Choosing edges and faces",
|
|
152
|
+
"level": 2,
|
|
153
|
+
"body": "- **Never guess an index.** Edges and faces are numbered in the order the kernel walks a shape, which nothing predicts and every operation changes. `fillets.filletEdges` takes `indexes` counted from 0 in the order `shapes.edge.getEdges` lists the edges, and `fillets.fillet2d` takes corners counted from 1; an index read off one shape means nothing on the next.\n- **Choose by geometry.** `shapes.edge.getEdges` lists a shape's edges; `shapes.edge.getEdgesCentersOfMass` and `shapes.edge.getEdgesLengths` measure them; `shapes.edge.isEdgeCircular`, `shapes.edge.isEdgeLinear`, `shapes.edge.getCircularEdgeRadius` and `shapes.edge.getCircularEdgeCenterPoint` say what each is. A full circle's center of mass is its center, but an arc's lies on its inner side, so find arcs, such as a rim a slot has cut open, by being circular, by their radius and by their circle's center. Keep the edges you mean, as the bracket does, and pass them to `fillets.filletEdgesListOneRadius`, `fillets.filletEdgesList` or `fillets.chamferEdgesList`, which takes a distance for each edge. Faces work the same way, with `shapes.face.getFaces`, `shapes.face.getFacesCentersOfMass` and `shapes.face.getFacesAreas`.\n- **Follow an edge through a change.** Methods ending in `WithHistory`, such as `booleans.differenceWithHistory` and `fillets.filletEdgesWithHistory`, also report what became of every face, edge and vertex they were given, for code that must keep pointing at the same edge as the part changes.\n- **Labels are for people.** `drawEdgeIndexes` and `drawFaceIndexes` in the draw options write each edge's and face's number on the screen, which helps a person find one but does not replace choosing by geometry in code.",
|
|
154
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/cad-geometry"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"id": "checking-a-shape",
|
|
158
|
+
"title": "Checking a shape",
|
|
159
|
+
"level": 2,
|
|
160
|
+
"body": "Each check is one call. Run them after any step that may have gone wrong:\n\n- `shapeFix.isValid` checks that a shape is well formed, of any kind. An operation can finish without an error and still return an invalid shape: a fillet too large for the faces beside its edge can.\n- `shapes.solid.debugInfo` reports in one answer how many faces and edges a solid has, its area and its volume. Its `valid` is false only for an empty shape; it does not check the geometry, so use `shapeFix.isValid` for that.\n- `shapes.solid.getSolidVolume` and `analysis.measure.tightBoundingBox` measure. Compare them with what the part should be: a cut that misses its shape, or a face whose hole was wound the wrong way, changes the volume by the wrong amount or not at all, without an error. The tight box follows the exact geometry; the older `operations.boundingBoxOfShape` can be loose around curved faces and is deprecated.\n- A method that cannot do what it was asked throws and says why, such as a fillet the faces beside an edge cannot hold. Read the message, change the input and run again.",
|
|
161
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/cad-geometry"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"id": "drawing-and-exporting-a-part",
|
|
165
|
+
"title": "Drawing and exporting a part",
|
|
166
|
+
"level": 2,
|
|
167
|
+
"body": "- **Drawing.** In the browser and in the editors, `draw.drawAnyAsync({ entity: shape, options })` draws any shape, mesh or point list; for OpenCascade shapes `options` is an `Inputs.Draw.DrawOcctShapeOptions`, with `faceColour`, `edgeColour`, `edgeWidth` and `precision`, the meshing tolerance. Draw the finished part rather than every step.\n- **STEP**, the exact format other CAD tools open: `io.saveShapeSTEPAndReturn` through the worker, `io.saveShapeSTEP` on the in-process service in Node, both giving the file's text in millimetres. Most CAD tools are Z-up: turn the part first with `transforms.rotate({ shape, axis: [1, 0, 0], angle: 90 })`, which takes Y up to Z and keeps the part as it was built. The `adjustYtoZ` option swaps Y and Z instead, which mirrors the part: it matches what a left-handed Babylon.js scene shows.\n- **STL** for printing: `io.saveShapeStlAndReturn` through the worker, `io.saveShapeStl` in Node, with `precision` as the meshing tolerance and `binary` for the smaller form. Turn the part as for STEP.\n- **Drawings and assemblies.** `io.shapeToDxfPaths` and `io.dxfCreate` write a DXF of flat geometry, and the documents of `occt.assembly.manager` hold several parts with names, colours and placements, written to one STEP file with `occt.assembly.manager.exportDocumentToStep`.",
|
|
168
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/cad-geometry"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"id": "manifold-and-jscad",
|
|
172
|
+
"title": "Manifold and JSCAD",
|
|
173
|
+
"level": 2,
|
|
174
|
+
"body": "- **Manifold** solids are handles too, through the worker. Make them with `manifold.manifold.shapes.cube`, `sphere` and `cylinder`, or from a flat outline with `manifold.crossSection.shapes.rectangle` or `manifold.crossSection.shapes.circle` and `manifold.crossSection.operations.extrude`. Combine them with `manifold.manifold.booleans.union`, `difference` and `intersection`, which take the whole list of `manifolds` at once, and measure them with `manifold.manifold.evaluate.volume`. `cube` and `cylinder` are centred on the origin by default (`center: true`), cylinders and extrusions stand along Z, and `circularSegments` sets how round a curve is. Free a solid with `manifold.deleteManifoldOrCrossSection` through the worker, or its own `.delete()` in Node.\n- **From OpenCascade to Manifold**, mesh the part and build a solid from the mesh:\n\n ```typescript\n const mesh = await bitbybit.occt.shapeToManifoldMesh({ shape: bracket, precision: 0.05 });\n const solid = await bitbybit.manifold.manifold.shapes.manifoldFromMesh({ mesh });\n ```\n\n- **JSCAD** entities are plain data, copied to and from the worker. `jscad.shapes.cube` and `jscad.shapes.cylinder` (along Z, centred on `center`) make solids, `jscad.booleans.union` and `jscad.booleans.subtract` combine a list of `meshes`, and `jscad.text.cylindricalText` writes text as solids. Move a part to OpenCascade when it needs fillets or STEP.",
|
|
175
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/cad-geometry"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"id": "mistakes-to-avoid-in-geometry-code",
|
|
179
|
+
"title": "Mistakes to avoid in geometry code",
|
|
180
|
+
"level": 2,
|
|
181
|
+
"body": "- **Guessed edge indexes.** An index from memory or from a picture rounds the wrong edge, or none. Choose edges by their geometry; `fillets.filletEdges` counts from 0 and `fillets.fillet2d` from 1.\n- **A fillet too large for its faces.** It throws, or returns an invalid solid without an error. Keep the radius under half the width of the narrowest face beside the edge, and check `shapeFix.isValid` after it.\n- **Holes in a face made from several wires.** `shapes.face.createFaceFromWires` cuts a hole only with a wire that runs against the outline; a wire running the same way adds material, silently. Cut holes with `booleans.difference` and cylinders, or turn such a wire round with `shapes.wire.reversedWire`.\n- **A cut that misses.** A tool that does not reach the shape leaves it as it was, with no error. Check that the volume changed.\n- **Extruding a wire.** That gives a shell, not a solid; make a face first.\n- **Treating Z as up in OpenCascade.** Heights run along Y there. Manifold and JSCAD build along Z, so primitives from different kernels need a quarter turn about X to line up.\n- **A missing `await`.** Through the worker every call returns a promise, and a promise passed as a shape fails in the next call.\n- **Worker-only members in Node.** `occt.deleteShape`, `occt.cleanAllCache` and `io.saveShapeSTEPAndReturn` exist only through the worker; in Node use `.delete()` and `io.saveShapeSTEP`.\n- **`adjustYtoZ` on export.** It mirrors the part; turn it about X instead.\n- **Degenerate numbers.** A scale of 0, a zero-length direction or `NaN` can stop the kernel rather than make it throw. Check computed values before they reach a call.\n- **Keeping every shape.** The worker holds every shape it has made until it is freed. Free what is no longer needed with `occt.deleteShapes`, or everything with `occt.cleanAllCache` before building a new part from scratch.\n- **Fields that do not exist.** `describe` each method first; its inputs, defaults and ranges come from the index, not from memory.",
|
|
182
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/cad-geometry"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"id": "what-a-design-document-is",
|
|
186
|
+
"title": "What a design document is",
|
|
187
|
+
"level": 2,
|
|
188
|
+
"body": "- **A part document** builds parts from features: `parameters`, `configurations`, `features`, `parts`, `materials` and `assets`.\n- **An assembly document** (`\"kind\": \"assembly\"`) places parts of other documents as `components`, moved by `joints` between their connectors. It has no geometry of its own.\n- **The document is the truth.** Shapes are always rebuilt from it and never stored in it. Every feature has a stable `id` that is never reused, and later features refer to earlier ones by those ids.\n- **Every number may be an expression** over the parameters, such as `\"width / 2 + 3\"`.\n- **Nothing is evaluated as code.** Expressions are read by a small arithmetic parser, and an `operation` feature calls a public method of the package by its dotted path.\n- **Unknown properties are errors.** A misspelt field is reported, never ignored. Free data goes into `extras`.",
|
|
189
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/design-documents"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"id": "the-loop-an-agent-should-follow",
|
|
193
|
+
"title": "The loop an agent should follow",
|
|
194
|
+
"level": 2,
|
|
195
|
+
"body": "1. **Write the document** against the schema. Name it in `$schema` so editors validate it as you type.\n2. **Validate it**: `await bitbybit.occt.design.validate({ document })` returns every problem with a JSON pointer to it, such as `/features/3/edges/count`. It builds nothing, so it is cheap. Fix every issue before building.\n3. **Build it**: `await bitbybit.occt.design.build({ document })` returns the `parts` with their shapes, a `report` with one entry per feature (`ok`, `failed` with messages, `skipped` because something it used failed, `suppressed`), and `issues` for parts, looks and connectors.\n4. **Read the report.** A failed feature names why: a reference that found 3 faces where it expects 4, a fillet radius the faces cannot take, an expression that divides by 0. Change the document and build again; features that did not change are reused, so the next build is fast.\n5. **Draw the result**: `await bitbybit.draw.drawAnyAsync({ entity: result })` draws every part with its looks, each placement an instance.\n6. **Try other values** with `parameters` or a `configuration` on the same call, without editing the document: `build({ document, parameters: { width: 80 } })`.\n\nFillets fail most often, and one tool helps with them: `design.probeFillet` reports which edges a fillet's reference finds and the largest radius that builds.",
|
|
196
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/design-documents"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"id": "a-first-document",
|
|
200
|
+
"title": "A first document",
|
|
201
|
+
"level": 2,
|
|
202
|
+
"body": "A plate with two holes and rounded top edges, made of aluminium, with a part number written from its size:\n\n```json title=\"bracket.design.json\"\n{\n \"$schema\": \"https://git-cdn.bitbybit.dev/v1.5.0-rc.0/schemas/design-document/experimental.json\",\n \"schemaVersion\": 1,\n \"id\": \"3f1c2a7e-8b4d-4c1a-9e2f-5d6b7a8c9e01\",\n \"meta\": { \"name\": \"Bracket\" },\n \"parameters\": {\n \"width\": { \"value\": 60, \"min\": 30, \"unit\": \"mm\" },\n \"depth\": { \"value\": 40, \"min\": 20, \"unit\": \"mm\" },\n \"thickness\": { \"value\": 6, \"min\": 2, \"unit\": \"mm\" },\n \"hole\": { \"value\": 6, \"min\": 2, \"max\": 12, \"unit\": \"mm\" }\n },\n \"features\": [\n {\n \"id\": \"base\", \"type\": \"sketch\", \"on\": { \"plane\": \"XY\" }, \"start\": [0, 0],\n \"pen\": [\n { \"type\": \"hLine\", \"id\": \"south\", \"length\": \"width\" },\n { \"type\": \"vLine\", \"id\": \"east\", \"length\": \"depth\" },\n { \"type\": \"hLine\", \"id\": \"north\", \"length\": \"-width\" },\n { \"type\": \"close\", \"id\": \"west\" }\n ]\n },\n { \"id\": \"plate\", \"type\": \"extrude\", \"profile\": \"base\", \"distance\": \"thickness\" },\n {\n \"id\": \"holes\", \"type\": \"hole\", \"body\": \"plate\",\n \"on\": { \"of\": \"plate\", \"role\": \"end\", \"count\": 1 },\n \"at\": [{ \"id\": \"left\", \"x\": 10, \"y\": \"depth / 2\" }, { \"id\": \"right\", \"x\": \"width - 10\", \"y\": \"depth / 2\" }],\n \"diameter\": \"hole\"\n },\n {\n \"id\": \"round\", \"type\": \"fillet\", \"body\": \"plate\", \"radius\": 2,\n \"edges\": { \"between\": [{ \"of\": \"plate\", \"role\": \"end\" }, { \"of\": \"plate\", \"role\": \"side\" }], \"count\": 4 }\n }\n ],\n \"materials\": [\n { \"id\": \"aluminium\", \"density\": 2700, \"appearance\": { \"color\": \"#b0b4b8\", \"metallic\": 0.8, \"roughness\": 0.4 } }\n ],\n \"parts\": [\n {\n \"id\": \"bracket\", \"name\": \"Bracket\", \"body\": \"plate\", \"material\": \"aluminium\",\n \"properties\": { \"partNumber\": \"BRK-{width}x{depth}\" },\n \"connectors\": [\n { \"id\": \"pivotTop\", \"on\": { \"of\": \"plate\", \"role\": \"end\", \"count\": 1 }, \"axis\": { \"of\": \"holes\", \"role\": \"wall\", \"from\": \"left\" } },\n { \"id\": \"pivotBottom\", \"on\": { \"of\": \"plate\", \"role\": \"start\", \"count\": 1 }, \"axis\": { \"of\": \"holes\", \"role\": \"wall\", \"from\": \"left\" } }\n ]\n }\n ]\n}\n```\n\n- The sketch draws a rectangle with a pen: each command moves from where the last one ended, and `close` returns to `start`. The command ids name the four side faces the extrude sweeps from them.\n- The extrude starts a body named `plate`. Its bottom face is `start`, its top `end` and its walls `side`.\n- The holes are placed on the face the reference `{ \"of\": \"plate\", \"role\": \"end\", \"count\": 1 }` names, at x and y on that face. Each position has an id, so a later reference can name one hole's wall.\n- The fillet rounds the edges between the top and the walls: exactly 4, or the build reports otherwise.\n- The connectors are frames where an assembly fastens the part: on the top and the bottom face, at the left hole's axis.",
|
|
203
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/design-documents"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"id": "parameters-and-expressions",
|
|
207
|
+
"title": "Parameters and expressions",
|
|
208
|
+
"level": 2,
|
|
209
|
+
"body": "- A parameter is a number, or an object with its `value` and limits: `{ \"value\": 6, \"min\": 2, \"max\": 12, \"unit\": \"mm\" }`. `type` may be `number` (the default), `boolean`, `choice` (with `options`) or `text`.\n- `min`, `max` and `options` are enforced on every value a build uses. `label`, `description`, `group`, `step` and `unit` are for people and editors.\n- A parameter may be an expression over others: `\"inner\": \"outer - 2 * wall\"`.\n- `configurations` are named sets of values, such as the sizes of a product: `{ \"id\": \"large\", \"values\": { \"width\": 120 } }`, chosen with `build({ document, configuration: \"large\" })`.\n- Expressions have `+ - * / ^`, comparisons, `&& || !`, `if(test, then, otherwise)`, `min`, `max`, `abs`, `sqrt`, `floor`, `ceil`, `round`, and trigonometry in degrees (`sin`, `cos`, `tan`, `asin`, `acos`, `atan`, `atan2`). `pi`, `tau`, `e`, `true` and `false` are constants. A step that gives infinity or not-a-number is an error.\n- Where a number or a switch is expected, a string is an expression. Where text is expected (a colour, a material id, a choice), a string is the text itself, and `{ \"expr\": \"...\" }` computes it.\n- `suppressed` on a feature leaves it out when it is true or its expression is not 0: `\"suppressed\": \"!withHoles\"`.",
|
|
210
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/design-documents"
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
"id": "sketches",
|
|
214
|
+
"title": "Sketches",
|
|
215
|
+
"level": 2,
|
|
216
|
+
"body": "- `on` places the sketch: `{ \"plane\": \"XY\" }` (or `XZ`, `YZ`, with an `offset`), `{ \"frame\": { \"origin\", \"normal\", \"direction\" } }`, or `{ \"face\": <face reference>, \"origin\": [...], \"direction\": [...] }` on a flat face of a body. A sketch on a face follows the face when parameters move it.\n- `pen` draws one outline from `start`: `line` (to a point), `hLine` and `vLine` (a length along x or y, negative for the other way), `polarLine`, `tangentLine`, `threePointArc`, `tangentArc`, `sagittaArc`, `bulgeArc`, `quadratic`, `cubic`, `close`, and `filletCorner` and `chamferCorner`, which round or bevel the corner between the commands before and after them.\n- A sketch with no `pen` and no `loops` draws nothing yet: it is only its plane, which an editor draws on, and a feature that uses it fails until it draws something.\n- An outline that ends with `close`, or back at its `start`, is closed, and a closed outline is a face. `\"face\": false` keeps it a wire, such as a closed path to sweep along; an open outline is always a wire.\n- `circle` draws an exact circle as one closed edge: `{ \"type\": \"circle\", \"id\": \"bore\", \"centre\": [0, 0], \"radius\": 5 }`.\n- `loops` draws several outlines in one sketch, the first the outside and each further one a hole in it, so one sketch makes a washer: `\"loops\": [{ \"start\": [-15, -15], \"pen\": [...] }, { \"pen\": [{ \"type\": \"circle\", ... }] }]`.\n- **Give an id to every command a later feature refers to.** A side face is named after the command it was swept from; a command without an id has no name a reference can use.",
|
|
217
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/design-documents"
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"id": "features",
|
|
221
|
+
"title": "Features",
|
|
222
|
+
"level": 2,
|
|
223
|
+
"body": "| Feature | What it does | Faces it names |\n|---|---|---|\n| `extrude` | sweeps a sketch `distance` along its normal | `start`, `end`, `side` (per command) |\n| `revolve` | turns a sketch about an `axis` | `start`, `end`, `side` |\n| `sweep` | sweeps a profile along a `path` sketch | `start`, `end`, `side` |\n| `loft` | skins two or more sketches in order | `start`, `end`, `side` |\n| `boolean` | `union`, `difference` or `intersection` of `body` with `tools` | `new` for faces no input had |\n| `fillet` | rounds the `edges` a reference names | `round` |\n| `chamfer` | bevels them | `bevel` |\n| `shell` | hollows a body, leaving the `open` faces open, including bodies rounded all round when the open faces are flat | `rim`, `inner` |\n| `hole` | drills holes `at` positions on a face, with counterbores or countersinks | `wall` (per position id) |\n| `boss` | raises a sketch on a face | `side`, `end` |\n| `pocket` | sinks a sketch into a face, a `distance`, `until` a face or `through` | `side`, `end` |\n| `linearPattern`, `polarPattern` | repeats a body `count` times | copies picked with `copy` |\n| `mirror` | mirrors a body across a plane | the image is copy 1 |\n| `pushPull` | moves a face of a body along its normal: out when `distance` is above 0, in when below; `mode` `extrude`, the default, sweeps one flat face straight and adds or cuts the swept solid, `offset` moves the faces themselves, flat or curved, the faces around them stretching to follow, and with a `count` the reference may name several faces | `end` (the moved faces, which keep their names), `side` (the faces an extrude sweeps out) |\n| `removeFaces` | removes the `count` faces a reference names and closes the gap from the faces around them: a hole's wall fills the hole, a round sharpens its edge | keeps every name the faces that stay had |\n| `transform` | moves a body: turns it `rotate` degrees about X, Y and Z through a `pivot`, then shifts it by `translate` | keeps every name it had |\n| `import` | starts a body from a STEP, IGES or BREP asset pinned by its SHA-256 | `face` (per index) |\n| `operation` | calls any method of the package by its path, such as `\"occt.shapes.shape.unifySameDomain\"` | carried through history, otherwise `face` |\n| `script` | runs code from an asset pinned by its SHA-256, outside the kernel, on bodies, references and values | the roles the script returns, otherwise `face` |\n\nFeatures that make a solid start a body named by their id, or join the body they name with `\"body\": \"<id>\"` and `\"join\": \"add\"`, `\"cut\"` or `\"intersect\"`.",
|
|
224
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/design-documents"
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
"id": "references-naming-faces-and-edges",
|
|
228
|
+
"title": "References: naming faces and edges",
|
|
229
|
+
"level": 2,
|
|
230
|
+
"body": "A feature that acts on faces or edges stores a reference, never an index. Indexes change whenever the model changes; references follow the faces through every later feature.\n\n- **A face reference** names the feature that made the faces and the role it made them in: `{ \"of\": \"plate\", \"role\": \"side\", \"from\": \"base.east\" }` is the side of `plate` swept from the sketch command `east` of the sketch `base`. `from` also takes a hole position's id (`{ \"of\": \"holes\", \"role\": \"wall\", \"from\": \"left\" }`) or an imported face's index as text.\n- **`count`** says how many faces the reference must find. A different number is an error, never a guess, so give it whenever you know it.\n- **`copy`** picks copies of a pattern or a mirror: `{ \"of\": \"row\", \"index\": 2 }`, or `\"index\": \"all\"` for every copy and the original.\n- **`filter`** narrows what the lineage found with a selector of `occt.select`: `{ \"select\": \"facing\", \"direction\": [0, 0, 1] }`, or `{ \"select\": \"extreme\", \"direction\": [1, 0, 0] }`. Prefer names over filters: a filter can move to a face that comes to win it after an edit.\n- **An edge reference** names the edges between two sets of faces, and always has a `count`: `{ \"between\": [{ \"of\": \"plate\", \"role\": \"end\" }, { \"of\": \"plate\", \"role\": \"side\" }], \"count\": 4 }`.\n\n**Hints.** `design.withHints({ document })` writes onto every face reference what its faces are like (surface type, area, position and normal relative to the body, and the names of their neighbours). Hints change nothing while names resolve. When an edit loses a reference's faces (a sketch redrawn without its ids, an operation that keeps no history), `build({ document, rebind: \"report\" })` takes the faces most like the hint, when they stand clear of every other face, and reports the feature `rebound`; the default, `rebind: \"never\"`, fails the feature and lists those faces as `repairs`. Write them when a document is saved; an agent writing a document by hand can leave them out.",
|
|
231
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/design-documents"
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
"id": "script-features",
|
|
235
|
+
"title": "Script features",
|
|
236
|
+
"level": 2,
|
|
237
|
+
"body": "A script feature carries what a generator knows, such as \"a gear of 14 teeth\", as one step of the document instead of the hundred commands it expands to.\n\n- **The code is an asset** pinned by its SHA-256, given to the build in `assets` as an import's file is: `{ \"id\": \"gear\", \"type\": \"script\", \"script\": \"gearCode\", \"params\": { \"teeth\": 14, \"on\": { \"faces\": { \"of\": \"hub\", \"role\": \"end\", \"count\": 1 } } } }`.\n- **The code is the body of an async function** given `inputs` (the params, with bodies as shapes, references as indexes and expressions as numbers) and `occt` (the OCCT API). It returns a shape, or `{ shape, roles }` naming faces by role, so later features refer to them as they do to any feature's faces: `{ \"of\": \"gear\", \"role\": \"tooth\" }`.\n- **The kernel runs no code.** `design.build` reports the feature `pending` and lists what it would run on; `design.buildWithScripts` runs each script and builds again until nothing waits. Run only documents whose scripts you trust.",
|
|
238
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/design-documents"
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
"id": "parts-materials-and-looks",
|
|
242
|
+
"title": "Parts, materials and looks",
|
|
243
|
+
"level": 2,
|
|
244
|
+
"body": "- **A part** is a body the document delivers, under a stable `id`: `{ \"id\": \"bracket\", \"body\": \"plate\", \"material\": \"aluminium\" }`. A body no part names is construction geometry. Without `parts`, every body that is not used up is a part.\n- **A material** carries `density` in kilograms per cubic metre (so the build reports mass), a `standard`, an `appearance` and `properties`. A part's `material` may be `{ \"expr\": \"...\" }`, so a choice parameter can pick it.\n- **Looks**: `color` and `edgeColor` as `#rrggbb` in sRGB, `metallic`, `roughness`, `opacity`, `emissive` and `emissiveStrength`. A part's appearance lies over its material's, and `faces` and `edges` entries colour what a reference names: `\"faces\": [{ \"faces\": { \"of\": \"holes\", \"role\": \"wall\" }, \"color\": \"#202020\" }]`.\n- **Properties** are text, numbers, booleans or templates over the parameters: `\"partNumber\": \"BRK-{width}x{depth}\"`. `partNumber`, `description`, `finish` and `unitOfMeasure` mean what they say to the bill of materials, and STEP exports carry every property.\n- **Connectors** are named frames on a part, on the flat face `on` names: at `origin`, at the axis of a cylindrical face (`axis`, such as a hole's wall), or at the centre of a circular edge (`centre`). An `axis` that names every wall of a hole makes one connector per hole position, `<id>.<position id>`.",
|
|
245
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/design-documents"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"id": "assemblies",
|
|
249
|
+
"title": "Assemblies",
|
|
250
|
+
"level": 2,
|
|
251
|
+
"body": "An assembly places parts of other documents. The documents are given to the build beside it, keyed by their `id`; the runner fetches nothing.\n\n```json title=\"hinge.design.json\"\n{\n \"$schema\": \"https://git-cdn.bitbybit.dev/v1.5.0-rc.0/schemas/design-document/experimental.json\",\n \"schemaVersion\": 1,\n \"kind\": \"assembly\",\n \"meta\": { \"name\": \"Swivel pair\" },\n \"parameters\": {\n \"swing\": { \"value\": 30, \"min\": 0, \"max\": 90, \"unit\": \"deg\" }\n },\n \"components\": [\n { \"id\": \"lower\", \"source\": { \"document\": \"3f1c2a7e-8b4d-4c1a-9e2f-5d6b7a8c9e01\", \"part\": \"bracket\" } },\n { \"id\": \"upper\", \"source\": { \"document\": \"3f1c2a7e-8b4d-4c1a-9e2f-5d6b7a8c9e01\", \"part\": \"bracket\", \"parameters\": { \"width\": 80 } } }\n ],\n \"joints\": [\n {\n \"id\": \"pivot\", \"type\": \"revolute\", \"component\": \"upper\", \"connector\": \"pivotBottom\",\n \"to\": { \"component\": \"lower\", \"connector\": \"pivotTop\" },\n \"angle\": \"swing\", \"limits\": { \"angle\": [0, 90] }\n }\n ]\n}\n```\n\n- Build it with the documents it places: `build({ document: hinge, documents: [bracket] })`. The result has the parts, every placed occurrence with its matrix, the bill of materials, and the structure that `assembly.manager.buildAssemblyDocument` exports to STEP and glTF.\n- **Joints** put a component's connector against another's, faces meeting and facing each other: `fastened` moves nothing, `revolute` turns by `angle` about the shared axis, `slider` moves by `offset` along it, `cylindrical` does both. `flip` makes the faces face the same way, `limits` bound what may move, and joints form a tree.\n- **`replicate`** places a component on every member of a connector set, such as a bolt in every hole of a flange: `\"replicate\": { \"connector\": \"seat\", \"to\": { \"component\": \"flange\", \"connector\": \"bolts\" } }`.\n- **`pattern`** places copies of a component where it is placed, turned about an axis or stepped along a direction, such as the blades of a fan: `\"pattern\": { \"polar\": { \"axis\": { \"origin\": [0, 0, 0], \"direction\": [1, 0, 0] }, \"count\": \"blades\" } }`, or `{ \"linear\": { \"direction\": [1, 0, 0], \"spacing\": 25, \"count\": 4 } }`. A polar pattern spaces its copies as the `polarPattern` feature does: a whole turn shared out, a part of one (`angle`) with both ends included, the first turned by `start`. Each copy is an occurrence of its own, `blade.1`, `blade.2` and so on, counted in the bill of materials. A patterned component is not moved by a joint or joined to; to turn a row of blades, pattern them inside a sub-assembly and join that.\n- A component's `source.parameters` drive the placed document's values from the assembly's own, so one parameter can size several parts.\n- An assembly may publish `connectors` of its components, so a larger assembly can join it as one unit.",
|
|
252
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/design-documents"
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
"id": "mistakes-to-avoid",
|
|
256
|
+
"title": "Mistakes to avoid",
|
|
257
|
+
"level": 2,
|
|
258
|
+
"body": "- **Indexes in references.** Never write a face or edge by its number. Name it by the feature and role that made it.\n- **Missing command and position ids.** A side or a hole wall that a later feature names needs an id where it was drawn.\n- **Edge references without `count`.** They are refused; count the edges you mean.\n- **Operations without the kernel.** An `operation` path starts with the kernel: `\"occt.fillets.filletEdges\"`, not `\"fillets.filletEdges\"`. Look its inputs up with the MCP's `describe` before writing them, and pass bodies as `{ \"body\": \"<id>\" }`.\n- **Guessed units.** Lengths are in the document's `units.length`, millimetres when left out, and angles in degrees.\n- **Fields that do not exist.** The schema and `validate` refuse unknown properties. Check them rather than inventing a plausible one.\n- **Building before validating.** `validate` reports every problem at once with a pointer to it; a build stops at the first feature that fails and skips what depends on it.",
|
|
259
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/design-documents"
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
"id": "ifc-models-in-bitbybit",
|
|
263
|
+
"title": "IFC models in Bitbybit",
|
|
264
|
+
"level": 2,
|
|
265
|
+
"body": "- **`@bitbybit-dev/ifc` is plain TypeScript.** It needs no WebAssembly, no worker and no CAD kernel, so it runs in Node, in a serverless function and in the browser alike. It creates, reads, changes and writes models.\n- **A building is made from standard elements.** A wall keeps its axis, height and layers in the file, and its joins are recorded as IFC connections, so a tool that understands IFC edits it as a wall. The same is true of slabs, openings, doors and windows, roofs, columns, beams and members.\n- **Geometry is described, not built.** `ifc.geometry.recipe` turns a model into data a kernel builds: Manifold for fast meshes to draw, OpenCascade for exact shapes and STEP files.\n- **The API is beta.** Names and inputs may still change before the first stable version. Look every method up with `describe` rather than from memory.\n- **It runs locally.** Everything here is in the MIT npm packages; nothing about IFC needs CAD Cloud.\n- **Not yet.** There is no stair element (a stairwell is an opening in a slab, and flights can be built from members), no curved wall or arched opening, and no building services (ducts, pipes, cables).",
|
|
266
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/ifc-models"
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
"id": "two-ways-to-call-the-ifc-api",
|
|
270
|
+
"title": "Two ways to call the IFC API",
|
|
271
|
+
"level": 2,
|
|
272
|
+
"body": "The methods have the same paths and the same inputs everywhere. What differs is how they answer.\n\n- **In Node, or anywhere with the package alone**, the methods are synchronous and a model is a value you hold:\n\n ```typescript\n import { IFC, IFCService } from \"@bitbybit-dev/ifc\";\n\n const ifc = new IFCService();\n let model = ifc.model.create({ name: \"House\", seed: \"house-1\" });\n model = ifc.spatial.addStorey({ model, id: \"ground\", name: \"Ground floor\", elevation: 0 });\n ```\n\n Run the TypeScript with `tsx` (`npx tsx house.ts`): the package's own imports leave out file extensions, as bundlers expect, so plain `node` cannot load them. Write the file with `writeFileSync(\"house.ifc\", ifc.model.writeBytes({ model, fileName: \"house.ifc\" }))`.\n- **In the browser, through the renderer packages, and in scripts in the Bitbybit editors**, the same methods run in the IFC worker as `bitbybit.ifc`. Every call is asynchronous, and a model is a handle to the model the worker holds:\n\n ```typescript\n let model = await bitbybit.ifc.model.create({ name: \"House\", seed: \"house-1\" });\n model = await bitbybit.ifc.spatial.addStorey({ model, id: \"ground\", name: \"Ground floor\", elevation: 0 });\n ```\n\n`describe` shows the worker form: `add(inputs: Inputs.IFC.AddWallDto<Inputs.IFC.IfcModelPointer>): Promise<Inputs.IFC.IfcModelPointer>`. In Node read it as `add(inputs: AddWallDto<IfcModel>): IfcModel`. Enumerations are `IFC.wallAlignmentEnum.left` in Node and `Bit.Inputs.IFC.wallAlignmentEnum.left` in the editors; as plain values they are the enum's value, which is camelCase for the library's own enums (`\"left\"`, `\"gable\"`, `\"iShape\"`) and IFC's own token for IFC's (`\"STANDARD\"`, `\"USERDEFINED\"`, `\"SINGLE_SWING_LEFT\"`). `describe` lists such an enum as `one of standard = \"STANDARD\", solidWall = \"SOLIDWALL\", ...`: the key you write after the enum's name, and the value it stands for; its `default` names the key. A method's answer also names the types it returns, such as `Inputs.IFC.SpaceInfoDto` for `spaces.list`; `describe` with that name lists their fields.",
|
|
273
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/ifc-models"
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
"id": "how-the-ifc-api-thinks",
|
|
277
|
+
"title": "How the IFC API thinks",
|
|
278
|
+
"level": 2,
|
|
279
|
+
"body": "- **A model is a value.** Every method that changes a model returns a new one and leaves the one it was given as it was. Assign the result each time: `model = ifc.walls.add({ model, ... })`. A call whose result is dropped changes nothing.\n- **Your own ids.** Give elements, storeys and types an `id` such as `\"north-wall\"` and refer to them by it in later calls; the model derives each GlobalId from it. `model.globalIdOf` turns an id into its GlobalId. Ids must be unique in a model.\n- **The same file every run.** A `seed` on `model.create` and a fixed `timeStamp` on `model.write` or `model.writeBytes` make the same calls write the same bytes, so a change shows as a diff.\n- **Units.** Lengths are millimetres unless `model.create` is given another `lengthUnit` (`centimetre`, `metre`). A length left out takes its default in the model's unit: a wall is 3000 mm high in a millimetre model and 3 m high in a metre one. Angles are in degrees.\n- **Axes.** IFC is Z up. Positions on a storey are its plan, `[x, y]`, and heights go up from the storey's floor; a storey's `elevation` sets where that floor is. Beams and members take `[x, y, z]` points in the same frame. Never swap Y and Z for a Y-up viewer in the model: drawing does that (`adjustZtoY`).\n- **Outlines** are lists of `[x, y]` corners without the first repeated at the end. Either winding works for slabs, spaces and holes.\n- **Layer order.** A layer set lists its layers from a wall's right face, looking from its start to its end, so walls drawn counterclockwise around a plan list them outside first; a slab's and a roof's from the top down.",
|
|
280
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/ifc-models"
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
"id": "the-order-to-write-a-building-in",
|
|
284
|
+
"title": "The order to write a building in",
|
|
285
|
+
"level": 2,
|
|
286
|
+
"body": "Later calls refer to what earlier calls made, so this order avoids every \"not found\" error:\n\n1. **The model and its storeys**: `model.create`, then `spatial.addStorey` per floor with its `elevation`.\n2. **Materials and layer sets**: `materials.add` (a name, an optional `color` such as `\"#b5651d\"`), then `materials.addLayerSet` with `layers: [{ material: \"Brick\", thickness: 235 }, { material: \"Plaster\", thickness: 15 }]`. Walls, wall types, slabs and roofs refer to a layer set by its name; a layer set's thicknesses add up to the element's thickness.\n3. **Types**: `walls.addType`, `doors.addType` and `windows.addType`. A door or window type is placed many times through shared geometry, so define each size once.\n4. **Walls**: `walls.add` per straight wall, from `start` to `end`, with a `height` and a `layerSet` or a `thickness`. `alignment` says which side of the axis the layers lie on, looking from `start` to `end`: walls drawn counterclockwise around a plan lie inside it with `left` and outside with `right`, so with `left` the plan's corners are the building's outer faces.\n5. **Joins**: `walls.connect` for every pair of walls that meet, at a corner or where one ends against another's side. Unjoined walls overlap or leave gaps at the corners. A wall that ends against another, such as a partition against an outside wall, may end anywhere within that wall's thickness: the join cuts it back to the face.\n6. **Doors, windows and openings**: `doors.add` and `windows.add` place a type in a wall `offset` along its axis from its start, and cut their own opening; do not add an opening for them as well. `openings.add` cuts an empty opening. A window's `sill` defaults to 900 mm above the wall's base, a door's to 0. Keep an opening at least the wall's thickness away from a mitred corner: the offset runs along the axis, and the face on the other side of a corner is shorter by the thickness. A door type's `operation` names its hinges as IFC does, seen from the wall's right side, its start on your left: `singleSwingLeft` is hinged toward the wall's start, `singleSwingRight` toward its end, and the handle is on the other edge.\n7. **Slabs**: `slabs.add` with an `outline`, `thickness` or `layerSet` and `topOffset` above the storey's floor; `holes` or `openings.addInSlab` for stairwells and shafts. A floor over a storey whose walls run up to it fits between their inner faces: an outline at the outer faces puts the slab and the top of the walls in the same space.\n8. **Roofs**: `roofs.add` over a rectangle of four corners (`kind`: `flat`, `monoPitch`, `gable`, `hip`), with `baseOffset` the height of the walls under it and an `overhang`. A mono-pitch roof rises from the outline's first side and a gable's ridge runs along it. Then `walls.clipByRoof` for each wall it covers. A wall under a slope is added taller than `baseOffset`, up to the ridge at most, and clipping cuts it to the slope, a gable wall to its triangle; a wall added exactly at `baseOffset` is left square, with a wedge open under the slope.\n9. **Structure and detail**: `columns.add`, `beams.add` and `members.add` with a `profile` (`rectangle`, `circle`, `iShape`); `assemblies.add` to group parts such as a facade's cladding boards.\n10. **Rooms**: `spaces.add` per room, with its `name` (the room number), `longName` and `height`.\n11. **Data**: `properties.addSet`, such as `Pset_WallCommon` with `IsExternal: true` shared by every outside wall. A property's value is written as a label, boolean, integer or real as it is, or as the `type` it names: any of IFC4's `IfcValue` types, such as `IfcText`, `IfcLengthMeasure` or `IfcThermalTransmittanceMeasure` for a U-value.\n12. **Quantities last**: `quantities.compute` measures every element as it is now; compute again after any later change.\n13. **Write**: `model.writeBytes` (any size) or `model.write` (the text).",
|
|
287
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/ifc-models"
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
"id": "a-house-to-start-from",
|
|
291
|
+
"title": "A house to start from",
|
|
292
|
+
"level": 2,
|
|
293
|
+
"body": "[A family house in IFC](/learn/code/common/ifc/family-house) shows where this order leads: a whole two-storey house written with the same calls, which opens in the TypeScript editor.\n\n<Shot id=\"code.ifc.family-house/morning\" />\n\nA two-storey house in Node, with the package alone. It follows the order above and writes a file other BIM tools open:\n\n```typescript\nimport { writeFileSync } from \"node:fs\";\nimport { Base, IFC, IFCService } from \"@bitbybit-dev/ifc\";\n\nconst FOOTPRINT: Base.Point2[] = [[0, 0], [10000, 0], [10000, 8000], [0, 8000]];\nconst INSIDE: Base.Point2[] = [[250, 250], [9750, 250], [9750, 7750], [250, 7750]];\nconst STOREY_HEIGHT = 3000;\nconst STOREYS = [\"ground\", \"first\"];\n\nconst ifc = new IFCService();\nlet model = ifc.model.create({ name: \"House\", seed: \"house-1\" });\nmodel = ifc.spatial.addStorey({ model, id: \"ground\", name: \"Ground floor\", elevation: 0 });\nmodel = ifc.spatial.addStorey({ model, id: \"first\", name: \"First floor\", elevation: STOREY_HEIGHT });\n\nmodel = ifc.materials.add({ model, name: \"Brick\", category: \"brick\", color: \"#b5651d\" });\nmodel = ifc.materials.add({ model, name: \"Plaster\", category: \"plaster\", color: \"#f2efe6\" });\nmodel = ifc.materials.add({ model, name: \"Concrete\", category: \"concrete\", color: \"#9a9a9a\" });\nmodel = ifc.materials.add({ model, name: \"Tiles\", category: \"tile\", color: \"#7a2e1d\" });\nmodel = ifc.materials.addLayerSet({ model, name: \"Exterior wall\", layers: [{ material: \"Brick\", thickness: 235 }, { material: \"Plaster\", thickness: 15 }] });\nmodel = ifc.materials.addLayerSet({ model, name: \"Floor\", layers: [{ material: \"Concrete\", thickness: 200 }] });\nmodel = ifc.materials.addLayerSet({ model, name: \"Roof\", layers: [{ material: \"Tiles\", thickness: 220 }] });\nmodel = ifc.doors.addType({ model, id: \"door\", name: \"Door 900\", width: 900, height: 2100 });\nmodel = ifc.windows.addType({ model, id: \"window\", name: \"Window 1200\", width: 1200, height: 1400 });\n\nfor (const storey of STOREYS) {\n for (let i = 0; i < FOOTPRINT.length; i++) {\n const underRoof = i % 2 === 1 ? 6500 : 3400;\n model = ifc.walls.add({\n model, storey, id: `${storey}-wall-${i}`, start: FOOTPRINT[i], end: FOOTPRINT[(i + 1) % FOOTPRINT.length],\n height: storey === \"first\" ? underRoof : STOREY_HEIGHT, layerSet: \"Exterior wall\", alignment: IFC.wallAlignmentEnum.left,\n });\n }\n for (let i = 0; i < FOOTPRINT.length; i++) {\n model = ifc.walls.connect({ model, wall: `${storey}-wall-${i}`, other: `${storey}-wall-${(i + 1) % FOOTPRINT.length}` });\n }\n model = ifc.slabs.add({ model, storey, id: `${storey}-floor`, outline: storey === \"ground\" ? FOOTPRINT : INSIDE, layerSet: \"Floor\" });\n model = ifc.windows.add({ model, wall: `${storey}-wall-2`, windowType: \"window\", offset: 3000 });\n model = ifc.properties.addSet({\n model, elements: FOOTPRINT.map((_, i) => `${storey}-wall-${i}`), name: \"Pset_WallCommon\",\n properties: [{ name: \"IsExternal\", value: true }, { name: \"LoadBearing\", value: true }],\n });\n}\nmodel = ifc.doors.add({ model, wall: \"ground-wall-0\", doorType: \"door\", id: \"front-door\", offset: 4500 });\nmodel = ifc.openings.addInSlab({ model, slab: \"first-floor\", id: \"stairwell\", outline: [[7000, 5000], [9750, 5000], [9750, 6200], [7000, 6200]] });\nmodel = ifc.roofs.add({ model, storey: \"first\", id: \"roof\", outline: FOOTPRINT, kind: IFC.roofKindEnum.gable, pitch: 35, baseOffset: STOREY_HEIGHT, overhang: 400, layerSet: \"Roof\" });\nfor (let i = 0; i < FOOTPRINT.length; i++) {\n model = ifc.walls.clipByRoof({ model, wall: `first-wall-${i}`, roof: \"roof\" });\n}\nmodel = ifc.spaces.add({ model, storey: \"ground\", id: \"living\", name: \"0.01\", longName: \"Living room\", outline: [[250, 250], [9750, 250], [9750, 7750], [250, 7750]], height: 2700 });\nmodel = ifc.quantities.compute({ model });\n\nwriteFileSync(\"house.ifc\", ifc.model.writeBytes({ model, fileName: \"house.ifc\", timeStamp: \"2026-01-01T12:00:00\" }));\n```\n\nThe walls run counterclockwise with `left` alignment, so they stand inside the footprint and their layers are listed outside first: brick, then plaster. The ground floor's slab lies under the walls and the first floor's between their inner faces (`INSIDE`), so no slab cuts into a wall. The gable's ridge runs along the outline's first side, so the short walls (`wall-1` and `wall-3`) are the gables: they are added 6.5 m high and clipped to the roof's triangle, and the long walls are added 3.4 m high and clipped to the slope, so the roof meets every wall without a gap. Each storey's windows, door and stairwell refer to walls and slabs by the ids they were given.",
|
|
294
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/ifc-models"
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
"id": "checking-an-ifc-model",
|
|
298
|
+
"title": "Checking an IFC model",
|
|
299
|
+
"level": 2,
|
|
300
|
+
"body": "Read the model back before handing it over; every check here is cheap:\n\n- `model.summary` gives the schema, whether the model can be changed, its length unit as `millimetresPerUnit`, the storeys and how many elements of each type there are (`elementCounts`). Compare the counts with what the prompt asked for: rooms are not among them (count them with `spaces.list`), and a sloping roof's planes are `IfcSlab` parts of its `IfcRoof`, so they count as slabs too.\n- `geometry.unsupported` lists every element whose geometry cannot be described, with the reason. It should be empty for a model made with these methods.\n- `walls.parameters` reads one wall back: its axis, height, thickness and layers, the walls it is joined to, its openings and its clippings. A corner missing from `joins` is a `walls.connect` that was forgotten; a join names the other wall by its GlobalId, which `model.globalIdOf` gives for an id of your own.\n- `spaces.list` gives every room with its area, in the model's length unit squared (square millimetres in a millimetre model). `quantities.get` gives an element's measured quantities after `quantities.compute`, as IFC's base quantities are written: lengths in the model's unit, areas in square metres and volumes in cubic metres.\n- A method refuses what it cannot do and says why, before anything changes: an opening wider than its wall, a door type that was never added, a wall id used twice. Read the message, fix the call and run the script again.\n- Where Python with IfcOpenShell is available, its validator checks the file against the IFC4 schema and its rules: `python -m ifcopenshell.validate --rules house.ifc`. A file made with these methods passes it.",
|
|
301
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/ifc-models"
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
"id": "reading-and-changing-ifc-files",
|
|
305
|
+
"title": "Reading and changing IFC files",
|
|
306
|
+
"level": 2,
|
|
307
|
+
"body": "- `model.read` takes the text or the bytes of an `.ifc` file, such as `readFileSync(\"in.ifc\")` or `await file.arrayBuffer()`. It indexes the file without decoding it, so files of hundreds of megabytes open in seconds.\n- `model.elements` lists objects by IFC type, its subtypes included (`IfcWall`, `IfcBuildingElement`, or `IfcElement` for every element), optionally of one storey; `model.element` describes one; `model.getAttribute` and `model.setAttribute` read and set one attribute such as `Name` or `Tag`.\n- `properties.getSets` reads an object's property sets; `properties.setValues` changes one object's values, copying a set it shares with others first, so the others keep theirs.\n- `walls.parameters` and `walls.edit` read and change walls other tools wrote with an axis and layers; joined walls are trimmed again and the wall's openings move with it. `model.move` moves and turns any element, and `model.remove` takes it away with what only it uses.\n- **IFC2X3 files** are read, queried and written back, but not changed: `model.upgradeToIfc4` gives a model that can be.\n- `model.writeBytes` writes untouched entities back byte for byte, so a small change to a large file stays small. Prefer it to `model.write` for files read from elsewhere: a JavaScript string holds about 512 MB.",
|
|
308
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/ifc-models"
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
"id": "drawing-an-ifc-model-and-exporting-step",
|
|
312
|
+
"title": "Drawing an IFC model and exporting STEP",
|
|
313
|
+
"level": 2,
|
|
314
|
+
"body": "In the browser, a model's recipe is built by a kernel and drawn:\n\n```typescript\nconst recipe = await bitbybit.ifc.geometry.recipe({ model });\nconst solids = await bitbybit.manifold.recipes.build({ recipe, adjustZtoY: true });\nawait bitbybit.draw.drawAnyAsync({ entity: solids });\n```\n\nThe solids come back one per root of the recipe, and `recipe.roots[i].tag` carries the element's `globalId`, `type`, `name` and, when its material has a colour, `rgba`. With the OpenCascade worker enabled as well, `ifc.geometry.toShapes` gives exact shapes and `ifc.geometry.toStep` the bytes of a STEP file, nested by site, building, storey and IFC class: `await bitbybit.ifc.geometry.toStep({ model, name: \"House\", fileName: \"house.step\" })`. A Babylon.js scene is left-handed unless told otherwise; set `scene.useRightHandedSystem = true` before drawing, or the building is mirrored.",
|
|
315
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/ifc-models"
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
"id": "mistakes-to-avoid-in-ifc-models",
|
|
319
|
+
"title": "Mistakes to avoid in IFC models",
|
|
320
|
+
"level": 2,
|
|
321
|
+
"body": "- **Dropping the returned model.** `ifc.walls.add({ model, ... })` without `model =` changes nothing; the next call starts from the model before it.\n- **Mixing the two call forms.** In Node the package's methods are synchronous; `bitbybit.ifc` in the browser and in the editors is asynchronous and needs `await` on every call.\n- **Guessed units.** A wall `height: 3` in a millimetre model is 3 mm high. Give lengths in the model's unit, millimetres unless the model says otherwise.\n- **Y as up.** Plans are `[x, y]` and up is Z. A point written as `[x, height, y]` puts the building on its side.\n- **Unjoined walls.** Every corner and T junction needs `walls.connect`. Without it the walls overlap or leave a gap there, and other BIM tools show them as walls that do not meet.\n- **An opening for a door or window.** `doors.add` and `windows.add` cut their own; an extra `openings.add` in the same place is a second hole.\n- **Openings that do not fit.** An opening past the end of its wall is refused, but two that overlap, or one whose `sill` plus height rises above the wall, are not: keep the openings of a wall apart and under its top.\n- **The roof before its walls are clipped, or a roof that is not a rectangle.** `roofs.add` takes four corners, and walls are clipped with `walls.clipByRoof` after the roof exists.\n- **Quantities computed too early.** They are a snapshot; compute them once the model is finished, or again after a change.\n- **An assembly of a user-defined kind without words.** `assemblies.add` with `predefinedType` `userDefined` needs an `objectType` that says what it is, such as `\"Cladding\"`.\n- **Changing an IFC2X3 model.** It refuses every change until `model.upgradeToIfc4`.\n- **Fields that do not exist.** Look each method up with `describe`; its inputs, defaults and ranges come from the index, not from memory.",
|
|
322
|
+
"page": "https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/ifc-models"
|
|
91
323
|
}
|
|
92
324
|
];
|
|
93
325
|
//# sourceMappingURL=guides.generated.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guides.generated.js","sourceRoot":"","sources":["../src/guides.generated.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"guides.generated.js","sourceRoot":"","sources":["../src/guides.generated.ts"],"names":[],"mappings":"AAEA,oFAAoF;AACpF,MAAM,CAAC,MAAM,cAAc,GAAG,qEAAqE,CAAC;AAEpG;;;;GAIG;AACH,MAAM,CAAC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C;QAClD,OAAO,EAAE,CAAC;QACV,MAAM,EAAE,q3BAAq3B;QAC73B,MAAM,EAAE,oEAAoE;KAC/E;IACD;QACI,IAAI,EAAE,iCAAiC;QACvC,OAAO,EAAE,iCAAiC;QAC1C,OAAO,EAAE,CAAC;QACV,MAAM,EAAE,i0DAAi0D;QACz0D,MAAM,EAAE,oEAAoE;KAC/E;CACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-loader.d.ts","sourceRoot":"","sources":["../src/index-loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAKjD,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACzG,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAI9C,wBAAgB,eAAe,CAAC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GAAG,MAAM,CAG7F;AAED,MAAM,WAAW,gBAAgB;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,wBAAsB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"index-loader.d.ts","sourceRoot":"","sources":["../src/index-loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAKjD,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACzG,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAI9C,wBAAgB,eAAe,CAAC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GAAG,MAAM,CAG7F;AAED,MAAM,WAAW,gBAAgB;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,wBAAsB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC,CA2B5E"}
|
package/dist/index-loader.js
CHANGED
|
@@ -16,21 +16,26 @@ export async function loadIndex(options) {
|
|
|
16
16
|
const cacheFile = cacheDir === null ? null : join(cacheDir, `index-v${options.version}.json`);
|
|
17
17
|
if (cacheFile !== null) {
|
|
18
18
|
const cached = await readCached(cacheFile, options.version);
|
|
19
|
-
if (cached)
|
|
19
|
+
if (cached) {
|
|
20
20
|
return cached;
|
|
21
|
+
}
|
|
21
22
|
}
|
|
22
23
|
const doFetch = options.fetch ?? fetch;
|
|
23
24
|
const response = await doFetch(url);
|
|
24
|
-
if (response.status === NOT_FOUND)
|
|
25
|
+
if (response.status === NOT_FOUND) {
|
|
25
26
|
throw new IndexNotPublishedError(options.version, url);
|
|
26
|
-
|
|
27
|
+
}
|
|
28
|
+
if (!response.ok) {
|
|
27
29
|
throw new Error(`Fetching ${url} failed with HTTP ${response.status}`);
|
|
30
|
+
}
|
|
28
31
|
const text = await response.text();
|
|
29
32
|
const parsed = JSON.parse(text);
|
|
30
|
-
if (!isApiIndex(parsed, options.version))
|
|
33
|
+
if (!isApiIndex(parsed, options.version)) {
|
|
31
34
|
throw new Error(`${url} is not an API index for version ${options.version}`);
|
|
32
|
-
|
|
35
|
+
}
|
|
36
|
+
if (cacheFile !== null && cacheDir !== null) {
|
|
33
37
|
await writeCached(cacheDir, cacheFile, text);
|
|
38
|
+
}
|
|
34
39
|
return parsed;
|
|
35
40
|
}
|
|
36
41
|
async function readCached(file, version) {
|
package/dist/index-loader.js.map
CHANGED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Y,EAAE,OAAe;IACnD,IAAI,CAAC;QACD,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;QACjE,OAAO,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5D,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,SAAS,CAAC;IACrB,CAAC;AACL,CAAC;AAED,MAAM,uBAAuB,GAAG,GAAc,EAAE,CAAC,SAAS,CAAC;AAE3D,KAAK,UAAU,WAAW,CAAC,GAAW,EAAE,IAAY,EAAE,IAAY;IAC9D,MAAM,OAAO,GAAG,GAAG,IAAI,IAAI,OAAO,CAAC,GAAG,UAAU,CAAC;IACjD,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;SAChC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;SAC5C,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;SACjC,KAAK,CAAC,uBAAuB,CAAC,CAAC;AACxC,CAAC"}
|
package/dist/index-reader.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import type { ApiIndex, Engine, IndexExample, IndexMember } from "./index-types.js";
|
|
1
|
+
import type { ApiIndex, Engine, IndexExample, IndexMember, IndexType } from "./index-types.js";
|
|
2
2
|
export interface SearchHit {
|
|
3
3
|
member: IndexMember;
|
|
4
4
|
score: number;
|
|
5
5
|
}
|
|
6
|
+
export interface NamedType {
|
|
7
|
+
key: string;
|
|
8
|
+
type: IndexType;
|
|
9
|
+
}
|
|
6
10
|
export interface SearchOptions {
|
|
7
11
|
engine?: Engine | undefined;
|
|
8
12
|
limit?: number | undefined;
|
|
@@ -13,8 +17,14 @@ export declare class IndexReader {
|
|
|
13
17
|
readonly version: string;
|
|
14
18
|
private readonly byPath;
|
|
15
19
|
private readonly tokens;
|
|
20
|
+
private readonly typeKeysByName;
|
|
16
21
|
constructor(index: ApiIndex);
|
|
17
22
|
get(path: string): IndexMember | undefined;
|
|
23
|
+
type(name: string, near?: string): NamedType | undefined;
|
|
24
|
+
typeKeysNamed(name: string): string[];
|
|
25
|
+
typesIn(texts: readonly (string | null | undefined)[], near?: string): NamedType[];
|
|
26
|
+
typesUsedBy(member: IndexMember): NamedType[];
|
|
27
|
+
typesUsedByType(named: NamedType): NamedType[];
|
|
18
28
|
all(): IndexMember[];
|
|
19
29
|
children(path?: string): IndexMember[];
|
|
20
30
|
search(query: string, options?: SearchOptions): SearchHit[];
|