Skip to main content

Crate pmpx_engine

Crate pmpx_engine 

Source
Expand description

Turning an answer into a running process: resolving the program, starting it, and saying what happened.

§Who owns what

A plugin answers “what to run” and nothing else. Everything about how it runs lives here: resolving the real path, deciding which interpreter a script needs, inheriting stdio, waiting, and translating the exit status. That is why there is exactly one implementation of each of those, and why this crate is the only place a Command is built.

§Windows needs the real path

Command::new("pnpm") fails on Windows: CreateProcessW does a PATH lookup and appends .exe, and nothing else. npm, pnpm, yarn and bun are all .cmd shims there. So the real path is resolved first (resolve), and the spawn then depends on the kind: .cmd/.bat go through std::process, which builds the cmd.exe line, and .ps1 goes to pwsh -NoProfile -File. A failed resolution is a EngineError::NotFound listing the near-matching names on PATH, because “pnpm: not found” without the list is a puzzle rather than a message.

§Nothing is printed

What a run does is reported as Events. The caller decides what to do with them: the CLI turns them into --debug lines and the “pmpx -> …” announcement, and a test asserts the sequence. The process’s own stdout and stderr are inherited, so whatever the backend prints goes straight to the person – this crate never captures it.

Modules§

discovery
Project root discovery.

Structs§

Backend
A plugin that is loaded and has passed the identity check.
Call
Everything one call needs that a plugin cannot work out for itself.
Declared
What a plugin declared, and the root to read it from.
Levels
How much of a plugin’s output a run wants.
Plan
What to run, resolved from whatever a plugin answered or the project defined.
PluginIdentity
One installed plugin, as this crate sees it: what the store read from its manifest, and where it lives. No store, no version, no detection: data enough to load it.
Resolved
A resolution result.

Enums§

ChildOutput
Where a started program’s own output goes.
EngineError
A program that could not be started.
Event
Something that happened while running one command.
ProgramKind
The kind of backend executable that was resolved.

Constants§

MAX_FILES
The most files one plugin may declare. Past this the declarations are ignored, with a note – a plugin that declares hundreds of files is not doing something this channel is for.
MAX_FILE_BYTES
The most one file may contribute. A lockfile or a manifest is kilobytes; anything at this size is a mistake, and the plugin is handed the beginning rather than the lot.

Functions§

command_for
Build a Command for a Resolved kind, without running it.
resolve
Resolve the real path of a backend executable.
run
Really run it: inherit stdio, wait for it to finish, hand back its exit code verbatim.