Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .github/social-preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 36 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Relay Forms
<p align="center">
<img src="./docs/assets/banner.png" alt="Relay Forms" width="100%">
</p>

Relay Forms builds the setup flows of command-line tools: single prompts, multi-step wizards, and editors for configuration files. Forms render in the normal terminal rather than a full screen, so the answers stay in the scrollback after the flow finishes.

Expand All @@ -9,12 +11,15 @@ npm install
npm run demo
```

The demonstration asks the questions of a project setup flow and prints the answers. To print its first screen without waiting for input:
The demo asks the questions of a project setup flow and prints the answers. It writes nothing to disk. Two more demonstrations show the other parts of the package:

```sh
npx tsx src/cli.tsx --demo --snapshot
npm run demo -- wizard
npm run demo -- config
```

`wizard` splits the same flow into steps with a review screen, and `config` opens a sample settings document in the configuration editor. Add `--snapshot` to print the first screen of any demonstration and exit.

## Ask questions

`askAll` asks a list of fields in order and resolves with the answers, keyed by field name. Answered questions stay in the terminal as a summary, and Esc returns to the previous question.
Expand Down Expand Up @@ -80,6 +85,21 @@ const {saved, changes} = await editConfig('./service.json', [

Run `npm run demo -- config` to try it on a sample document. See [the configuration editor guide](./docs/config-editor.md).

## Keys

| Key | Action |
| -------- | ----------------------------------------------------------- |
| `Enter` | Accept the answer, or edit the selected setting |
| `Escape` | Return to the previous question, or cancel at the first one |
| `↑`, `↓` | Move through options, or between settings |
| `Space` | Toggle an option in a multiple choice |
| `y`, `n` | Answer a confirmation |
| `s` | Save the configuration editor |
| `q` | Leave the configuration editor, confirming unsaved changes |
| `Ctrl+C` | Cancel the form |

Text fields also accept `Ctrl+A`, `Ctrl+E`, `Ctrl+U`, `Ctrl+K`, and `Ctrl+W`. The complete list for each field kind is in [the prompt guide](./docs/prompts.md).

## Build your own form

`runForm` renders any Ink component where the cursor is and resolves with the value the component submits. Ctrl+C cancels it, and `runForm` then rejects with `FormCancelledError`. `Prompt`, `PromptList`, and `FormFrame` are ordinary components, so they can be combined with your own.
Expand All @@ -94,13 +114,25 @@ const answers = await runForm<Record<string, unknown>>(({submit, cancel}) => (
));
```

## Documentation

- [Prompts](./docs/prompts.md)
- [Wizards](./docs/wizard.md)
- [Configuration editor](./docs/config-editor.md)
- [Architecture](./docs/architecture.md)

## Scope

This release covers questions asked while a tool is set up or reconfigured. Full-screen layouts belong in Relay Shell, and the configuration editor reads and writes JSON files.

## Development

```sh
npm install
npm run check
```

Relay Forms requires Node.js 22 or newer. See [the architecture notes](./docs/architecture.md) and [CONTRIBUTING.md](./CONTRIBUTING.md).
`npm run check` verifies formatting, linting, strict types, tests, and the distributable package. Relay Forms requires Node.js 22 or newer. See [CONTRIBUTING.md](./CONTRIBUTING.md).

## License

Expand Down
15 changes: 15 additions & 0 deletions docs/assets/ARTWORK.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Relay Forms artwork

The banner and social preview follow the direction of the other Relay repositories: the official Relay mark and the product name on the left, and the real interface drawn as terminal panels on the right.

## Banner

`banner.png` uses a 3:1 composition (2172 × 724). The left side holds the Relay mark, the product name, and a one-line description. The right side shows the three parts of the package as they appear in the terminal: the progress row of a wizard, a single-choice prompt with a disabled option, and an unsaved setting in the configuration editor.

## Social preview

`.github/social-preview.png` recomposes the same panels for a 2:1 thumbnail (1774 × 887). The description is removed and the product name is enlarged so it stays readable in repository cards.

## How it was made

Both images were laid out as HTML with the shared Relay palette (background `#080B0F`, text `#E8EDF2`, muted `#84909C`, blue `#48A8FF`, orange `#FF8A3D`, green `#4FD18B`, yellow `#F0C84B`) and rendered with headless Chrome. The mark is the official one from the Relay organization profile. The panel text is taken from the demonstrations, so the artwork shows what the package actually draws. Avoid decorative code, robots, and generic terminal imagery in future versions.
Binary file added docs/assets/banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading