Modules
PiFi’s core knows four kinds of thing that come in more than one variety. A module is the code that adds one variety.
| Family | The question it answers | Built in | Where its modules run |
|---|---|---|---|
| Host | Where does the work run? | A machine running the host agent | On that machine |
| Client | Where do you look at it? | The web app, the phone and the CLI; herdr and tmux as client modules | On the client’s machine, signed in as a device |
| Scope | What work is it? | Projects you choose; GitHub issues and Projects boards | Coordinator-side catalog worker (@pifi/catalog-github) with a GitHub App or PAT |
| Trigger | What starts unattended work? | Cron, once, webhook, and another task finishing | Wherever the caller is: a trigger is an HTTP request or a schedule |
Hosts, clients and scopes are in the model; triggers start automations (spec.md).
Module, plugin, adapter
Three words, one rule each:
- A module plugs into PiFi. It adds a kind of host, client, scope or trigger.
- A plugin plugs into another program: a Pi plugin, a herdr plugin, a tmux plugin. PiFi has no plugins of its own. A module can contain one: the herdr client module is a herdr plugin (
modules/herdr) plus a daemon in the PiFi CLI. - An adapter translates between one Pi plugin and PiFi: it turns that plugin’s dialogs and state into portable UI (adapters.md). The plugin owns it.
What belongs to core and what to each of these is the ownership contract.
Where modules run
The coordinator never runs code: it keeps state, decides what runs where and relays. So a module is never loaded into it. A module is a process somewhere else that speaks one of the coordinator’s contracts, with its own revocable credential:
- a client module runs on the machine it shows things on and signs in as a device (
pifi login); - the GitHub catalog worker (
@pifi/catalog-github) runs alongside the coordinator in an isolated IPC process and holds GitHub App or PAT credentials in the coordinator data directory; - a trigger module is whatever sends the request: another service, a CI job, a cron line.
Core never branches on a kind’s name. It records what a module reports and what you chose for it, and it asks about capabilities (a host’s features, a client’s capabilities in its hello), not about who is asking. With a module absent, everything else works: without the GitHub module a scope is projects you choose, and without a client module there is the web app.
What another project can write today
A trigger. This contract is open and stable. Create an automation with a webhook trigger, and send POST /api/hooks/<automationId> with the automation’s bearer token and a JSON body. The automation’s filters match dot-paths of the body, and its task template substitutes {{payload.<dot.path>}}, so a service that already sends webhooks needs only a target URL and a token (operations.md). A retried delivery with the same Idempotency-Key is one occurrence.
A client. Nearly open. The herdr and tmux modules use nothing but the public API, and a module for another multiplexer can do the same:
- sign in as a device (
pifi login, or the device enrollment API); - report each session it runs in with
PUT /api/clients/<kind>:<name>@<machine>and a body ofkind,name,machineand the sessions itshows; any lowercasekindis accepted; optionally setPIFI_CLIENT_ID(<kind>:<name>or<kind>:<name>@<machine>) andPIFI_PANE_IDin panes so user-started Pi sessions enrol under that client without multiplexer-specific code inpi-runtime; - read what the client mirrors from the synced state (
clientsandscopesover/ws/client, with the capabilityscopes.v1), never from its name; - show a session by running
pifi tui <session>in a pane, and open work withPOST /api/branches/open.
What is not shared yet is the logic that decides which sessions a mirror opens (one tab per active branch): it lives in the CLI (packages/cli/src/mirror), not in the client SDK.
A host. The host agent’s protocol is the contract, and there is one implementation of it. Nothing yet lets a module create, wake or destroy a host on demand, which is what a sandbox or cloud host would need.
A scope. Not yet. GitHub is the only source, served by the coordinator-side @pifi/catalog-github worker behind RepositoryProvider (with GitHub’s shapes in the protocol). A generalized contract for scope sources waits for a second provider to shape it.