Q:

Scripted vector drawing app (à la Satimage Smile)

I've used Satimage's Smile app to make vector diagrams (for technical illustrations, laser-cutting patterns, etc) via AppleScript augmented with drawing commands. It's like the opposite of PaintCode, which turns drawings into code. (I'm a mathematician, not an artist, so I want/need to describe images with formulas and equations.)
Sadly, macOS Mojave broke OSAX functionality, making Smile completely unusable.[*] Besides, the oh-so-rudimentary Smile UI can be pretty frustrating. It's time to seek an alternative.
The "code" doesn't have to be AppleScript. I've seen a couple of open-source (usually Qt) apps for editing TikZ, a programmatic graphics language. However, these are geared towards tweaking TikZ code for import into a LaTeX documents and whatnot; I'm looking for something more of a stand-alone document editor, capable of exporting to PDF or EPS directly. (But if there's a really good Mac-like TikZ editor, I'd consider it.)

[*] There's apparently an AppleScript workaround using an an auxiliary SatimageOSAX app, but I haven't gotten it to work with Smile. Besides, it's only a patch, doomed to break eventually.

A:

MetaPost
An open source and complete picture drawing language, with plenty of support and documentation, is MetaPost.

The MetaPost system (by John Hobby) implements a picture-drawing language very much like that of MetaFont; the difference is that MetaPost outputs vector graphic files instead of run-length-encoded bitmaps; output formats available are PostScript and SVG.

MetaPost is capable of creating complex images and shapes:

beginfig(11)
    pair A, B, C;
    A:=(0,0); B:=(1cm,0); C:=(0,1cm);
    draw A--B;
    draw B--C dashed evenly;
    draw C--A dashed withdots;

endfig;

beginfig(117)
  u:=2cm;
  pair A, B, C, D, E;
  path p, q, r;

  A = u*up;
  p := (-.2)[ A, A rotated 72 ] -- (1.2)[ A, A rotated 72 ];
  for i=0 upto 5:
    draw p rotated 72i;
  endfor;
  B := 1/2[ A, A rotated 72 ];
  C := .8*B;

  p := B --- C .. (C rotated (2*72)){right};
  % On allonge le chemin p
  p := ( (point 0 of p) - 4mm*unitvector(direction 0 of p))
       --
       (point 0 of p)
       & p &
       (point 2 of p)
       --
       ( (point 2 of p) + 4mm*unitvector(direction 2 of p));

  E = p intersectionpoint (p rotated 72);
  q := p cutbefore fullcircle scaled -2mm shifted E;
  r := p cutafter fullcircle scaled  2mm shifted E;

  for i=0 upto 4:
    draw q rotated 72i;
    draw r rotated 72i;
    draw A rotated 72i withpen pencircle scaled 4bp;
    draw B rotated 72i withpen pencircle scaled 4bp;
    draw C rotated 72i withpen pencircle scaled 4bp;
  endfor;
endfig;

You can install MetaPost as part of BasicTex.
Sketch
Aimed more at designers than engineers, Sketch offers a programmable interface and AppleScript support.
Side Note
As an aside, Apple once distributed a sample vector drawing application also called Sketch. One purpose of Sketch was to demonstrate how to incorporate AppleScript into an application.

