plugin

package
v0.5.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package plugin starts the programs docs/PLUGINS.md describes: `jaira <id>` runs ~/.jaira/plugins/<id>/jaira-<id>, and a write a plugin subscribed to runs `jaira-<id> event <name>`.

What runs is only what sits in the plugins directory. jaira never searches PATH for a jaira-<id>: a program somebody dropped on PATH is not a plugin a person chose to install, and the directory is the whitelist.

Index

Constants

View Source
const InEventVar = "JAIRA_IN_EVENT"

InEventVar is set to "1" for a plugin run by an event. A write made from inside one fires no events, or a plugin that answers a set with a set — or two plugins answering each other — would never stop.

Variables

This section is empty.

Functions

func Dir

func Dir() string

Dir is where installed plugins live: plugins/ beside settings.json, which is JAIRA_HOME when that is set, so tests and a sandboxed run never reach the real one.

func Fire

func Fire(ids []string, event string, payload []byte, env Env)

Fire runs `jaira-<id> event <name>` for each of ids — what Subscribers returned — one after the other, with payload on stdin. Nothing about a plugin's run reaches the caller: the write has already happened, so a plugin that fails, times out or is missing changes nothing about the command's result. Its output is discarded, as a hook's is, so it never mixes into JSON an agent is parsing.

func Program

func Program(id string) string

Program is the path of id's program, or "" when id is not a well-formed id or no such plugin is installed.

func Run

func Run(prog string, args []string, env Env) (int, error)

Run starts prog with args on jaira's own stdin, stdout and stderr, in the directory jaira was started in, and returns the plugin's exit code. The error is only for a program that could not be started at all.

func Subscribers

func Subscribers(event string) []string

Subscribers are the ids of the installed plugins whose manifest names event, in order of their ids. A plugin without a readable manifest, or whose manifest names another id, hears nothing: the manifest is the subscription.

Inside an event — JAIRA_IN_EVENT=1 — there are none, so a write a plugin makes from its own event calls nobody.

Types

type Env

type Env struct {
	// Root is the directory holding .jaira/, "" outside a repository.
	Root string
	// Board is the board the call works on, "default" for today's.
	Board string
	// Version is the running jaira's version.
	Version string
}

Env is what a plugin is told about the call, in the three variables the standard names.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL