Skip to content

[Feature Request] Shared runtime or global variables between javascript blocks #965

@flooweb214

Description

@flooweb214

Summary

Runme currently isolates each JavaScript block in its own process, which prevents variables or state from being shared across blocks. The only available mechanism is to pass data through environment variables (always as strings), which requires manual serialization/deserialization and makes even simple workflows unnecessarily complex.

💡 Problem

Runme is designed to break workflows into small, readable blocks — which is great.
However, this design becomes restrictive when we need to exchange structured data (arrays, objects) between JS blocks.
Example:

// Block 1
const stores = [1, 2, 3];

There is no way to access stores from a second JS block without:

  1. Writing the value to stdout
  2. Naming the block in ALL CAPS so it becomes an env var
  3. Reading it back with process.env.XYZ
  4. Calling JSON.parse manually
const stores = JSON.parse(process.env.STORES);

This is confusing, error-prone, and breaks the nice development ergonomics that Runme otherwise provides.

❗ Why This Is a Problem

  • Environment variables only support strings, so structured data is always lost unless manually serialized.
  • The name: "VAR" mechanism feels like a hack rather than a proper API.
  • It forces users to write extra boilerplate for something that should feel natural in a notebook-style environment.
  • For JS workflows, this is a significant productivity penalty.
    Runme helps simplify workflows — but passing data between blocks becomes more difficult, not easier.

🎯 Requested Feature: Shared State or Global Context

I would like Runme to support one of the following:

Option A — A shared JS runtime

Similar to how Jupyter notebooks keep a persistent kernel.
JS blocks would share variable scope or at least a global context.

Option B — Built-in serialization for env variables

If a block output is valid JSON, Runme should automatically expose the parsed value to JS blocks, not only the raw string.
Example:

```json {"name": "STORES"}
[1, 2, 3]



Then in a JS block:

```js
console.log(STORES); // → [1, 2, 3], already parsed

Option C — A Runme API

Something like:

runme.set("stores", [1, 2, 3]);
const stores = runme.get("stores");

This would avoid abusing env variables and would feel natural for notebook-style development.

🙏 Why This Matters

Runme is a great tool for orchestrating step-by-step workflows, but lack of shared state between JS blocks makes certain workflows unnecessarily painful:

  • data pipelines
  • DevOps automation scripts
  • API testing
  • multi-step generation of objects
  • combining shell and JS in the same document
    Having a clean, native way to share structured data would drastically improve developer experience.

✔️ Expected Benefits

  • Cleaner notebooks
  • Less boilerplate
  • More intuitive mental model
  • Better parity with notebooks like Jupyter
  • More adoptable for JS/TS-heavy teams

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions