Skip to content

[Feature request] Adding hooks such as mount and env to Extensions, and expose to the JavaScript API #2291

Description

@Niapya

Background

While Rust has the Extension trait, the JavaScript @everruns/bashkit library lacks this capability, ScriptedTool cannot be registered as a Bash instance.

While the API does provide capabilities for mounting file systems and loading environment variables (via the files, mounts, and env options), these are defined within BashOptions and can only be passed once during construction. As a result, they cannot be broken down into a reusable, publishable extension module.

Suggestion

  1. Expose a TypeScript extension API in @everruns/bashkit.
const bash = await Bash.create({ extensions: [skill] });
bash.installExtension(skill);
  1. The extension is an object containing a set of hooks responsible for mounting the file system, loading environment variables, registering commands, and other operations. Bash calls these hooks when the extension is created and each time it is executed.
class SkillExtension {
  // Initialization hook: mount the file system, load environment variables, and register commands
  onInit(ctx: ExtensionInitContext) {
    ctx.mount(/skills/my-skill”, skillData.fs);   // Mount the file system
    ctx.env(“SKILL_PATH”, /skills/my-skill”);     // Load environment variables
    ctx.command(...);
  }

  // Lifecycle hook: Before each `execute` begins
  onBeforeExecute(ctx: ExecContext) {
    // Optional preparation before each execution
  }
}

Expectations

Users should be able to create a skill extension that mounts an external S3 bucket into a virtual Bash environment during initialization, stores the mount path as an environment variable, and then creates a new command skill. This extension can be published for others to use.

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