← Catalog

pi-galley

Set Pi's chat in a readable measure on wide terminals, with tool output, input, and footer free to run full width

Package

Install

Install with PiG

pig install npm:pi-galley

Install with Pi

pi install npm:pi-galley
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./extension.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 0.2.0 (README.md). PiG does not review it.

pi-galley

Set Pi's chat in a readable measure on wide terminals, with tool output, input, and footer free to run full width.

A galley is a long single column of set type. pi-galley keeps the transcript's prose to a comfortable line length (the measure) while the parts of the screen that read better wide, such as logs, diffs, and the status footer, keep the whole terminal.

Install

pi install npm:pi-galley

Restart Pi, or run /reload in existing sessions.

Settings

CommandEffect
/galley 100Set the measure in cells (20 or more).
/galley offTurn the galley off; everything runs full width.
/galley leftSet the galley flush left (ragged right).
/galley centerCenter the galley.
/galley tools fullRun tool calls and ! command output full width.
/galley input fullRun the input editor full width.
/galley footer fullRun the footer full width.
/galley tools columnSet tool output in the galley. Same for input and footer.
/galleyShow the current settings.

Defaults: a 120-cell measure, flush left, with tool output, input, and footer full width. Commands save to pi-galley.json in Pi's agent directory (~/.pi/agent unless PI_CODING_AGENT_DIR points elsewhere).

Environment variables override the saved settings for one launch:

VariableValues
PI_GALLEY_MEASURE0 (off) or a whole number of 20 or more
PI_GALLEY_ALIGNleft or center
PI_GALLEY_TOOLSfull or column
PI_GALLEY_INPUTfull or column
PI_GALLEY_FOOTERfull or column

Wide diagrams

Mermaid diagrams wider than the measure break out to the width they need, so Pi can still draw them. The prose around them stays in the galley.

For extension authors

Extensions can cooperate with pi-galley without depending on it. The hooks use global symbols, so they do nothing when pi-galley is not installed.

  • Set component[Symbol.for("pi-galley.full-width")] = true on a component your message or tool renderer returns. pi-galley leaves the transcript block that contains it at the full terminal width.

  • Call globalThis[Symbol.for("pi-galley.measure")]?.() at render time for the current measure in cells. It returns 0 when the galley is off, and the function is absent when pi-galley is not loaded.

  • Set component[Symbol.for("pi-galley.image-width")] on a component your tool's renderCall or renderResult returns, to size the images Pi draws below that tool's block:

    • "natural" draws each image at its own size: one image pixel per terminal pixel, from the cell size the terminal reports. Pi places images on whole cells, so the image shrinks to fit a whole number of them rather than growing. The exception is an image narrower than one cell, which is drawn one cell wide. The image shrinks further only to fit its block.
    • A positive number caps the width at that many cells, with Pi's usual scaling.

    An image never runs wider than its tool's block. Under /galley tools column the block sits in the galley, so add the full-width mark to give the images the whole terminal. Without the hint, Pi's terminal.imageWidthCells setting applies.

A chat-style extension can combine the first two: run its block full width, cap its bubbles at the measure, and put them against the left and right edges.

Scope and limitations

  • Terminals lay text out on a grid of equal-width cells, so pi-galley controls line length and placement, not fonts.
  • The input setting covers the whole editor slot, including selectors and dialogs that replace the editor. Extension widgets above and below the editor stay in the galley.
  • pi-galley wraps Pi's interactive components at render time. A Pi release that restructures those components can break it until pi-galley catches up.

Credits

pi-galley began as a fork of Adam Chmara's pi-centered, which contributed the column rendering and the Mermaid breakout.

Contributing

See CONTRIBUTING.md.

License

MIT. See LICENSE.