A thin VS Code layer over the dm CLI (@datamagik/cli) — author DataMagik
scripts, SQL queries, and SPA apps locally and act against the platform without
leaving the editor.
What it adds
A DataMagik panel in the activity bar, covering the whole loop: find it, get
it, change it, test it, ship it.
- Scripts and SQL trees listing everything in the active tenant, marking
what is already in your workspace.
✓ opens the file; ☁ downloads it and
opens it. Rows match on the platform id, so a file you renamed by hand is still
recognised. + creates a new one.
- Apps tree listing the tenant's applications. A
spa app downloads a
published version's source into a new folder, so an app built months ago
can be opened again on a machine that never had it. Two versions pull side by
side and diff.
- Account view showing the two facts that decide where a command lands — the
environment and the company — each one click from changing.
- Sign in with a browser (OAuth device flow): no key to paste, and it works
with SSO. Pasting an API key is still offered.
- Switch company without leaving the editor. Needs a browser sign-in; an API
key is fixed to one company for its life.
- SQL results as a grid in an editor tab — sticky headers, a filter box,
numbers aligned, NULL distinct from empty. Not a log: a log cannot scroll
sideways.
- Script results in a panel with Console and Return tabs. A failed
run still shows what it printed.
- F5 to debug an app — launch configurations are contributed per app, so
there is no
launch.json to write. Starts the dev server and binds
breakpoints in your .vue sources.
- CodeLens atop
@dm-script .js files (▶ Run, ⬆ Commit, ✎ Push meta,
≡ Status) and @dm-sql .sql files (▶ Run, ⬆ Push).
- Publish —
DataMagik: Publish a new version (goes live) builds and ships a
SPA app from the editor.
dm.config.json validation — schema-backed completion and inline errors,
so a typo surfaces before a publish rejects it.
@datamagik/ui components — 45 of them, browsable and insertable, read
from your workspace's own copy so the versions always match.
- An Output channel streaming
dm output, and the integrated terminal for
interactive commands.
SQL results
▶ Run on a @dm-sql file sends it to the engine's read-only test-run and
opens the result set as a grid in an editor tab beside the query:
✓ 6 rows in 2284ms
┌────────────────────────┬──────────┬──────────┬──────────────┐
│ Part_No │ Part_Key │ Revision │ Name │
├────────────────────────┼──────────┼──────────┼──────────────┤
│ MATL │ 0 │ 0 │ Raw Material │
│ 72963-TA0 │ 556851 │ │ Collar │
│ 84400SWA A014M1 NH661L │ 957057 │ │ Grey Shelf │
└────────────────────────┴──────────┴──────────┴──────────────┘
Numeric columns right-align. An empty string renders blank and a NULL renders as
NULL, so the two are never confused.
The grid has a filter box for narrowing rows without re-running the query. To get
them out of the editor, dm sql run in a terminal also takes --out results.csv
(or .json), --format csv for piping, and --max-rows <n> to cap a large
terminal grid. The CSV export neutralises spreadsheet
formula injection, so a cell beginning = or @ cannot execute when the file is
opened in Excel.
Needs @datamagik/cli 0.3.6 or newer; the default npx --yes @datamagik/cli
always fetches a current one.
How it works
Every action shells the dm CLI (@datamagik/cli), so behavior matches the
terminal exactly. Read-only/output actions (run, status, pull, typegen, push, commit)
stream to the Output channel; add and dev run in a terminal. Files are saved
before a run so the engine sees your latest edits.
Requirements
- Nothing. The
dm CLI ships inside the extension and runs on the Node.js
runtime VS Code already has — no install, and no npm registry access.
(dm dev runs your project's Vite, so that needs your own Node 20+.)
- Log in once (status bar → log in) to store credentials for the tenant.
Settings
datamagik.cliCommand (default: empty) — how to invoke the CLI. Empty
means the bundled one. Set it to dm if you have it on your PATH, to an
absolute path, or to npx --yes @datamagik/cli@latest for the published CLI.
It is machine-scoped: a workspace's .vscode/settings.json cannot set it,
so opening an untrusted repository cannot redirect the CLI at an arbitrary
binary.
datamagik.caCertPath (default: empty) — a PEM of extra certificate
authorities to trust, for a machine behind TLS inspection.
Node ships its own frozen list of roots and never reads the operating system's
certificate store, so a corporate proxy's root that every browser trusts is
invisible to it and commands fail with unable to verify leaf signature. On
Windows the extension exports the OS root stores itself, so this is usually
unnecessary. It is passed as NODE_EXTRA_CA_CERTS, which adds to the
built-in roots and disables no verification.
Testing
npm test runs the unit suite against a stub of the vscode module.
npm run test:integration runs a second suite inside a real VS Code extension
host, which is where the claim this extension depends on gets checked rather
than argued: the CLI ships inside the VSIX and runs on VS Code's own runtime,
which needs Electron to behave as Node. VS Code can gate that behind the
runAsNode fuse, and where it is gated a bare spawn opens a second editor
window instead of running the script — so the code uses fork(), and this is
the proof. It also covers activation, command registration, the configuration
the host actually resolves, and that a terminal command harms no other terminal.
It needs a display and an installed VS Code (set VSCODE_BIN if it is somewhere
unusual), so it is a local gate rather than a CI one. It uses a throwaway
profile and never touches yours.
Something not working?
Run DataMagik: Diagnose Setup from the command palette. It reports the
runtime, the CLI it resolved, the certificates in play, and whether this machine
can verify the platform's TLS chain — which is what a corporate proxy breaks.