Scribe

Search and a command palette for Ember.

One <Search> component with providers that you can change. A command palette with steps, a preview pane, key bindings, undo and history. Command servers for Rails, Django, FastAPI, Next.js, Node and Laravel, with one protocol and one conformance suite.

pnpm add @scribe-ts/core @scribe-ts/ember @scribe-ts/palette

Ember 6.12 or later, Vite and Embroider.

The live demo runs on a free Neon project with 212 public-domain books from Project Gutenberg. Change the provider, search by meaning, and press ⌘K. Each visitor has a shelf that you can undo. The shelves go empty each night.

Command palette

Commands, keys, steps and undo

Define a command in a module. The {{commandContext}} modifier gives it context from the DOM. ⌘K opens the palette. A command can ask for arguments in steps, with a preview pane. The options of a step come from a function, a search provider or the server.

import { defineCommand } from '@scribe-ts/palette'

export const pin = defineCommand({
  id: 'note.pin',
  title: 'Pin the note',
  keys: ['Mod+P'],   // ⌘P on macOS, Ctrl+P elsewhere
  needs: ['note'],   // shows only when the context has a note
  run: ({ context }) => notes.pin(context.note),
  undo: (_result, { context }) => notes.unpin(context.note),
})

Guide: the palette

Servers

Your back end, its own idiom

The server lists the permitted commands, gives the options of each step and runs the commands. It logs each write for undo and redo. A long command is a job that the palette polls. The protocol is JSON:API, and one conformance suite checks the six servers over HTTP.

# Rails
class RenameNote < Scribe::Command
  id "note.rename"
  title "Rename the note"
  needs :note
  arguments type: "object", properties: { title: { type: "string", maxLength: 80 } }, required: ["title"]
  undoable
  policy NotePolicy, :update?

  def call
    note = Note.find(context["note"])
    check_version!(note) # If-Match
    before = note.attributes
    note.update!(title: arguments["title"])
    record(note, before, note.attributes)
    nil
  end
end
# Django (FastAPI has the same decorator)
@command("note.rename", "Rename the note", needs=["note"], undoable=True,
         arguments={"type": "object", "properties": {"title": TITLE}, "required": ["title"]})
def rename(ctx: RunContext) -> None:
    note = Note.objects.get(pk=ctx.context["note"])
    check_version(note)
    before = snapshot(note)
    note.title = ctx.args["title"]
    note.version += 1
    note.save()
    record(note, before, snapshot(note))

Node has defineCommand() with adapters for Express, Fastify, Hono and Next.js. Laravel has a command class and a service provider. Each server also has the Postgres search endpoint, scoped search keys and an indexer for each engine.

Guide: servers

Get started

Install

pnpm add @scribe-ts/core @scribe-ts/ember @scribe-ts/palette @scribe-ts/commands-client
pnpm add @scribe-ts/typesense   # or meilisearch, algolia, elasticsearch, postgres, postgrest, local, pinecone
bundle add scribe-rails                    # Rails
uv add scribe-django                       # Django (or scribe-fastapi)
composer require joegaudet/scribe-laravel  # Laravel
pnpm add @scribe-ts/server @scribe-ts/hono # Node (or express, fastify, next)

Guide: installation

More

Part of the Ember Workbench

Scribe is the search and command library of the Ember Workbench. Its components use Joinery, its palette runs on a Switchyard statechart, and its tests use Harnessed.