commandagi 0.6.2__tar.gz → 0.6.3__tar.gz
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.
- {commandagi-0.6.2 → commandagi-0.6.3}/CHANGELOG.md +67 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/PKG-INFO +3 -2
- {commandagi-0.6.2 → commandagi-0.6.3}/README.md +2 -1
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/__init__.py +1 -1
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/client.py +5 -2
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/__init__.py +1 -1
- commandagi-0.6.3/commandagi/design/flows.py +144 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/part_fields.py +11 -5
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/pcb.py +15 -4
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/standards.py +7 -2
- commandagi-0.6.3/commandagi/design/standards_data.py +14 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/study.py +2 -2
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/systems.py +17 -4
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/threed.py +156 -141
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/threed_elements.py +27 -15
- commandagi-0.6.3/commandagi/design/threed_schema.py +4 -0
- commandagi-0.6.3/commandagi/design/tolerances.py +206 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/kernel.py +5 -1
- commandagi-0.6.3/tests/test_flows.py +51 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/tests/test_kernel.py +22 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/tests/test_logistics.py +3 -3
- {commandagi-0.6.2 → commandagi-0.6.3}/tests/test_pcb.py +12 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/tests/test_standards.py +7 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/tests/test_study.py +5 -1
- {commandagi-0.6.2 → commandagi-0.6.3}/tests/test_systems.py +5 -1
- {commandagi-0.6.2 → commandagi-0.6.3}/tests/test_threed.py +13 -2
- {commandagi-0.6.2 → commandagi-0.6.3}/tests/test_tolerances.py +8 -2
- commandagi-0.6.2/commandagi/design/standards_data.py +0 -14
- commandagi-0.6.2/commandagi/design/threed_schema.py +0 -4
- commandagi-0.6.2/commandagi/design/tolerances.py +0 -119
- {commandagi-0.6.2 → commandagi-0.6.3}/.gitignore +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/LICENSE +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/_generated.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/agents.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/business.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/cad.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/cadquery.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/circuit_checks.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/documents.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/eda.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/element.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/fab.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/firmware.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/graph.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/ir.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/media.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/monitors.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/office.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/ontology.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/pdf.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/postal.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/records.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/schema.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/schematic.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/solids.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/source.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/tasks.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/testplans.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/tsx.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/twod.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/twod_schema.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/design/workbook_schema.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/gym_env.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi/lerobot.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/commandagi-sdk.schema.json +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/examples/drive_a_sim.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/pyproject.toml +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/tests/test_agents.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/tests/test_business.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/tests/test_design.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/tests/test_fab.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/tests/test_media.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/tests/test_monitors.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/tests/test_office.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/tests/test_ontology.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/tests/test_pdf.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/tests/test_postal.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/tests/test_records.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/tests/test_schematic.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/tests/test_sdk.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/tests/test_source.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/tests/test_tasks.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/tests/test_testplans.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/tests/test_tsx.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/tests/test_twod.py +0 -0
- {commandagi-0.6.2 → commandagi-0.6.3}/uv.lock +0 -0
|
@@ -4,6 +4,73 @@ One entry for each release. A release is the tag `v<version>` in this repository
|
|
|
4
4
|
TypeScript and Rust SDKs carry the same version number. A version promises nothing about the next one (README
|
|
5
5
|
§ Versions): read this file before you change the version you pin.
|
|
6
6
|
|
|
7
|
+
## 0.6.3 (2026-10-21)
|
|
8
|
+
|
|
9
|
+
The fixes for the microfab team's report on 0.6.2 (110 issues; the ids in brackets are theirs). The vocabulary below
|
|
10
|
+
is the same in the three SDKs, in each language's spelling; `@commandagi/host` 0.6.3 carries the checks.
|
|
11
|
+
|
|
12
|
+
Changed (a document written for 0.6.2 may need an edit)
|
|
13
|
+
|
|
14
|
+
- One face query for 3D documents, checks and studies: a study's `type` is `geometry`, `nearest` is `farthest` with
|
|
15
|
+
the direction reversed, `radius` and `area` take `{ min, max }`; `at` names the face that holds a point (CORE-24,
|
|
16
|
+
PCBC-12, IC2-08).
|
|
17
|
+
- A finding names a body by the id the document gives it (`<body id>`, else the feature that made it); the rebuild's
|
|
18
|
+
`body_0` is `rebuildId` (CORE-13). A covered finding's `severity` is `suppressed`, its own in `coveredSeverity`
|
|
19
|
+
(PCBC-03).
|
|
20
|
+
- `commandagi check` prints a compact report (verdict, each check, findings grouped by rule); `--json` or `--out FILE`
|
|
21
|
+
gives the whole report (IC2-12, PCBC-04).
|
|
22
|
+
- A `bodies` entry that names no body is an `unknown-body` error: a check of nothing never passes (LABS-02).
|
|
23
|
+
- Copper joins where it is drawn, and a pour joins the pads and vias of its net it covers; `from`/`to` are optional
|
|
24
|
+
(EDA-03, EDA-06). A part on the bottom flips its pads, paste, mask, silk and courtyard as KiCad does (EDA-04). An
|
|
25
|
+
unrouted net on a board with copper is an error (EDA-05).
|
|
26
|
+
- An unknown material is a warning of the process check (CORE-11).
|
|
27
|
+
|
|
28
|
+
Added
|
|
29
|
+
|
|
30
|
+
- Placed parts carry what their file states: engineering, mass, part number, fasteners; a placed assembly keeps its
|
|
31
|
+
members as `<placement>/<id>`. Check, `threed bom`, `threed observe`, STEP and `diff` agree (CORE-01 to -04, -09,
|
|
32
|
+
-20, -26, -27). Bill lines and logistics findings are one per part number with a quantity (LABS-16, IC1-11).
|
|
33
|
+
- A `.3d.tsx` imports sibling `.ts`, `.tsx` and `.json` files; a `.3d.py` reads its folder and imports sibling modules
|
|
34
|
+
(CORE-05, CORE-06). Syntax errors name the author's line and column (IC1-01); every refused element in one run
|
|
35
|
+
(IC1-02).
|
|
36
|
+
- `commandagi --version` with no key; `check --only ID`, `--timeout S` and a timeout that says so; `release --dry-run`
|
|
37
|
+
and `.releaseignore`; a release also holds the folder's requirements, systems and interfaces (SETUP-01, IC1-09,
|
|
38
|
+
LABS-19, LABS-20, CORE-28). `commandagi layout | route | fabricate <board>` run on this computer (EDA-17).
|
|
39
|
+
- Faces: a hole on a face split in two, a pick by a point on the face, a pick among the bodies a feature consumes, an
|
|
40
|
+
ambiguous pick that names its faces (CORE-08, IC2-02, IC2-03, LABS-05). A counterbore deeper than its size's
|
|
41
|
+
(CORE-10); `m2.5` threads (IC2-04); a clearance pair the kernel cannot measure is its own finding (CORE-19).
|
|
42
|
+
- Every ISO 286 class (IT01 to IT18, A to ZC) to 3150 mm, and ISO 2768-1 (IC2-05, CORE-17, IC1-06); a fit between two
|
|
43
|
+
sizes of different nominals (CORE-16); a fit's `pair` covers its press fit's clash (CORE-18); `against` on
|
|
44
|
+
interference and clearance (CORE-25, LABS-03); `<accept other>` for a part modelled inside another, an accept sized
|
|
45
|
+
to its finding (PCBC-09, IC1-10); `<hole spare>` and `<permitted diameter>` (IC1-04).
|
|
46
|
+
- The mill check judges each face from the setup that reaches it (`make.setups`, or the fewest sides), drilled holes as
|
|
47
|
+
drilled, a plate turned on the table, the machine's materials (CORE-07, -12, -14, -15, -21, -34). The resin printer
|
|
48
|
+
prints: SLA printability (drain, cups) and slicing (CORE-32); `commandagi slicer slice X.slice.tsx` (CORE-33).
|
|
49
|
+
- Drawing sheets: hole callouts from the hole features (depth, blind, FAR SIDE), a hole table from a datum corner, no
|
|
50
|
+
overlapping callouts, the release's REV (CORE-22, -31, -36, PCBC-10).
|
|
51
|
+
- Studies: inverted elements straightened, each level's reason on its line, `<solver timeout>`, `--keep finest`, a
|
|
52
|
+
fixture on a region (CORE-37, IC2-10, PCBC-11, IC1-15).
|
|
53
|
+
- Budgets of any quantity and unit (flow, area, volume …), a priced `<item ref>` to a design with its lead-time path,
|
|
54
|
+
a diff that names every logistics change, process flows (`.flow.tsx`), cost ranges, µm and nm, `other` processes,
|
|
55
|
+
`<library>` data for fastener pieces, `<fastener material partNumber>`, a `chemicals` check (LABS-06 to -12, IC1-03,
|
|
56
|
+
IC1-05, IC1-12, IC2-11, PCBC-13). HFS5-2060 and HFS5-2080 in the T-slot table (CORE-35).
|
|
57
|
+
- Boards: pinless parts (EDA-02), four-layer net-class rules (EDA-07), KiCad parity on no-connect pins, datasheets and
|
|
58
|
+
back-side text (EDA-08 to -10), interface sides that read a sheet, a board or a `.sch.py` (EDA-14), a fabrication
|
|
59
|
+
BOM by part number (EDA-19), `near` as a hard rule of the placer (EDA-20).
|
|
60
|
+
- Speed: a 1136-hole plate checks in about 5 s (was 4 min 54 s); a 206-body assembly in 45 s (was 4 min 41 s)
|
|
61
|
+
(LABS-04, IC2-06).
|
|
62
|
+
|
|
63
|
+
In this SDK
|
|
64
|
+
|
|
65
|
+
- `netclass(...)` states the rules a four-layer board needs: `min_width` (the narrowest track; `width` is what the
|
|
66
|
+
router lays), `edge_clearance` and `hole_clearance` (the least gaps to the board edge and to a hole),
|
|
67
|
+
`inner={"clearance": …, "width": …, "minWidth": …}` (the rules on inner copper layers) and `min_spokes` (the fewest
|
|
68
|
+
thermal spokes a pad needs to a pour). `commandagi check` holds the board to them and `commandagi export kicad`
|
|
69
|
+
writes them into the project and its `.kicad_dru` (microfab EDA-07).
|
|
70
|
+
- Every request (the client, a session's frames and its WebSocket, the 3D kernel's cloud and local calls) sends
|
|
71
|
+
`User-Agent: commandagi-python/<version>`. The platform's CDN refused the kernel's standard-library requests with
|
|
72
|
+
`error code: 1010` (microfab CORE-30).
|
|
73
|
+
|
|
7
74
|
## 0.6.2 (2026-10-16)
|
|
8
75
|
|
|
9
76
|
No change in this SDK's code. The release carries `@commandagi/host` 0.6.2, which `commandagi check` and the local 3D
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: commandagi
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.3
|
|
4
4
|
Summary: The CommandAGI SDK for Python — agent threads, memory and integrations, and live computers, robots and simulated worlds you watch and control.
|
|
5
5
|
Project-URL: Homepage, https://commandagi.com
|
|
6
6
|
Project-URL: Documentation, https://github.com/CommandAGI/commandagi-sdk-python/blob/main/README.md
|
|
@@ -33,6 +33,7 @@ Drive the whole CommandAGI platform as code: agent threads, memory and integrati
|
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
35
|
pip install commandagi
|
|
36
|
+
# or, in an environment uv manages: uv pip install commandagi (in a uv project: uv add commandagi)
|
|
36
37
|
export COMMANDAGI_API_KEY=cagi_... # Settings → API keys
|
|
37
38
|
```
|
|
38
39
|
|
|
@@ -279,7 +280,7 @@ graph (`run_module(...)["graph"]`) or the graph's JSON text. An entity is `{"bod
|
|
|
279
280
|
## Versions
|
|
280
281
|
|
|
281
282
|
- A release is the tag `v<version>` in this repository and the same version on PyPI. Pin an exact version:
|
|
282
|
-
`commandagi==0.6.
|
|
283
|
+
`commandagi==0.6.3`. A range (`^`, `~=`, `>=`) takes the next release without asking you.
|
|
283
284
|
- The three SDKs (Python, TypeScript, Rust) carry one version number. A vocabulary at version X in one language is
|
|
284
285
|
the vocabulary at version X in the others.
|
|
285
286
|
- A version promises nothing about the next one. CommandAGI keeps no compatibility layers: a release may rename or
|
|
@@ -5,6 +5,7 @@ Drive the whole CommandAGI platform as code: agent threads, memory and integrati
|
|
|
5
5
|
|
|
6
6
|
```bash
|
|
7
7
|
pip install commandagi
|
|
8
|
+
# or, in an environment uv manages: uv pip install commandagi (in a uv project: uv add commandagi)
|
|
8
9
|
export COMMANDAGI_API_KEY=cagi_... # Settings → API keys
|
|
9
10
|
```
|
|
10
11
|
|
|
@@ -251,7 +252,7 @@ graph (`run_module(...)["graph"]`) or the graph's JSON text. An entity is `{"bod
|
|
|
251
252
|
## Versions
|
|
252
253
|
|
|
253
254
|
- A release is the tag `v<version>` in this repository and the same version on PyPI. Pin an exact version:
|
|
254
|
-
`commandagi==0.6.
|
|
255
|
+
`commandagi==0.6.3`. A range (`^`, `~=`, `>=`) takes the next release without asking you.
|
|
255
256
|
- The three SDKs (Python, TypeScript, Rust) carry one version number. A vocabulary at version X in one language is
|
|
256
257
|
the vocabulary at version X in the others.
|
|
257
258
|
- A version promises nothing about the next one. CommandAGI keeps no compatibility layers: a release may rename or
|
|
@@ -28,6 +28,8 @@ from typing import Any, Dict, Iterator, List, Optional
|
|
|
28
28
|
import requests
|
|
29
29
|
import websocket # from the `websocket-client` package
|
|
30
30
|
|
|
31
|
+
from .kernel import USER_AGENT
|
|
32
|
+
|
|
31
33
|
from ._generated import (
|
|
32
34
|
DEFAULT_BASE_URL,
|
|
33
35
|
ENV_API_KEY,
|
|
@@ -90,6 +92,7 @@ class CommandAGI(GeneratedClient):
|
|
|
90
92
|
"authorization": f"Bearer {self.api_key}",
|
|
91
93
|
"content-type": "application/json",
|
|
92
94
|
"mcp-protocol-version": "2025-06-18",
|
|
95
|
+
"user-agent": USER_AGENT,
|
|
93
96
|
},
|
|
94
97
|
data=json.dumps({
|
|
95
98
|
"jsonrpc": "2.0",
|
|
@@ -222,7 +225,7 @@ class Session:
|
|
|
222
225
|
}
|
|
223
226
|
self._lock.notify_all()
|
|
224
227
|
|
|
225
|
-
self._ws = websocket.WebSocketApp(url, on_message=on_message)
|
|
228
|
+
self._ws = websocket.WebSocketApp(url, header={"user-agent": USER_AGENT}, on_message=on_message)
|
|
226
229
|
threading.Thread(
|
|
227
230
|
target=lambda: self._ws.run_forever(ping_interval=20, ping_timeout=10, reconnect=3),
|
|
228
231
|
daemon=True,
|
|
@@ -247,7 +250,7 @@ class Session:
|
|
|
247
250
|
url = self.frame(fresh=fresh, timeout=timeout)["url"]
|
|
248
251
|
if url.startswith("data:"):
|
|
249
252
|
return base64.b64decode(url.split(",", 1)[1])
|
|
250
|
-
r = self._client._http.get(url, headers={"authorization": f"Bearer {self._client.api_key}"}, timeout=60)
|
|
253
|
+
r = self._client._http.get(url, headers={"authorization": f"Bearer {self._client.api_key}", "user-agent": USER_AGENT}, timeout=60)
|
|
251
254
|
r.raise_for_status()
|
|
252
255
|
return r.content
|
|
253
256
|
|
|
@@ -32,7 +32,7 @@ from .element import Element, declarer_of
|
|
|
32
32
|
from .tsx import to_tsx
|
|
33
33
|
# The document vocabularies, one module each (``from commandagi.design.twod import drawing, rect``). Importing them
|
|
34
34
|
# registers what each root element declares.
|
|
35
|
-
from . import agents, business, fab, firmware, media, monitors, office, ontology, pcb, pdf, postal, records, schematic, standards, study, systems, tasks, testplans, threed, tolerances, twod # noqa: F401
|
|
35
|
+
from . import agents, business, fab, firmware, media, monitors, office, ontology, pcb, pdf, postal, records, schematic, standards, study, systems, flows, tasks, testplans, threed, tolerances, twod # noqa: F401
|
|
36
36
|
|
|
37
37
|
__all__ = [
|
|
38
38
|
"Declaration", "NodeRef", "Out", "Scope", "channels", "check_ir", "is_ir_graph",
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"""A process flow, declared in Python (``<name>.flow.py``): the ordered steps that make one thing, each with the tool it
|
|
2
|
+
visits, its recipe parameters with their units, its time and who does it, and the measurements taken in the process,
|
|
3
|
+
the same document and the same elements as the TypeScript SDK's JSX (``commandagi/design`` ``flows.ts``)::
|
|
4
|
+
|
|
5
|
+
from commandagi.design.flows import flow, tool, step, param, measure
|
|
6
|
+
|
|
7
|
+
result = flow(
|
|
8
|
+
tool(id="coater", ref="stage1.bom.3d.py#coater", rate_per_hour=40, currency="USD"),
|
|
9
|
+
step(id="why", kind="note", instruction="Marks first: every later layer aligns to them."),
|
|
10
|
+
step(
|
|
11
|
+
param(name="speed", value=3000, unit="rpm"),
|
|
12
|
+
measure(id="resist", name="resist thickness", nominal=1.2, plus=0.1, minus=0.1, unit="um"),
|
|
13
|
+
id="coat", order=1, tool="coater", by="in-house", minutes=6,
|
|
14
|
+
),
|
|
15
|
+
name="Alignment marks", of="stage1.bom.3d.py#wafer",
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
A record is an element and its fields are the element's attributes (snake_case keywords: ``rate_per_hour`` is
|
|
19
|
+
``ratePerHour``). Nothing adds a default. The check is the host's (``commandagi check <file>.flow.py``).
|
|
20
|
+
"""
|
|
21
|
+
from __future__ import annotations
|
|
22
|
+
|
|
23
|
+
import json
|
|
24
|
+
import math
|
|
25
|
+
import re
|
|
26
|
+
from typing import Any, Dict
|
|
27
|
+
|
|
28
|
+
from .documents import DocTree, Vocabulary, register_vocabulary
|
|
29
|
+
from .element import define
|
|
30
|
+
|
|
31
|
+
FLOW_STEP_KINDS = ["work", "note"]
|
|
32
|
+
FLOW_FIELDS = ["name", "description", "of"]
|
|
33
|
+
FLOW_TOOL_FIELDS = ["id", "ref", "name", "ratePerHour", "currency", "description"]
|
|
34
|
+
FLOW_STEP_FIELDS = ["id", "order", "kind", "tool", "fixture", "by", "minutes", "setupMinutes", "ratePerHour", "currency", "instruction",
|
|
35
|
+
"note"]
|
|
36
|
+
FLOW_PARAM_FIELDS = ["name", "value", "unit", "description"]
|
|
37
|
+
FLOW_MEASURE_FIELDS = ["id", "name", "nominal", "min", "max", "plus", "minus", "unit", "method", "sampling", "acceptance"]
|
|
38
|
+
|
|
39
|
+
_CHILDREN = {"holds": "children"}
|
|
40
|
+
#: Every tag and what it holds (the TypeScript SDK's ``SIGNATURES``).
|
|
41
|
+
SIGNATURES: Dict[str, Dict[str, Any]] = {"flow": _CHILDREN, "tool": {}, "step": _CHILDREN, "param": {}, "measure": {}}
|
|
42
|
+
|
|
43
|
+
__all__ = ["FLOW_STEP_KINDS", "SIGNATURES", "FLOW_VOCABULARY", *define(globals(), "flows", SIGNATURES)]
|
|
44
|
+
|
|
45
|
+
_ID = re.compile(r"[A-Za-z0-9][A-Za-z0-9._-]*")
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _where(tag: str, key: str, a: Dict[str, Any]) -> str:
|
|
49
|
+
return f"<{tag} {key}={json.dumps(a[key], ensure_ascii=False)}>" if key in a else f"<{tag}>"
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _num(v: Any) -> bool:
|
|
53
|
+
return isinstance(v, (int, float)) and not isinstance(v, bool) and math.isfinite(v)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def _check(cond: Any, message: str) -> None:
|
|
57
|
+
if not cond:
|
|
58
|
+
raise ValueError(message)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _money(a: Dict[str, Any], at: str) -> None:
|
|
62
|
+
_check("ratePerHour" not in a or (_num(a["ratePerHour"]) and a["ratePerHour"] >= 0), f"{at}: ratePerHour is a number of at least 0 (money an hour)")
|
|
63
|
+
_check("currency" not in a or (isinstance(a["currency"], str) and re.fullmatch(r"[A-Z]{3}", a["currency"])),
|
|
64
|
+
f"{at}: currency is an ISO 4217 code (USD)")
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def _tool(a: Dict[str, Any]) -> None:
|
|
68
|
+
at = _where("tool", "id", a)
|
|
69
|
+
_check(isinstance(a.get("id"), str) and _ID.fullmatch(a["id"]), f'{at}: id is letters, digits, ".", "_" and "-"')
|
|
70
|
+
_check("ref" not in a or (isinstance(a["ref"], str) and a["ref"].strip()),
|
|
71
|
+
f"{at}: ref is a device definition, or an item or body of a 3D document (<file>#<id>)")
|
|
72
|
+
_money(a, at)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def _step(t: DocTree) -> None:
|
|
76
|
+
a = t["attrs"]
|
|
77
|
+
at = _where("step", "id", a)
|
|
78
|
+
_check(isinstance(a.get("id"), str) and _ID.fullmatch(a["id"]), f'{at}: id is letters, digits, ".", "_" and "-"')
|
|
79
|
+
o = a.get("order")
|
|
80
|
+
_check("order" not in a or (isinstance(o, int) and not isinstance(o, bool) and o >= 1) or (isinstance(o, float) and o.is_integer() and o >= 1),
|
|
81
|
+
f"{at}: order is a whole number from 1")
|
|
82
|
+
_check("kind" not in a or a["kind"] in FLOW_STEP_KINDS, f"{at}: kind must be one of {', '.join(FLOW_STEP_KINDS)} (got {json.dumps(a.get('kind'))})")
|
|
83
|
+
for k in ("minutes", "setupMinutes"):
|
|
84
|
+
_check(k not in a or (_num(a[k]) and a[k] >= 0), f"{at}: {k} is a number of at least 0")
|
|
85
|
+
_money(a, at)
|
|
86
|
+
if a.get("kind") == "note":
|
|
87
|
+
_check("tool" not in a and a.get("minutes", 0) == 0 and not t["children"],
|
|
88
|
+
f"{at}: a note step names no tool, takes no time (minutes 0 or absent) and holds no param or measure")
|
|
89
|
+
names = [c["attrs"].get("name") for c in t["children"] if c["tag"] == "param"]
|
|
90
|
+
twice = next((n for i, n in enumerate(names) if n in names[:i]), None)
|
|
91
|
+
_check(twice is None, f"{at}: two params are named {json.dumps(twice, ensure_ascii=False)}")
|
|
92
|
+
for c in t["children"]:
|
|
93
|
+
b = c["attrs"]
|
|
94
|
+
if c["tag"] == "param":
|
|
95
|
+
pat = _where("param", "name", b)
|
|
96
|
+
_check(isinstance(b.get("name"), str) and b["name"].strip(), f"{pat}: name says what the parameter is")
|
|
97
|
+
v = b.get("value")
|
|
98
|
+
_check(_num(v) or isinstance(v, (str, bool)), f"{pat}: value is a number, a text or true/false")
|
|
99
|
+
_check("unit" not in b or (isinstance(b["unit"], str) and b["unit"].strip()), f"{pat}: unit is a unit's symbol (rpm, sccm, mTorr, °C, s)")
|
|
100
|
+
else:
|
|
101
|
+
mat = _where("measure", "id", b)
|
|
102
|
+
_check(isinstance(b.get("id"), str) and _ID.fullmatch(b["id"]), f'{mat}: id is letters, digits, ".", "_" and "-"')
|
|
103
|
+
for k in ("nominal", "min", "max", "plus", "minus"):
|
|
104
|
+
_check(k not in b or _num(b[k]), f"{mat}: {k} is a number")
|
|
105
|
+
for k in ("plus", "minus"):
|
|
106
|
+
_check(k not in b or b[k] >= 0, f"{mat}: {k} is a number of at least 0")
|
|
107
|
+
_check(("plus" not in b and "minus" not in b) or "nominal" in b, f"{mat}: plus and minus are tolerances of the nominal: give nominal")
|
|
108
|
+
_check("min" not in b or "max" not in b or b["min"] <= b["max"], f"{mat}: min is at most max")
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def _step_record(t: DocTree) -> Dict[str, Any]:
|
|
112
|
+
params = [dict(c["attrs"]) for c in t["children"] if c["tag"] == "param"]
|
|
113
|
+
measures = [dict(c["attrs"]) for c in t["children"] if c["tag"] == "measure"]
|
|
114
|
+
return {**t["attrs"], **({"params": params} if params else {}), **({"measures": measures} if measures else {})}
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def _flow(t: DocTree) -> Dict[str, Any]:
|
|
118
|
+
_check("of" not in t["attrs"] or isinstance(t["attrs"]["of"], str),
|
|
119
|
+
"<flow>: of is a ref to what the flow makes (a 3D document, or <file>#<item or body>)")
|
|
120
|
+
for c in t["children"]:
|
|
121
|
+
_tool(c["attrs"]) if c["tag"] == "tool" else _step(c)
|
|
122
|
+
measures = [m["attrs"].get("id") for c in t["children"] for m in c["children"] if m["tag"] == "measure"]
|
|
123
|
+
again = next((m for i, m in enumerate(measures) if m in measures[:i]), None)
|
|
124
|
+
_check(again is None, f"<measure id={json.dumps(again, ensure_ascii=False)}>: two measures have this id (a ref names it as <file>#<id>)")
|
|
125
|
+
tools = [dict(c["attrs"]) for c in t["children"] if c["tag"] == "tool"]
|
|
126
|
+
steps = [_step_record(c) for c in t["children"] if c["tag"] == "step"]
|
|
127
|
+
own = {k: t["attrs"][k] for k in FLOW_FIELDS if k in t["attrs"]}
|
|
128
|
+
return {**own, **({"tools": tools} if tools else {}), **({"steps": steps} if steps else {})}
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def _never(_: Any) -> DocTree:
|
|
132
|
+
raise NotImplementedError("the editor makes the tree from a document (the TypeScript SDK's toTree)")
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
FLOW_VOCABULARY = Vocabulary("flow", "a process flow", "flow", {
|
|
136
|
+
"flow": {"parents": [], "attrs": FLOW_FIELDS},
|
|
137
|
+
"tool": {"parents": ["flow"], "key": "id", "required": ["id"], "attrs": FLOW_TOOL_FIELDS},
|
|
138
|
+
"step": {"parents": ["flow"], "key": "id", "required": ["id"], "attrs": FLOW_STEP_FIELDS},
|
|
139
|
+
"param": {"parents": ["step"], "required": ["name", "value"], "attrs": FLOW_PARAM_FIELDS},
|
|
140
|
+
"measure": {"parents": ["step"], "key": "id", "required": ["id"], "attrs": FLOW_MEASURE_FIELDS},
|
|
141
|
+
}, _flow, _never, lambda name: {"name": name})
|
|
142
|
+
|
|
143
|
+
register_vocabulary(FLOW_VOCABULARY, "flows")
|
|
144
|
+
|
|
@@ -18,7 +18,8 @@ form the board editor writes), so the BOM, the KiCad board and a 3D body's join
|
|
|
18
18
|
|
|
19
19
|
The keys inside these dicts are the data's own (camelCase, as the JSON holds them); only the arguments are snake_case.
|
|
20
20
|
A supplier is two properties: ``<name> Part`` (its sku; ``LCSC Part`` is what JLCPCB's assembly BOM reads) and
|
|
21
|
-
``<name> Terms`` (the rest as compact JSON, a price break as [quantity, unitPrice]
|
|
21
|
+
``<name> Terms`` (the rest as compact JSON, a price break as [quantity, unitPrice], or [quantity, unitPrice,
|
|
22
|
+
unitPriceHigh] for an estimate range). ``Datasheet`` is KiCad's own field;
|
|
22
23
|
``Alternates`` is JSON; a facet's fields are one property each (``Lifecycle``, ``RoHS``, ``HS Code`` …).
|
|
23
24
|
|
|
24
25
|
``datasheet`` says where the part's datasheet is (KiCad's ``Datasheet`` field); it claims nothing. ``pinout_verified``
|
|
@@ -191,10 +192,13 @@ def check_offers(where: str, v: Any) -> List[Dict[str, Any]]:
|
|
|
191
192
|
breaks = s.get("priceBreaks")
|
|
192
193
|
if breaks is not None:
|
|
193
194
|
ok = isinstance(breaks, (list, tuple)) and all(
|
|
194
|
-
isinstance(b, dict) and
|
|
195
|
+
isinstance(b, dict) and set(b) <= {"quantity", "unitPrice", "unitPriceHigh"} and _whole(b.get("quantity"), 1)
|
|
196
|
+
and _number(b.get("unitPrice")) and b["unitPrice"] >= 0
|
|
197
|
+
and ("unitPriceHigh" not in b or (_number(b["unitPriceHigh"]) and b["unitPriceHigh"] >= b["unitPrice"]))
|
|
195
198
|
for b in breaks)
|
|
196
199
|
if not ok:
|
|
197
|
-
raise ValueError(f"{at}: priceBreaks is a list of {{ quantity, unitPrice }} (quantity a whole number from 1,
|
|
200
|
+
raise ValueError(f"{at}: priceBreaks is a list of {{ quantity, unitPrice, unitPriceHigh? }} (quantity a whole number from 1, "
|
|
201
|
+
"unitPrice 0 or more, unitPriceHigh not under it)")
|
|
198
202
|
out.append({k: copy.deepcopy(x) for k, x in s.items() if x is not None})
|
|
199
203
|
return out
|
|
200
204
|
|
|
@@ -205,7 +209,8 @@ def _offer_forms(where: str, v: Any) -> List[Dict[str, Any]]:
|
|
|
205
209
|
terms: Dict[str, Any] = {}
|
|
206
210
|
for k in _OFFER_TERMS:
|
|
207
211
|
if s.get(k) is not None:
|
|
208
|
-
terms[k] = [[b["quantity"], b["unitPrice"]]
|
|
212
|
+
terms[k] = [[b["quantity"], b["unitPrice"], *([b["unitPriceHigh"]] if "unitPriceHigh" in b else [])] for b in s[k]] \
|
|
213
|
+
if k == "priceBreaks" else s[k]
|
|
209
214
|
if s.get("sku") is not None:
|
|
210
215
|
forms.append(field_form(f"{s['name']} Part", s["sku"]))
|
|
211
216
|
if terms or s.get("sku") is None:
|
|
@@ -324,7 +329,8 @@ def part_fields(inputs: Mapping[str, Any]) -> Dict[str, Any]:
|
|
|
324
329
|
s = supplier(name[:-6])
|
|
325
330
|
for k in _OFFER_TERMS:
|
|
326
331
|
if terms.get(k) is not None:
|
|
327
|
-
s[k] = [{"quantity":
|
|
332
|
+
s[k] = [{"quantity": b[0], "unitPrice": b[1], **({"unitPriceHigh": b[2]} if len(b) > 2 else {})} for b in terms[k]] \
|
|
333
|
+
if k == "priceBreaks" else terms[k]
|
|
328
334
|
elif arg == "alternates":
|
|
329
335
|
out["alternates"] = json.loads(value)
|
|
330
336
|
elif arg == "datasheet":
|
|
@@ -47,8 +47,12 @@ The calls (children are positional; every attribute is a keyword):
|
|
|
47
47
|
|
|
48
48
|
The layout's constraints (the board's design intent: the placer, the router, the layout score and the checks read
|
|
49
49
|
them; the editor and the layout operations write each one back):
|
|
50
|
-
netclass(name, nets, kind, width,
|
|
51
|
-
|
|
50
|
+
netclass(name, nets, kind, width, min_width, clearance, edge_clearance, hole_clearance, inner, min_spokes,
|
|
51
|
+
via_diameter, via_drill, current, criticality, max_length, max_vias, impedance)
|
|
52
|
+
the rules of the nets named ("FIN*" matches by prefix): the width the router
|
|
53
|
+
lays and the narrowest allowed (``min_width``), the gaps to copper, to the
|
|
54
|
+
board edge and to a hole, the rules on inner layers (``inner``: {"clearance",
|
|
55
|
+
"width", "minWidth"}), the fewest thermal spokes a pad needs to a pour.
|
|
52
56
|
diffpair(name, positive, negative, gap, width, impedance, max_skew)
|
|
53
57
|
group(name, parts, region, near, max_distance, conviction, side)
|
|
54
58
|
parts placed together: in the box ``region`` [x0, y0, x1, y1], within
|
|
@@ -256,7 +260,7 @@ def _constraint_fact(el: Element) -> Dict[str, Any]:
|
|
|
256
260
|
return v
|
|
257
261
|
|
|
258
262
|
if el.tag == "netclass":
|
|
259
|
-
_refuse_unknown(el, ["name", "nets", "kind", "width", "clearance", "viaDiameter", "viaDrill", "current", "criticality", "maxLength", "maxVias", "impedance"])
|
|
263
|
+
_refuse_unknown(el, ["name", "nets", "kind", "width", "minWidth", "clearance", "edgeClearance", "holeClearance", "inner", "minSpokes", "viaDiameter", "viaDrill", "current", "criticality", "maxLength", "maxVias", "impedance"])
|
|
260
264
|
kind = _text(el, "kind")
|
|
261
265
|
if kind is not None and kind not in _NET_KINDS:
|
|
262
266
|
raise ValueError(f"{_where(el)}: kind is {', '.join(_NET_KINDS)}")
|
|
@@ -266,10 +270,17 @@ def _constraint_fact(el: Element) -> Dict[str, Any]:
|
|
|
266
270
|
put("name", _text(el, "name", True))
|
|
267
271
|
put("nets", names("nets", True))
|
|
268
272
|
put("kind", kind)
|
|
269
|
-
for k in ("width", "clearance", "viaDiameter", "viaDrill", "current", "maxLength", "impedance"):
|
|
273
|
+
for k in ("width", "minWidth", "clearance", "edgeClearance", "holeClearance", "viaDiameter", "viaDrill", "current", "maxLength", "impedance"):
|
|
270
274
|
put(k, _positive(el, k))
|
|
271
275
|
put("criticality", unit("criticality"))
|
|
272
276
|
put("maxVias", max_vias)
|
|
277
|
+
if out.get("minWidth") is not None and out.get("width") is not None and out["minWidth"] > out["width"]:
|
|
278
|
+
raise ValueError(f"{_where(el)}: minWidth is at most width")
|
|
279
|
+
put("inner", _plain(el, "inner", lambda v: _is_object(v) and len(v) > 0 and all(k in ("clearance", "width", "minWidth") and _is_num(x) and x > 0 for k, x in v.items()), "the rules on inner copper layers: { clearance, width, minWidth } (mm)"))
|
|
280
|
+
spokes = _num(el, "minSpokes")
|
|
281
|
+
if spokes is not None and not (float(spokes).is_integer() and 0 <= spokes <= 4):
|
|
282
|
+
raise ValueError(f"{_where(el)}: minSpokes is a whole number from 0 to 4")
|
|
283
|
+
put("minSpokes", spokes)
|
|
273
284
|
if out.get("viaDiameter") is not None and out.get("viaDrill") is not None and out["viaDiameter"] <= out["viaDrill"]:
|
|
274
285
|
raise ValueError(f"{_where(el)}: viaDiameter is more than viaDrill")
|
|
275
286
|
elif el.tag == "diffpair":
|
|
@@ -88,7 +88,8 @@ def sized_hole(hole: Dict[str, Any]) -> Dict[str, Any]:
|
|
|
88
88
|
tables give for that thread (a counterbore for a hexagon socket head cap screw, DIN 974-1; a countersink for a
|
|
89
89
|
countersunk screw, DIN 74 form F, its depth from its diameter and angle). The size wins: a ``diameter``,
|
|
90
90
|
``headDiameter`` or ``headDepth`` that differs from the size's is refused. Leave it out, or clear ``size`` to give
|
|
91
|
-
your own.
|
|
91
|
+
your own. One choice stays yours: a counterbore deeper than the size's (``headDepth`` more than the table's) sinks
|
|
92
|
+
the head below the face."""
|
|
92
93
|
if not isinstance(hole.get("size"), str):
|
|
93
94
|
return hole
|
|
94
95
|
named = hole_size(hole["size"])
|
|
@@ -102,10 +103,14 @@ def sized_hole(hole: Dict[str, Any]) -> Dict[str, Any]:
|
|
|
102
103
|
says["headDiameter"] = sink["diameter"]
|
|
103
104
|
depth = (sink["diameter"] - named["diameter"]) / 2 / math.tan(sink["angleDeg"] * math.pi / 360)
|
|
104
105
|
says["headDepth"] = math.floor(depth * 1e4 + 0.5) / 1e4
|
|
106
|
+
depth = hole.get("headDepth")
|
|
107
|
+
if hole.get("style") == "counterbore" and "headDepth" in says and _is_number(depth) and depth > says["headDepth"]:
|
|
108
|
+
says["headDepth"] = depth
|
|
105
109
|
for field, value in says.items():
|
|
106
110
|
written = hole.get(field)
|
|
107
111
|
if _is_number(written) and abs(written - value) > 1e-9:
|
|
108
|
-
|
|
112
|
+
deeper = " (a counterbore may be deeper than the size's, not shallower)" if field == "headDepth" and hole.get("style") == "counterbore" else ""
|
|
113
|
+
raise ValueError(f'{field}: "{hole["size"]}" is {_number(value)} mm (got {_number(written)}); leave {field} out, or clear size{deeper}')
|
|
109
114
|
return {**hole, **says}
|
|
110
115
|
|
|
111
116
|
|