Expand description
The Scripts workspace: one space to write the app’s custom commands and pipeline steps, in
Python or Rust. Scripts tree on the left, the editor (kitchen-ui’s CodeView: highlighting,
errors on their lines) in the middle, the run panel (output, the result, errors) under it.
A script runs against what is in front of the user: it reads one JSON object on its stdin,
{"args": …, "context": …} (the context is what the app says is shown: the image, the
selection, the table), and may print its result as JSON on its last line of output.
A few comment lines at the top say what a script is (ScriptMeta):
# kitchen: command = Count cells
# kitchen: hint = Counts the cells of the shown image
# kitchen: args = {"type": "object", "properties": {"min_area": {"type": "number"}}}
# kitchen: node = in image:image; out counts:table(// in Rust.) With command, the script becomes a command (ScriptsWorkspace::register):
in the menus, the search and an agent’s tools, its arguments the schema given. With node, it
becomes a pipeline node (ScriptsWorkspace::nodes) with typed inputs and outputs, whose
types are the app’s (ScriptsWorkspace::new takes them). Running a script is a job with a
cancel button; what it ran is reported (ScriptsEvent::Finished) for the app to record in
its session.
Structs§
- Node
Spec - A script as a pipeline node: typed ports, run by its script.
- Port
- A typed port of a script node.
- RunOutput
- What a run of a script produced.
- Script
- A script file.
- Script
Meta - What a script’s header says it is.
- Scripts
Workspace - The Scripts workspace.
Enums§
- Scripts
Event - What the workspace tells its owner.
Functions§
- default_
runner - The runner used by default: Python with
python3; Rust withrust-script(install it withcargo install rust-script). The input goes to the script’s stdin. - script_
errors - Errors on the script’s own lines in
stderr: a Python traceback’s last frame in the script (File "…/count.py", line 7) with its last line, or a Rust message (--> count.rs:7:5).