← Commit history
Preserve source for adom-molecule-1.2.0
10 files changed
+444−357
.gitignoreadded+1@@ -0,0 +1 @@+target/
Cargo.lockadded+186@@ -0,0 +1,186 @@+# This file is automatically @generated by Cargo.+# It is not intended for manual editing.+version = 4++[[package]]+name = "adom-molecule"+version = "1.2.0"+dependencies = [+ "clap",+]++[[package]]+name = "anstream"+version = "1.0.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d"+dependencies = [+ "anstyle",+ "anstyle-parse",+ "anstyle-query",+ "anstyle-wincon",+ "colorchoice",+ "is_terminal_polyfill",+ "utf8parse",+]++[[package]]+name = "anstyle"+version = "1.0.14"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000"++[[package]]+name = "anstyle-parse"+version = "1.0.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e"+dependencies = [+ "utf8parse",+]++[[package]]+name = "anstyle-query"+version = "1.1.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"+dependencies = [+ "windows-sys",+]++[[package]]+name = "anstyle-wincon"+version = "3.0.11"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"+dependencies = [+ "anstyle",+ "once_cell_polyfill",+ "windows-sys",+]++[[package]]+name = "clap"+version = "4.6.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b193af5b67834b676abd72466a96c1024e6a6ad978a1f484bd90b85c94041351"+dependencies = [+ "clap_builder",+ "clap_derive",+]++[[package]]+name = "clap_builder"+version = "4.6.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "714a53001bf66416adb0e2ef5ac857140e7dc3a0c48fb28b2f10762fc4b5069f"+dependencies = [+ "anstream",+ "anstyle",+ "clap_lex",+ "strsim",+]++[[package]]+name = "clap_derive"+version = "4.6.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1110bd8a634a1ab8cb04345d8d878267d57c3cf1b38d91b71af6686408bbca6a"+dependencies = [+ "heck",+ "proc-macro2",+ "quote",+ "syn",+]++[[package]]+name = "clap_lex"+version = "1.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9"++[[package]]+name = "colorchoice"+version = "1.0.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"++[[package]]+name = "heck"+version = "0.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"++[[package]]+name = "is_terminal_polyfill"+version = "1.70.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"++[[package]]+name = "once_cell_polyfill"+version = "1.70.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"++[[package]]+name = "proc-macro2"+version = "1.0.106"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"+dependencies = [+ "unicode-ident",+]++[[package]]+name = "quote"+version = "1.0.45"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924"+dependencies = [+ "proc-macro2",+]++[[package]]+name = "strsim"+version = "0.11.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"++[[package]]+name = "syn"+version = "2.0.117"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"+dependencies = [+ "proc-macro2",+ "quote",+ "unicode-ident",+]++[[package]]+name = "unicode-ident"+version = "1.0.24"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"++[[package]]+name = "utf8parse"+version = "0.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"++[[package]]+name = "windows-link"+version = "0.2.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"++[[package]]+name = "windows-sys"+version = "0.61.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"+dependencies = [+ "windows-link",+]
Cargo.tomladded+16@@ -0,0 +1,16 @@+[package]+name = "adom-molecule"+version = "1.2.0"+edition = "2021"+description = "Deprecated: molecules live on the Adom wiki; use adom-wiki model import"++[[bin]]+name = "adom-molecule"+path = "src/main.rs"++[dependencies]+clap = { version = "4", features = ["derive"] }++[profile.release]+strip = true+lto = "thin"
README.md+20−51@@ -1,51 +1,20 @@-# Adom Molecule CLI--Rust CLI for the Adom molecule pipeline. Install via the wiki (binary bundled — no-GitHub release needed):--```bash-adom-wiki pkg install adom/adom-molecule-```--## Import a wiki molecule into Hydrogen (new in 1.1.0)--Pulls a molecule **already published on the wiki** into a Hydrogen account, reusing-its published GLB — **no re-optimization, no silkscreen re-render**:--```bash-adom-molecule import <wiki-slug> --owner <username> [--name <molecule-name>]-```--The wiki page's auto-generated GLB (STEP→GLB at `adom-wiki pkg publish` time) is fetched-and registered directly via Hydrogen's `/api/molecules/create-json`.--## Create from source files--```bash-# KiCad-adom-molecule create --name "RP2040_Core" --owner adom \- --glb model.glb --pcb board.kicad_pcb --sch schematic.kicad_sch-# Fusion 360-adom-molecule create --source fusion --name "Enclosure" --owner john \- --usdz model.usdz --silk-top silkscreen.png-```--`adom-molecule list` / `adom-molecule delete --owner <u> --name <n>` manage the library.--## Sources--| Source | Files | Pipeline |-|--------|-------|----------|-| Wiki import | (reuses published GLB) | none — direct register |-| KiCad | `.glb`, `.kicad_pcb`, `.kicad_sch` | Blender |-| Fusion 360 | `.usdz`, silkscreen `.png` | USDZ→GLB (Blender) |-| EasyEDA | `.obj` | direct |--- Source: https://github.com/adom-inc/adom-molecule (backup)-- Binary: ~3.3 MB (Linux x86_64)----## Private pages--`adom-molecule import <owner>/<slug> --owner <you>` works on **private** wiki pages since 1.1.10: the wiki reads carry the container credential (`Authorization: Bearer`) and the owner-qualified `wikiRef` lets Hydrogen re-read the page with the same credential. A page you cannot see 404s (by the wiki's design); nothing has to be made public.+# adom-molecule (deprecated)++adom-molecule is deprecated and no longer maintained; 1.2.0 is its last release, and this+repository is archived. Molecules live on the Adom wiki: the wiki's model registry builds a+molecule's model, footprint and symbol from the sources its page carries, and Hydrogen reads+them from there.++| Old command | Now |+| --- | --- |+| `adom-molecule import <owner>/<slug> --owner <you> [--name <n>]` | `adom-wiki model import <owner>/<slug> --owner <you> [--name <n>]` (adom-wiki 1.8.0 or newer) |+| `adom-molecule create ...`, `optimize`, `optimize-fusion` | publish the sources on the wiki page with the molecule-publish skill or `adom-wiki pkg publish --wait`; the registry builds the model |+| `adom-molecule list`, `delete` | Hydrogen: https://hydrogen.adom.inc/users/<you>/molecules (an org's at /orgs/<org>/molecules) |+| `adom-molecule health`, `install` | `adom-wiki doctor`, `adom-wiki self-update` |++The 1.2.0 binary prints the matching row for each command and exits 1. `import` instead runs+`adom-wiki model import` with the same arguments when adom-wiki 1.8.0 or newer is on the+PATH, and otherwise prints the command to run.++The last working code is commit `52aa0b5` (1.1.11, never published); the wiki keeps the+1.1.10 release.
SKILL.md+20−246@@ -1,255 +1,29 @@ --- name: adom-molecule description: >- Use when the user wants to create a molecule, import KiCad/Fusion 360/EasyEDA files- into the Adom molecule system, upload a molecule, optimize a molecule's 3D model,- list molecules, or delete a molecule. Trigger words: create molecule, import molecule,- upload molecule, molecule from kicad, molecule from fusion, import kicad files,- upload fusion files, list molecules, delete molecule, optimize molecule, usdz to glb,- kicad to molecule, fusion to molecule, import molecule from wiki, pull wiki- molecule into hydrogen, import published molecule.+ Deprecated, no longer maintained. Read only to translate an old adom-molecule command+ (import, create, optimize, list, delete) into what replaced it: molecules live on the Adom+ wiki, the wiki's model registry builds them from their sources, and+ `adom-wiki model import` brings one into Hydrogen. Trigger words: adom-molecule,+ adom-molecule import, adom-molecule create. --- -# Adom Molecule CLI+# adom-molecule (deprecated) -Create and manage Adom molecules from KiCad, Fusion 360, and EasyEDA design files.-Wraps the Hydrogen molecule import pipeline — file upload, Blender 3D optimization,-listing, and deletion.+adom-molecule is deprecated; 1.2.0 is its last release. Molecules live on the Adom wiki:+the wiki's model registry builds a molecule's model, footprint and symbol from the sources+its page carries, and Hydrogen reads them from there. Use these instead: -## EasyEDA logo: remove it during creation (always)+| Old command | Now |+| --- | --- |+| `adom-molecule import <owner>/<slug> --owner <you> [--name <n>]` | `adom-wiki model import <owner>/<slug> --owner <you> [--name <n>]` (adom-wiki 1.8.0 or newer) |+| `adom-molecule create ...`, `optimize`, `optimize-fusion` | publish the sources on the wiki page with the molecule-publish skill or `adom-wiki pkg publish --wait`; the registry builds the model. The kicad-, fusion- and altium-export-molecule skills cover the whole trip. |+| `adom-molecule list`, `delete` | Hydrogen: https://hydrogen.adom.inc/users/<you>/molecules (an org's at /orgs/<org>/molecules) |+| `adom-molecule health`, `install` | `adom-wiki doctor`, `adom-wiki self-update` | -3D models that come from EasyEDA / LCSC (easyeda2kicad, LCSC `C` numbers, EasyEDA `.obj`, JLC libraries), and any board STEP/GLB that places those models, often carry an embossed **"LCEDA / EasyEDA" logo**: usually on a package side wall (seen on WS2812B-2020 and X0408FVS-100F-LPV01), sometimes on a chip top (seen on RP2350A and ADS1220), and sometimes the same colour as the body so it is easy to miss. It must not ship in anything we create or publish.+The 1.2.0 binary prints the same table entry for each command and exits 1, except `import`,+which runs `adom-wiki model import` with the same arguments when adom-wiki 1.8.0 or newer+is on the PATH. -- **Check every EasyEDA-sourced part** before it is used or published: look at close-up renders of all four side walls and the top, not just the top view, and scan the STEP for the logo (clusters of tiny, very thin glyph faces or zero-thickness glyph solids).-- **Strip it from the part model** (remove the glyph faces/solids and close the face they sat on), keeping the body, pads, size and colours unchanged. Then build the footprint, board STEP and GLBs from the cleaned part, so every derived file is clean.-- **Verify**: rescan clean, the part's bounding box and colours unchanged, and a before/after render.-- Real manufacturer markings (the maker's logo, MPN or date code etched on the part) are not EasyEDA logos; keep those.--## Quick Start--```bash-# Check connectivity-adom-molecule health--# Create a KiCad molecule (uploads files + auto-queues 3D optimization)-adom-molecule create --source kicad --name "MyBoard" --owner john \- --glb model.glb --pcb board.kicad_pcb --sch schematic.kicad_sch--# Create a Fusion 360 molecule-adom-molecule create --source fusion --name "MyEnclosure" --owner john \- --usdz model.usdz --f3d design.f3d --brd board.brd --silk-top silkscreen.png--# List all molecules-adom-molecule list--# Delete a molecule-adom-molecule delete --owner john --name "MyBoard"-```--## Import a published wiki molecule (new in 1.1.0)--Pull a molecule **already published on the wiki** into a Hydrogen account, reusing its-published GLB — no re-optimization, no silkscreen re-render:--```bash-adom-molecule import <wiki-slug> --owner <username> [--name <molecule-name>]-```--The wiki page's auto-generated GLB (STEP→GLB at `adom-wiki pkg publish` time) is fetched and-registered directly via Hydrogen's `/api/molecules/create-json`. Use this to reuse an-existing wiki molecule instead of re-uploading source files. The wiki read is public-(public molecules only for now).--## Commands--### `adom-molecule health`--Check connectivity to the Hydrogen and Carbon APIs.--**Example:**-```bash-adom-molecule health-# OK: Hydrogen API reachable (https://hydrogen.adom.inc)-# OK: Carbon API reachable (https://carbon.adom.inc)-```---### `adom-molecule create`--Upload design files and create a molecule. Auto-queues 3D optimization unless `--no-optimize` is passed.--| Flag | Required | Description |-|------|----------|-------------|-| `--source` | no | `kicad`, `fusion`, or `easyeda`. Auto-detected from files if omitted. |-| `--name` | yes | Molecule name |-| `--owner` | yes | Owner username or org name |-| `--glb` | KiCad | Path to `.glb` 3D model |-| `--pcb` | KiCad | Path to `.kicad_pcb` board file |-| `--sch` | KiCad | Path to `.kicad_sch` schematic file |-| `--pro` | no | Path to `.kicad_pro` project file |-| `--usdz` | Fusion | Path to `.usdz` 3D model |-| `--f3d` | no | Path to `.f3d` Fusion native file |-| `--brd` | no | Path to `.brd` board file |-| `--sch-eagle` | no | Path to `.sch` EAGLE schematic file |-| `--silk-top` | Fusion | Path to silkscreen top `.png` |-| `--silk-bottom` | no | Path to silkscreen bottom `.png` |-| `--obj` | EasyEDA | Path to `.obj` 3D model |-| `--extra` | no | Additional files (repeatable) |-| `--no-optimize` | no | Skip automatic optimization queue |--**KiCad example:**-```bash-adom-molecule create --name "RP2040_Core" --owner adom \- --glb /home/adom/project/molecules/rp2040/model.glb \- --pcb /home/adom/project/molecules/rp2040/board.kicad_pcb \- --sch /home/adom/project/molecules/rp2040/schematic.kicad_sch \- --pro /home/adom/project/molecules/rp2040/project.kicad_pro-# OK: Created molecule "RP2040_Core" (v1). Optimization queued.-```--**Fusion 360 example:**-```bash-adom-molecule create --source fusion --name "Enclosure_v2" --owner john \- --usdz /home/adom/exports/enclosure.usdz \- --f3d /home/adom/exports/enclosure.f3d \- --brd /home/adom/exports/board.brd \- --silk-top /home/adom/exports/silkscreen_top.png-# OK: Created molecule "Enclosure_v2" (v1). Fusion optimization queued.-```--**EasyEDA example:**-```bash-adom-molecule create --source easyeda --name "Sensor_Board" --owner adom \- --obj /home/adom/exports/sensor.obj-# OK: Created molecule "Sensor_Board" (v1).-```--**With extra files:**-```bash-adom-molecule create --name "MyBoard" --owner adom \- --glb model.glb --pcb board.kicad_pcb --sch schematic.kicad_sch \- --extra datasheet.pdf --extra bom.csv-# OK: Created molecule "MyBoard" (v1). Optimization queued. 2 extra file(s) attached.-```---### `adom-molecule optimize`--Manually queue a KiCad molecule for 3D optimization (Blender pipeline).-Normally not needed — `create` does this automatically.--| Flag | Required | Description |-|------|----------|-------------|-| `--owner` | yes | Owner username or org |-| `--name` | yes | Molecule name |-| `--version` | yes | Version string (e.g. `v1`) |-| `--glb` | yes | GLB filename that was uploaded |--**Example:**-```bash-adom-molecule optimize --owner adom --name "RP2040_Core" --version v1 --glb model.glb-# OK: Optimization queued for "RP2040_Core" v1 (job abc123)-```---### `adom-molecule optimize-fusion`--Manually queue a Fusion 360 molecule for USDZ-to-GLB optimization.--| Flag | Required | Description |-|------|----------|-------------|-| `--owner` | yes | Owner username or org |-| `--name` | yes | Molecule name |-| `--version` | yes | Version string |-| `--usdz` | no | USDZ filename |-| `--f3d` | no | F3D filename |-| `--brd` | no | BRD filename |-| `--silk-top` | yes | Silkscreen top filename |--**Example:**-```bash-adom-molecule optimize-fusion --owner john --name "Enclosure_v2" --version v1 \- --usdz enclosure.usdz --silk-top silkscreen_top.png-# OK: Fusion optimization queued for "Enclosure_v2" v1 (job def456)-```---### `adom-molecule list`--List all molecules in the system.--**Example:**-```bash-adom-molecule list-# OK: 0 molecule(s)-# (empty — no molecules created yet)-```---### `adom-molecule delete`--Delete a molecule.--| Flag | Required | Description |-|------|----------|-------------|-| `--owner` | yes | Owner username or org |-| `--name` | yes | Molecule name |--**Example:**-```bash-adom-molecule delete --owner john --name "OldBoard"-# OK: Deleted molecule "OldBoard" owned by john-```---### `adom-molecule install`--Deploy the SKILL.md to `~/.claude/skills/adom-molecule/` and optionally copy-the binary to `/usr/local/bin/`.--**Example:**-```bash-adom-molecule install-# OK: Installed skill to /home/adom/.claude/skills/adom-molecule/SKILL.md-# OK: Binary already at /usr/local/bin/adom-molecule-```--## Source Types & Required Files--| Source | Required Files | Optional Files |-|--------|---------------|----------------|-| **KiCad** | `.glb`, `.kicad_pcb`, `.kicad_sch` | `.kicad_pro` |-| **Fusion 360** | `.usdz`, silkscreen top `.png` | `.f3d`, `.brd`, `.sch`, silkscreen bottom `.png` |-| **EasyEDA** | `.obj` | — |--If `--source` is omitted, it's auto-detected from file extensions:-- `.glb`, `.kicad_pcb`, `.kicad_sch` → KiCad-- `.usdz`, `.f3d`, `.brd`, `.png` → Fusion 360-- `.obj` → EasyEDA--## Environment Variables--| Variable | Default | Description |-|----------|---------|-------------|-| `ADOM_HYDROGEN_URL` | `https://hydrogen.adom.inc` | Hydrogen API base URL |-| `ADOM_CARBON_URL` | `https://carbon.adom.inc` | Carbon API base URL |--## Troubleshooting--### `ERROR: Failed to create molecule: Access Key Id does not exist`-The Hydrogen server's S3 storage credentials are expired or misconfigured.-This is a server-side issue — contact the Adom team.--### `ERROR: Cannot reach Hydrogen API`-Check your network connection. The API is at `https://hydrogen.adom.inc`.-From inside an Adom container, this should always be reachable.--### Optimization queued but molecule doesn't update-The Blender optimization pipeline runs asynchronously. Check the molecule-page at `https://hydrogen.adom.inc/{owner}/molecules/{name}` after a few minutes.+Before importing, wait for the page's build: `adom-wiki model wait <owner>/<slug>` (exit 0+is a passed build). A page with no model yet is refused with MODEL_IMPORT_NO_MODEL.
build.shadded+7@@ -0,0 +1,7 @@+#!/usr/bin/env bash+set -euo pipefail+cd "$(dirname "$0")"+cargo build --release+sudo cp target/release/adom-molecule /usr/local/bin/+chmod +x /usr/local/bin/adom-molecule+echo "Done. adom-molecule is deprecated: use adom-wiki model import"
install.sh+4−5@@ -20,7 +20,8 @@ if [ -w "$(dirname "$DEST")" ]; then install -m 0755 "$TMP_BIN" "$DEST"; else su rm -f "$TMP_BIN" echo "Installed adom-molecule ${VER} → $DEST" -# Skills: root SKILL.md = the adom-molecule skill; sub-skills under skills/<name>/.+# Skill: root SKILL.md = the adom-molecule skill, which now only says what replaced each+# command. The adom-molecule-import skill of older releases is removed. # Copy real files (no symlinks), clearing any prior dir or symlink from an old install. # Under sudo, $HOME is /root — resolve the REAL user's home via SUDO_USER so the # skills land where Claude Code (running as that user) can see them.@@ -37,7 +38,5 @@ install_skill() { # <install-name> <source SKILL.md> echo "Installed skill → $SKILLS_DIR/$1/SKILL.md" } install_skill adom-molecule "$PKG_DIR/SKILL.md"-for d in "$PKG_DIR"/skills/*/; do- [ -d "$d" ] || continue- install_skill "$(basename "$d")" "$d/SKILL.md"-done+rm -rf "$SKILLS_DIR/adom-molecule-import" "$TARGET_HOME/.codex/skills/adom-molecule-import"+echo "adom-molecule is deprecated: use adom-wiki model import (adom-wiki 1.8.0 or newer)"
package.json+9−28@@ -1,41 +1,22 @@ { "slug": "adom-molecule",- "version": "1.1.10",+ "version": "1.2.0", "type": "app",- "description": "Adom Molecule CLI \u2014 import a wiki molecule into Hydrogen (reuses the published GLB, no re-optimization), plus create/optimize/list/delete from KiCad, Fusion 360, and EasyEDA files.",+ "description": "Deprecated: molecules live on the Adom wiki. Bring one into Hydrogen with `adom-wiki model import`; publish one with the molecule-publish skill. This last release points each old command to its replacement.", "needs_sudo": true, "tags": [ "molecule", "hydrogen",- "kicad",- "fusion360",- "cli"+ "deprecated" ], "dependencies": {}, "scripts": { "install": "./install.sh", "uninstall": "./uninstall.sh" },- "hero": {- "headline": "Wiki molecule \u2192 Hydrogen, one command",- "subhead": "import a published molecule (reuses its GLB), or create from KiCad/Fusion/EasyEDA",- "screenshot": "docs/shot.png"- },- "discovery_triggers": [- "create molecule",- "import molecule from wiki",- "pull wiki molecule into hydrogen",- "import published molecule",- "molecule from kicad",- "molecule from fusion",- "list molecules",- "delete molecule",- "optimize molecule",- "usdz to glb",- "upload fusion files",- "kicad to molecule",- "import private molecule",- "private wiki molecule",- "molecule import private page"- ]-}+ "hero": { + "type": "image", + "path": "screenshots/hero.png" +},+ "discovery_triggers": []+}
page.json+9−27@@ -1,46 +1,28 @@ { "slug": "adom-molecule",- "version": "1.1.10",+ "version": "1.2.0", "type": "app",- "description": "Adom Molecule CLI — import a wiki molecule into Hydrogen (reuses the published GLB, no re-optimization), plus create/optimize/list/delete from KiCad, Fusion 360, and EasyEDA files.",+ "description": "Deprecated: molecules live on the Adom wiki. Bring one into Hydrogen with `adom-wiki model import`; publish one with the molecule-publish skill. This last release points each old command to its replacement.", "needs_sudo": true, "tags": [ "molecule", "hydrogen",- "kicad",- "fusion360",- "cli"+ "deprecated" ], "dependencies": {}, "scripts": { "install": "./install.sh", "uninstall": "./uninstall.sh" },- "hero": {- "type": "image",- "path": "screenshots/hero.png"- },- "discovery_triggers": [- "create molecule",- "import molecule from wiki",- "pull wiki molecule into hydrogen",- "import published molecule",- "molecule from kicad",- "molecule from fusion",- "list molecules",- "delete molecule",- "optimize molecule",- "usdz to glb",- "upload fusion files",- "kicad to molecule",- "import private molecule",- "private wiki molecule",- "molecule import private page"- ],+ "hero": { + "type": "image", + "path": "screenshots/hero.png" +},+ "discovery_triggers": [], "org": "adom", "author": { "name": "Kyle Bergstedt", "email": "[email protected]" }, "visibility": "public"-}+}
src/main.rsadded+172@@ -0,0 +1,172 @@+//! adom-molecule is deprecated; 1.2.0 is its last release.+//!+//! Molecules live on the Adom wiki: the wiki's model registry builds a+//! molecule's model, footprint and symbol from the sources its page carries,+//! and Hydrogen reads them from there. Each old command says where its work+//! went, and `import` runs `adom-wiki model import` with the same arguments.++use clap::{Args, Parser, Subcommand};+use std::process::{Command, ExitCode, Stdio};++#[derive(Parser)]+#[command(+ name = "adom-molecule",+ version,+ about = "Deprecated: molecules live on the Adom wiki. Publish one with the molecule-publish skill or adom-wiki, and bring it into Hydrogen with `adom-wiki model import`"+)]+struct Cli {+ #[command(subcommand)]+ command: Cmd,+}++#[derive(Subcommand)]+enum Cmd {+ /// Deprecated: runs `adom-wiki model import` with the same arguments+ Import {+ /// Wiki page reference: <owner>/<slug> or a bare slug+ slug: String,+ /// Hydrogen owner to import under: your username or an org you belong to+ #[arg(long)]+ owner: String,+ /// Molecule name in Hydrogen+ #[arg(long)]+ name: Option<String>,+ },+ /// Deprecated: publish the sources on the wiki; its registry builds the model+ Create(Unused),+ /// Deprecated: the wiki's registry builds the model+ Optimize(Unused),+ /// Deprecated: the wiki's registry builds the model+ OptimizeFusion(Unused),+ /// Deprecated: Hydrogen lists your molecules+ List(Unused),+ /// Deprecated: Hydrogen deletes your molecules+ Delete(Unused),+ /// Deprecated: use adom-wiki+ Health(Unused),+ /// Deprecated: use adom-wiki+ Install(Unused),+}++/// The arguments an old command was given. They are read and not used, so a+/// script calling the old command gets the notice, not a usage error.+#[derive(Args)]+struct Unused {+ #[arg(trailing_var_arg = true, allow_hyphen_values = true, hide = true)]+ args: Vec<String>,+}++const NOTICE: &str =+ "adom-molecule is deprecated and no longer maintained; 1.2.0 is its last release. Molecules live on the Adom wiki.";++const MAKE: &str = "Publish the molecule's sources on its wiki page (the STEP with its .kicad_pcb or .brd, \+<slug>-fab.zip and export.json, or a circuit.json) with the molecule-publish skill or `adom-wiki pkg publish --wait`. \+The wiki's model registry builds the model, footprint and symbol from them. Then bring it into Hydrogen:\n \+adom-wiki model import <owner>/<slug> --owner <hydrogen-owner>";++const LIBRARY: &str = "Hydrogen lists and deletes your molecules at https://hydrogen.adom.inc/users/<you>/molecules \+(an org's at /orgs/<org>/molecules). Bring a wiki molecule in with:\n \+adom-wiki model import <owner>/<slug> --owner <hydrogen-owner>";++const TOOLS: &str = "Use adom-wiki: `adom-wiki doctor` checks it and your sign-in, `adom-wiki self-update` updates it, \+and `adom-wiki model import <owner>/<slug> --owner <hydrogen-owner>` brings a wiki molecule into Hydrogen.";++/// The `adom-wiki` arguments an old `import` stands for.+fn import_args(slug: &str, owner: &str, name: Option<&str>) -> Vec<String> {+ let mut args = vec!["model", "import", slug, "--owner", owner];+ if let Some(n) = name {+ args.extend(["--name", n]);+ }+ args.into_iter().map(str::to_string).collect()+}++/// An argument as it would be typed in a shell: quoted when it holds+/// anything but letters, digits and `-_./@:=`.+fn shell_word(s: &str) -> String {+ let plain = !s.is_empty() && s.chars().all(|c| c.is_ascii_alphanumeric() || "-_./@:=".contains(c));+ if plain {+ s.to_string()+ } else {+ format!("'{}'", s.replace('\'', r"'\''"))+ }+}++/// Whether the `adom-wiki` on PATH has `model import` (1.8.0 and newer).+fn adom_wiki_imports() -> bool {+ Command::new("adom-wiki")+ .args(["model", "import", "--help"])+ .stdout(Stdio::null())+ .stderr(Stdio::null())+ .status()+ .map(|s| s.success())+ .unwrap_or(false)+}++fn import(slug: &str, owner: &str, name: Option<&str>) -> ExitCode {+ let args = import_args(slug, owner, name);+ let typed = args.iter().map(|a| shell_word(a)).collect::<Vec<_>>().join(" ");+ if !adom_wiki_imports() {+ eprintln!(+ "{NOTICE}\n`adom-molecule import` moved to `adom-wiki model import`, which needs adom-wiki 1.8.0 or newer \+(`adom-wiki self-update` updates an older one). Then run:\n adom-wiki {typed}"+ );+ return ExitCode::FAILURE;+ }+ eprintln!("{NOTICE}\nRunning `adom-wiki {typed}`; run that directly from now on.");+ match Command::new("adom-wiki").args(&args).status() {+ Ok(s) => ExitCode::from(s.code().unwrap_or(1).clamp(0, 255) as u8),+ Err(e) => {+ eprintln!("could not run adom-wiki: {e}");+ ExitCode::FAILURE+ }+ }+}++fn main() -> ExitCode {+ let where_now = match Cli::parse().command {+ Cmd::Import { slug, owner, name } => return import(&slug, &owner, name.as_deref()),+ Cmd::Create(_) | Cmd::Optimize(_) | Cmd::OptimizeFusion(_) => MAKE,+ Cmd::List(_) | Cmd::Delete(_) => LIBRARY,+ Cmd::Health(_) | Cmd::Install(_) => TOOLS,+ };+ eprintln!("{NOTICE}\n{where_now}");+ ExitCode::FAILURE+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn import_maps_to_adom_wiki_model_import() {+ assert_eq!(+ import_args("drew2/e2e-kicad-solonoid", "drew2", None),+ ["model", "import", "drew2/e2e-kicad-solonoid", "--owner", "drew2"]+ );+ assert_eq!(+ import_args("adom/foo", "acme", Some("Foo Board")),+ ["model", "import", "adom/foo", "--owner", "acme", "--name", "Foo Board"]+ );+ }++ #[test]+ fn shell_words_quote_only_what_needs_it() {+ assert_eq!(shell_word("adom/foo-1.2"), "adom/foo-1.2");+ assert_eq!(shell_word("Foo Board"), "'Foo Board'");+ assert_eq!(shell_word("it's"), r"'it'\''s'");+ assert_eq!(shell_word(""), "''");+ }++ #[test]+ fn old_commands_parse_with_their_old_arguments() {+ for argv in [+ vec!["adom-molecule", "create", "--name", "X", "--owner", "adom", "--glb", "x.glb"],+ vec!["adom-molecule", "optimize-fusion", "--owner", "a", "--name", "b", "--version", "v1"],+ vec!["adom-molecule", "list"],+ vec!["adom-molecule", "delete", "--owner", "a", "--name", "b"],+ vec!["adom-molecule", "install", "--bin-dir", "/tmp"],+ ] {+ assert!(Cli::try_parse_from(&argv).is_ok(), "{argv:?}");+ }+ }+}