Shoddy Documentation

VS Code

Highlighting, snippets, debugging and mill commands, with a Run button

This page covers everything about writing Shoddy in VS Code: installing the extension, its commands, native debugging (the perch, Shoddy's debugger), and the one environment detail worth understanding. An extension is an add-on package that teaches VS Code something new; here, a whole language. This one carries its own mill (the program that compiles and runs Shoddy) and machines, so the only prerequisite is the .NET 10 runtime: Setup, Track A, two steps.

Only two sections here ask you to do anything: installing the extension (required, once) and the smoke test (recommended, a minute). Everything else is either optional, with its trigger stated on the section, plain usage (§3 to §4, §6), or background (§5).

Key note. Shortcuts are written Cmd+… / Ctrl+…: macOS uses Cmd, Windows and Linux use Ctrl. Everything else on this page is identical on every platform.

1. Install the extension Required · once

Shoddy has its own extension, and it provides:

It also carries a complete toolchain, every tool needed to build and run Shoddy. A mill and every machine ship inside the package, so installing it is the whole install. Download the latest .vsix from the latest release (one package, every platform), then in VS Code: Extensions view → ··· menu → Install from VSIX… → pick the file you downloaded. Reload when prompted.

The bundled mill is portable .NET: mill.exe on Windows, and dotnet mill.dll everywhere else, through the runtime Setup had you install. The machines travel with it. That is why a bare Include "seq.shoddy" resolves in any folder you open, with nothing set.

Optional, only if you have edited the extension: repackage from the repo root, which stages a fresh mill and freshly built machines into the package first:

./build.sh vsix          # ./build.ps1 vsix on Windows

Optional, only if you are developing the extension: to iterate without packaging at all, open the vscode-shoddy/ folder in VS Code and press F5. That launches an Extension Development Host, a second VS Code window with your edited extension loaded.

Tip If GitHub Copilot is in this window too, spend five more minutes on Grounding an Assistant. Copilot has never read a line of Shoddy and will write you BASIC unless a .github/copilot-instructions.md tells it otherwise. That page has the file to copy.

2. Point it at the mill Optional

The extension looks for a mill in four places, in order: the shoddy.millPath setting; the mill your workspace has built, at artifacts/bin/Shoddy.Mill/release/mill under the folder you have open (mill.exe on Windows); its own bundled copy; then mill on your PATH, the list of folders your terminal searches for commands. The bundled copy means almost everyone can skip this section.

The one ordering to know: a workspace's own built mill beats the bundled one. That is deliberate. When the repo is your open folder, the mill you just built is the one you want tested, not the one that shipped. Set millPath explicitly in two cases: you keep several checkouts (separate copies of the repository) and want the editor pinned to one regardless of which is open, or something else named mill hides the real one.

If you do set it, set it in User settings, not per-workspace. Then every folder you ever open, inside the repo or out, finds it with no per-folder setup: Ctrl+Shift+P / Cmd+Shift+P → Preferences: Open User Settings (JSON), then add:

"shoddy.millPath": "C:\\github\\shoddy\\artifacts\\bin\\Shoddy.Mill\\release\\mill.exe"

(macOS/Linux: the full absolute path to the built mill. Do not rely on ~ expanding inside settings.)

Whichever mill answers, keep the editor at four spaces for .shoddy files: Shoddy's blocks are indentation-based (a tab counts as 4) and the whole corpus uses 4 spaces.

3. Debugging: the perch Usage · nothing to configure

Start here: it is the fastest way to see the whole chain working, and it needs no configuration. Shoddy has native debugging: running your program one line at a time while you watch what it does. In mill vocabulary the debugger is the perch, the place where woven cloth was inspected for flaws. Open any .shoddy file and press F5: no launch.json needed. The program compiles with debug instrumentation (the extra bookkeeping that lets the debugger watch each line). It is the same program mill run builds, machines and all, and it runs until it reaches a breakpoint, as a C# program does under the .NET debugger. If it would not compile, the launch fails with the error the runner gives, rather than starting and dying part-way through.

The program runs exactly as it does under mill run. It gets a terminal window of its own, outside VS Code, named shoddy debug: FILE. That is the operating system's own terminal (Windows Terminal or the console on Windows, Terminal on macOS), at its full size. To use a different one, set VS Code's terminal.external.windowsExec, terminal.external.osxExec or terminal.external.linuxExec. The program reads that window's keyboard (Input, InputLine, InKey), draws on its screen (escape codes and all, so VT100 games play), opens scribbler windows and plays sound. It runs from its own folder, whichever folder the workspace is opened on, so a relative path such as files/words.txt finds the file beside the program. That is true in a checkout and out of one: the machines the extension ships are debugged the same way as the ones in the repository.

Why a window of its own: VS Code's integrated terminal keeps F1, F5 and the chord prefixes for the editor, and a game that reads the arrow keys and the function keys through InKey never sees them there. The terminal checklist records, per mill, what each one asks of a terminal and which terminals pass. The window is opened on the machine VS Code itself runs on, so a remote, WSL or container session, where the editor's window and the program's would be on different machines, cannot launch; debug on the machine that has the terminal.

Under the hood, VS Code runs mill dap as the debug adapter. The adapter asks VS Code for the window and starts the program's own process in it, mill run --perch PORT FILE, which compiles the program with the instrumented library and connects back to the adapter; from then on the adapter relays between the two. Then:

Settings for a launch

None are needed. To give a program arguments, arm the network, or run it from another folder, add a launch.json (Run → Add Configuration… → Shoddy) and set any of these:

SettingWhat it does
programThe .shoddy file to debug. Default: the one you are editing.
argsThe program's arguments, what Args() answers: ["words.txt", "42"] is mill run FILE words.txt 42.
allowNettrue arms the network, as mill run --allow-net does.
cwdThe folder the program runs from. Default: the program's own folder. A relative one is taken against the workspace folder.
stopOnEntrytrue stops on the first line that runs. That is a top-level Let in an included file when there is one, since those run before Main. Off by default.
{
    "type": "shoddy",
    "request": "launch",
    "name": "Burler, seeded",
    "program": "${workspaceFolder}/burler.shoddy",
    "args": ["files/words.txt", "42"]
}

There is no console setting. A program being debugged always runs in a terminal window of its own, and a launch that names console is refused with a message saying to remove it.

The extension's Run, Weave, Build Machine and Show Generated C# commands run from the program's folder too.

4. Run, weave, build inside VS Code Usage · nothing to configure

The extension's four commands work on the .shoddy file you are editing, in any folder, inside a checkout or out of one. Right-click in the file to find them, or open the Command Palette (Cmd+Shift+P / Ctrl+Shift+P) and type “Shoddy”.

CommandWhat it does
Run File (ctrl+r, or the ▶ button)Runs the program with mill run in a terminal window of its own. The same as Run → Run Without Debugging (Ctrl+F5).
Weave File (compile)Compiles the program to FILE.dll beside the source, a program that later runs anywhere .NET runs (the Toolchain page says how). Scribbler-window programs run only under mill run, so weave console programs.
Build Machine from FileCompiles a machine to Shoddy.Machines.<Name>.dll in the bin/ folder beside its source. Run and weave link against it from then on.
Show Generated C#Opens the C# the weave produces, to read.

Work on the mill itself happens at the command line, with the build wrapper: ./build.sh build builds the mill under artifacts/, and ./build.sh test proves it still passes (./build.ps1 on Windows). The Toolchain page lists every command.

5. How the extension sees your environment Background · no action

Nothing to configure here. This section explains what the extension does with SHODDYLIB on your behalf, and matters only if you decide to set one yourself.

The extension invokes mill five different ways (Run, Weave, Machine, Show Generated C#, and F5 Debug), and they do not all receive environment variables the same way. (An environment variable is a named setting the operating system hands to a program when it starts.) Weave and Machine go through VS Code's integrated terminal, which picks up terminal.integrated.env.* from workspace settings. Run and F5 Debug open a terminal window of the operating system's own, and Show Generated C# runs the mill directly from the extension host (the background process that runs extensions). Those three inherit only the environment the VS Code process itself was launched with, plus what the extension adds. That split is a trap: a SHODDYLIB set in workspace settings makes Weave work while silently breaking Run and F5 on the first Include-using program.

The extension now closes that gap itself. It points SHODDYLIB at its own bundled machines by both routes at once (a terminal environment collection for the terminal commands, and an explicit environment for the two processes it spawns), so all five behave identically with no setup.

If you set SHODDYLIB yourself, the extension uses yours everywhere. Set it where the VS Code process will see it: a User environment variable on Windows, a shell-profile export on macOS (VS Code resolves your login-shell environment at launch, Dock launches included). Then restart VS Code fully (macOS: Cmd+Q, relaunch), because a program copies its environment variables once, at launch. Setting it in a workspace's terminal.integrated.env reopens exactly the split described above, so do not.

One other environment variable the mill reads: SHODDY_LINT, set to anything, turns on the weave-time accessor-shadowing warning. The same launch rules apply: set it where the VS Code process will see it if you want F5 and ▶ Run to lint alike. What it warns about, and why it is off by default, is on the Toolchain page.

6. Interactive programs Usage · nothing to configure

Run File and F5 both give the program a terminal window of its own (section 3), so programs that use Input or InKey work as they are. Run tst/gradebook.shoddy with ctrl+r and type at the prompts. To replay its scripted session instead (a command-line matter, the only one on this page):

./build.sh run tst/gradebook.shoddy < tst/golden/gradebook.in

7. Smoke-test the whole chain Recommended · once

Do this once after installing the extension, and again whenever SHODDYLIB or millPath changes, or a mill you build yourself moves. Use a scratch folder outside any checkout. That is the real test: it proves a program folder anywhere on disk will work, not just files inside the source tree.

  1. Create check.shoddy in a scratch folder:
    Include "stats.shoddy"
    
    Def Main()
        Print(Sum({ 1, 2, 3 }))
  2. Open the folder in VS Code and run it with the ▶ Run button. Expect 6, not unknown word: Sum or a “cannot open” error.
  3. Press F5 on the same file and confirm it also runs clean under the debugger. With the ▶ Run step, this catches the environment gap from section 5 before it surprises you mid-program.
  4. Delete the scratch folder once both pass.

8. Troubleshooting As needed

Editor-side symptoms. If the command line is broken too, start with Setup's troubleshooting instead. Fix the machine before the editor.

SymptomLikely cause
Works on Weave File but fails on ▶ (Run), F5 or “Show Generated C#” A SHODDYLIB of your own was set only in a workspace's terminal.integrated.env, which only the integrated terminal sees. See section 5
unknown word: Sum (or any library word) on Run and F5 alike A SHODDYLIB left over from an older install points somewhere that no longer holds the machines. It overrides the bundled ones. Clear it and fully restart VS Code (macOS: Cmd+Q). With it unset the extension supplies its own
macOS: works when VS Code is launched from a terminal (code .) but not from the Dock Only possible with a SHODDYLIB or PATH of your own: the login-shell environment was not resolved. Keep the export in ~/.zshrc or ~/.zprofile and fully relaunch, or drop it and let the bundled toolchain answer, which no Dock launch can miss
“The framework Microsoft.NETCore.App version 10 was not found” The .NET 10 runtime is not installed, or VS Code predates the install. Setup step A1, then restart VS Code
Mill not found at all All four lookups missed, which normally means the package was built without its mill staged. Check shoddy.millPath is not set to a stale path (it is checked first, and a wrong value beats the bundled copy), then reinstall the .vsix from the Releases page