Skip to content

feat(plugin): add formatter host fallback - #448

Open
natalie-o-perret wants to merge 1 commit into
rest-sh:mainfrom
natalie-o-perret:feat/formatter-host-fallback
Open

natalie-o-perret wants to merge 1 commit into
rest-sh:mainfrom
natalie-o-perret:feat/formatter-host-fallback

Conversation

@natalie-o-perret

@natalie-o-perret natalie-o-perret commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • adds opt-in formatter.host_fallback support for formatter plugins
  • keeps asynchronous formatter output available for live redraws and animation
  • lets a plugin delegate an individual response or stream item to Restish's native auto formatter

Wire contract

A plugin requiring formatter.host_fallback writes formatter-output CBOR messages instead of raw stdout. data frames may arrive asynchronously. Each request ends with one matching request_id and complete: true. Setting fallback: true on that completion renders the request body through auto, including native indentation, highlighting, and theme handling.

Existing formatter plugins keep the raw stdout protocol unchanged.

Behavior

On main, the fixture is rejected because the host does not know the required feature:

$ RSH_CONFIG_DIR=/tmp/restish-fallback/config ./restish plugin install ./restish-test-fallback --yes
install: plugin restish-test-fallback: manifest requires unsupported feature "formatter.host_fallback"

I built this branch and the checked-in fixture, then served one local JSON response:

$ go build -o /tmp/restish-fallback/restish ./cmd/restish
$ go build -o /tmp/restish-fallback/restish-test-fallback ./internal/output/testdata/fallbackfmt
$ RSH_CONFIG_DIR=/tmp/restish-fallback/config /tmp/restish-fallback/restish plugin install /tmp/restish-fallback/restish-test-fallback --yes
$ mkdir -p /tmp/restish-fallback/response
$ printf '%s\n' '{"message":"cannot match command"}' > /tmp/restish-fallback/response/error.json
$ python3 -m http.server 18777 --bind 127.0.0.1 --directory /tmp/restish-fallback/response
$ RSH_CONFIG_DIR=/tmp/restish-fallback/config /tmp/restish-fallback/restish get http://127.0.0.1:18777/error.json -o testfallback --rsh-print b
{
  "message": "cannot match command"
}

Using --rsh-print bc in a terminal also applies the configured native Restish colours.


Note

AI assistance: protocol design, test scaffolding, documentation, PR description.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant