name: adom-molecule-import description: "Import a molecule from the Adom wiki into a Hydrogen account in one step — download its published assets, reuse the existing optimized GLB (no re-optimization, no silkscreen needed), and register it under the user's owner. Use when: import a molecule, pull a molecule from the wiki, copy a wiki molecule to my account, clone molecule, add wiki molecule to Hydrogen, get molecule into my account. Trigger words — import molecule, molecule import, pull molecule, copy molecule, clone molecule, wiki molecule to hydrogen, add molecule to my account." user-invocable: true argument-hint: " [--owner ] [--name ]"

adom-molecule-import — wiki molecule → your Hydrogen account

Wraps the manual download→map→create chain into one flow. Given a wiki molecule slug, it pulls the published assets, reuses the existing GLB (skipping the Blender pipeline entirely — so no silkscreen files are ever needed), and registers the molecule under the user's owner on Hydrogen.

Prereq: adom-molecule CLI installed (adom-molecule health passes) and the user is in an Adom container (auth is automatic via the container's Carbon credential — no token).

Why this is simpler than it looks

The hard part of importing used to be silkscreen PNGs — needed only to re-optimize (regenerate the GLB) from source. We don't re-optimize. If the molecule already has an optimized GLB, we reuse it as-is via create --glb ... --no-optimize. No haiku agent, no silkscreen analysis, no per-file inference — asset→flag is a fixed lookup table (below).

Asset type → create flag (the only mapping — deterministic)

The wiki assets API (/api/v1/pages/<slug>/assets) returns objects with asset_type, filename, file_path. Map by asset_type:

asset_type adom-molecule create flag Role
glb --glb The optimized 3D model — reuse this; enables --no-optimize
kicad_pcb (or *.kicad_pcb) --pcb KiCad board
kicad_sch (or *.kicad_sch) --sch KiCad schematic
kicad_pro (or *.kicad_pro) --pro KiCad project
usdz --usdz Fusion 3D model
f3d --f3d Fusion native project
fbrd --brd Fusion/EAGLE board
fsch --sch-eagle Fusion/EAGLE schematic
obj --obj EasyEDA 3D
step, stl, 3mf, sat, igs, gerbers, bom, cpl --extra (repeatable) Carried along as supplementary files
screenshot, hero_image, video, thumbnail (skip) Informational only — never uploaded

Workflow

1. Resolve target owner + name

  • Owner: --owner if given, else the user's own username from adom-wiki whoami (the name field). Never default to the source molecule's owner — Carbon only lets you write to yourself or an org you belong to (wrong owner → 401).
  • Name: --name if given, else derive from the slug (strip trailing -<digits> id and version suffixes; confirm with the user).

2. Fetch the asset list

Use adom-wiki api — it authenticates with the container's Carbon credential automatically, so this works on private molecule pages too (anonymous reads 404 on private pages; the old public slug-host URLs are dead):

adom-wiki api "/api/v1/pages/<slug>/assets" \
  | python3 -c "import sys,json; [print(a['asset_type'],a['filename'],a['file_path']) for a in (lambda d: d.get('assets',d) if isinstance(d,dict) else d)(json.load(sys.stdin))]"

3. Decide the path based on GLB presence

If a glb asset exists → REUSE path (clean, preferred):

  1. Download the page's files with an authenticated, binary-safe clone (works for private pages; GLBs come through intact):
    adom-wiki repo clone <owner>/<slug> --dir /tmp/molecule-import-<slug>
    
    Prefer the <owner>/<slug> reference — page identity is (owner, slug), so a bare slug can be ambiguous across owners. Pick the mapped files out of the clone; skip informational assets.
  2. Build the create command from the mapping table, always passing --glb <downloaded.glb> and --no-optimize:
    adom-molecule create --owner <owner> --name <name> \
      --glb <name>.glb [--pcb ... | --usdz ... | --f3d ... etc] \
      [--extra <step> --extra <gerbers.zip> ...] --no-optimize
    
    --no-optimize is the key: it registers the molecule with the existing GLB and skips the Blender pipeline, so silkscreen is irrelevant.

If NO glb asset exists (common for Fusion molecules like COSMOCOIL) → STOP and tell the user:

"This molecule has no published GLB on the wiki — its 3D model lives on the original owner's Hydrogen account and was never published back. I can either (a) import the source files now and you re-optimize later (this needs silkscreen PNGs, which the wiki doesn't provide), or (b) ask the molecule's owner to publish its optimized GLB to the wiki so import is clean. Which do you want?"

Do not silently run optimize/optimize-fusion — that reintroduces the silkscreen requirement and usually fails. Default to surfacing the gap, not guessing.

4. Guard against name collisions

Before create, run adom-molecule list and check for <name> under <owner>. If it exists, ask the user: rename, overwrite (delete+recreate), or abort. Never silently clobber.

5. Verify + report

adom-molecule list   # confirm <name> appears under <owner>

Print the result URL: hydrogen.adom.inc/<owner>/molecules/<name>.

Notes & guardrails

  • Auth is automatic in an Adom container — never set ADOM_API_KEY (the binary ignores it) or invent a login step.
  • Owner = the user, not the source molecule's owner. This is the #1 cause of 401s.
  • Downloads are authenticated (via adom-wiki, same container credential), so private molecule pages import fine — no need to flip a page public first. A 401 on create means wrong owner, not missing setup; a 404 on the wiki read means the page doesn't exist or you lack access to a private page.
  • Don't re-optimize. Reuse the GLB. If there's no GLB, surface the gap — don't fall into the silkscreen trap.
  • The clean long-term fix (so the no-GLB branch disappears) is upstream: have molecule publishing push the optimized GLB to the wiki for Fusion molecules too. Flag it when you hit a no-GLB molecule.
  • adom-molecule — the underlying CLI (create, list, health). A native import <slug> verb may exist in newer versions; prefer it if present (adom-molecule import --help).
  • adom-molecules / adom-molecules-catalog — what molecules exist / SKUs.