Skip to content

Releases

v0.6.0

Choose a tag to compare

@treytomes treytomes released this 30 Nov 20:17

GRFON documents you can navigate, with the format's own reader deciding what gets a squiggle, and notebooks that run multi-line literals, answer input, and export to Markdown.

GRFON navigation and squiggles

Ctrl-click on an @group reference goes to the group's declaration, and Find All References lists the declaration and every use. The Outline shows a groups section with each group's name and the parts it holds.

A reference the reader would refuse is squiggled with the reader's own wording: a group that no groups: block declares, a group used as a part it doesn't hold (for example, a once: naming a group that holds facts), or the wrong number of arguments for the group's takes. A clause that its level doesn't have is squiggled too. The list of clauses comes from the reader itself, asked once per folder and cached until it changes, so the editor and the reader can't disagree. In a folder with no reader, only the reference squiggles apply.

The rules are tested against the reader: every services/*.grfon document is checked unchanged and then with one reference broken at a time, and the editor's squiggle has to match the reader's refusal.

Notebooks

Brackets spanning lines. A map, list or call laid out over several lines now runs in a cell just as it does in a file. Before, the REPL behind a notebook rejected an open { at the end of a line, and every line after it failed too.

Errors are reported. The interpreter's REPL prompts were hiding error lines, so a cell that failed could show as a success with the prompts in its output. Errors now end the cell and are shown in red.

input works. input("Enter a word: ") opens an input box with that prompt, and the cell's output shows the prompt and your answer, as a terminal would. Escape stops the cell.

Export to Markdown. Export MiniScript Notebook as Markdown (notebook toolbar or Command Palette) writes the open notebook as one .md file with the outputs each cell shows. Code goes in miniscript blocks, and printed text and errors in text blocks. A Mermaid diagram stays a mermaid block, which GitHub and VS Code's preview render. An SVG is saved beside the document and linked. To export without VS Code, run the notebook fresh from a terminal:

node export-notebook.js notes.msnb [out.md] [--answer <line>]...

--answer supplies input lines in order; after those, it asks in the terminal.

Fixes

The test suite passes on a checkout of the extension alone (as in CI) and on Windows. The GRFON checks no longer fail when the micro-expert documents aren't present or have CRLF line endings.

Installing

Requires VS Code 1.75 or newer. Download the .vsix below and install it with Extensions: Install from VSIX…, or from a terminal:

code --install-extension miniscript2-0.6.0.vsix

v0.5.0

Choose a tag to compare

@treytomes treytomes released this 28 Nov 02:01

Nnavigation that follows new to its class, fields and shadowed imports, imports followed across files, quick fixes beside the squiggle, the Run commands, and a Testing panel that stays current.

GRFON

A .grfon file opens as GRFON, with a TextMate grammar whose rules follow the format's own reader, lib/grfon.ms: // comments that stop at a url's ://, keys before an unescaped colon, backslash escapes, whole-token numbers and null, with true and false left as the text GRFON reads them as. The document layer over it is colored too — @group references with their arguments, ?term, $.path, and the <name> placeholders a takes: group fills. Braces, comments and indentation come from a language configuration, so // toggles and } indents the way the format does.

The grammar has a test of its own: it tokenizes sample lines and every services/*.grfon through the real tokenizer, and an editor check opens a declaration in a real VS Code and asserts the file's language and the grammar the manifest contributes.

Classes and instances

new Shape now gives a name the class's methods: completion after sq., hover, Ctrl-click, signature help and the semantic colors all read the instance the file proved, and self and super resolve through the enclosing method's class. A field a method sets with self.sides = 0 is a member of that class, so sq.sides hovers, jumps and counts as a use. A member the class does not have is a diagnostic that offers the close name.

Imports across files

import "sizes" and import "../sizes" are followed out of the file: Shift+F12 on sizes.helper lists the module's declaration and its uses, including every importing file's sizes.helper, and Rename rewrites them together. The import's quoted path is a link, and sizes. completes the module wherever the importing file sits. A name the importing file owns — a local, a parameter, a top-level name — shadows the alias there, so it is neither listed nor rewritten, and hover, Ctrl-click and the parameter popup agree with that reading.

Quick fixes

The two problems that can be repaired with certainty carry the repair: a misspelt member offers the close name, and an end that names no open block inserts the one that closes it, indented as its block.

Running

Run commands open the file in a terminal in its project folder, the file with arguments prompted for and passed as typed, the selection in a MiniScript REPL so a name one selection defines is there for the next, or a REPL on its own in the project folder. The REPL is kept until its terminal closes, and a missing interpreter is reported rather than opening a terminal.

The Testing panel

The panel merges rather than reloads: a save queues one rediscovery behind a debounce, a check that moved keeps its item and has its range moved, one that is gone leaves with its file, and each run writes the suite's own totals into the output. Only the files whose checks the panel shows are watched, and a save during a run does not start a second one.

Editor checks

npm run test:editor launches a real VS Code and asks its own commands for a hover, a completion, a diagnostic and a semantic token, and now also for the GRFON language of a .grfon document. Every provider also answers inside a notebook cell.

Installing

Requires VS Code 1.75 or newer. Attach the .vsix below with Extensions: Install from VSIX…, or from a terminal:

code --install-extension miniscript2-0.5.0.vsix

v0.4.0

Choose a tag to compare

@treytomes treytomes released this 24 Nov 14:30

Opens a .msnb file as a notebook whose cells share one MiniScript session, and lets a cell draw the diagram it built beside the text it printed.

Notebooks

A .msnb file opens the way an .ipynb does: a column of cells, each run on its own with Shift+Enter or the ▶ beside it, its output underneath. New MiniScript Notebook in the Command Palette opens one, and saving writes the .msnb beside the rest of the project. A new cell is MiniScript, and Markdown cells work as they do in any other notebook.

One session per notebook

The cells of a notebook share one interpreter process, so a name, a function or an import from one cell is there for the next:

x = 41          // first cell
print x + 1     // second cell prints 42

A cell of a single line also shows that line's value, the way the REPL echoes 1 + 1; a cell of several lines runs as one block, which has no value to echo, so write print for those. A runtime or compiler error stops that cell and is shown under it, and the session carries on with the values it already had.

Pictures

A cell can draw as well as print. notebook.mermaid(diagram) hands the lines mermaid.build(...) returns to VS Code's own Mermaid renderer, so the diagram is drawn under the cell — VS Code 1.121 or later, before which the fence shows as a code block. notebook.svg(mermaid.svg(facts, types, rules)) hands over an SVG document instead, which every version shows as a picture, since the project draws it itself. Both go through notebook.draw(mime, text), so anything with a type VS Code knows is drawn the same way, and what the cell prints is still its text output.

import "mermaid"

diagram = mermaid.build(facts, types, rules)
print diagram.join(char(10))   // the text, as always
notebook.mermaid(diagram)      // and the picture, under it

notebook.svg(mermaid.svg(facts, types, rules))   // the same diagram, drawn here

Imports and the working folder

A cell runs in the notebook's project folder, and import finds the project's modules there: MS_IMPORT_PATH defaults to the notebook's folder, <project>/src and the project folder, and an MS_IMPORT_PATH in the project's .env replaces that. A notebook has no entry script, but the session is given the notebook's own path as shellArgs before the REPL starts, and the notebook helpers are defined before the first cell runs. A loader that resolves a data file from the entry script has no script to go on, so name the file relative to the project folder — the micro-expert repository's examples/explore.msnb does exactly that with data/schema.kb, data/facts.kb and data/rules.kb.

A cell cannot read the keyboard: input would swallow the notebook's own lines, so a program that asks questions belongs in Run MiniScript File and its terminal.

Stopping, restarting and saving

The stop button kills the interpreter rather than the cell, since MiniScript cannot be interrupted part way; the next cell then starts a fresh session. Restart MiniScript Session, in the notebook toolbar, does the same deliberately. Closing the notebook ends its session, and only the cells are saved — outputs are not written to the file.

Installing

Requires VS Code 1.75 or newer. Attach the .vsix below with Extensions: Install from VSIX…, or from a terminal:

code --install-extension miniscript2-0.4.0.vsix

v0.3.0

Choose a tag to compare

@treytomes treytomes released this 24 Nov 02:20

Reads your .ms files without running them, so a name can be explained and followed from where it is used.

Hover documentation

Hover a function or method for its signature and its docstring — the first constant string in its body, the same note info(@f) reports. A function documented with a // comment above it instead shows that, and so does a variable, along with its assignment.

Ctrl-click to a definition

Ctrl-click (Cmd-click on macOS, F12 or Go to Definition) a name to jump to the line that assigns it. A name local to the function you are in wins over one defined elsewhere, and owner.name looks for a method of that name on that receiver.

The Outline

The Outline and the breadcrumb above the editor list the file's functions, methods, classes and top-level variables, with a method under its class and a nested function under the one that holds it. MiniScript declares nothing, so a symbol is whatever a line assigns — a capitalised name given a map or a new is read as a class.

Imported and workspace names

import "knowledge" makes knowledge a name for knowledge.ms, so knowledge.loadFacts reads that file, and Ctrl-clicking the string on the import line opens it. A name found in neither this file nor an imported module is looked for in the workspace's other .ms files, and Ctrl-click lists every file that defines it.

MiniScript's own names

print, s.len, xs.push(value), file.readLines(path) and the rest of the language's intrinsics are documented from its tables, and get no Ctrl-click, since there is no line to jump to. A member's type is read from the value its receiver was given, so s = "text" makes s.len the string's; when the value says nothing, every type that has that member is listed.

Hovering inside a string or a comment shows nothing: a name there is text.

Installing

Requires VS Code 1.75 or newer. Attach the .vsix below with Extensions: Install from VSIX…, or from a terminal:

code --install-extension miniscript2-0.3.0.vsix

MiniScript 2 0.2.0

Choose a tag to compare

@treytomes treytomes released this 19 Nov 14:27

Language support for MiniScript 2 in Visual Studio Code, matching the micro-expert v0.2.0 release.

  • Syntax highlighting for .ms files, plus the language configuration VS Code needs for comments and brackets.
  • A Run button that hands the active file to the MiniScript interpreter.
  • The project's 174-check suite in the Testing panel, with --filter and --file passed through to the runner.

Install the attached miniscript2-0.2.0.vsix:

code --install-extension miniscript2-0.2.0.vsix

The extension finds its interpreter through MINISCRIPT_EXE_PATH in the project's .env (the same file bootstrap writes), then miniscript on PATH.