Search
One component, any provider
<Search> yields its parts: the input, the results, the highlights, the
facets, the pages, and the empty and error states. The parts use Joinery components. Each
provider is one small package, so one line changes the search engine.
import { defineIndex, defineScribe } from '@scribe-ts/core'
import { typesense } from '@scribe-ts/typesense'
import { Search } from '@scribe-ts/ember'
const books = defineIndex<Book>()({
name: 'books',
searchable: ['title', 'author'],
facets: ['genre'],
})
const scribe = defineScribe({ books: typesense({ url, key }) })
<template>
<Search @provider={{scribe.books}} @index={{books}} as |s|>
<s.Input placeholder="Search books" />
<s.Facets @field="genre" @label="Genre" />
<s.Results as |hit|>
<s.Hit><s.Highlight @hit={{hit}} @field="title" /></s.Hit>
</s.Results>
<s.Empty /> <s.Error /> <s.Pagination />
</Search>
</template>
Eight providers
-
Typesense, Meilisearch, Algolia, Elasticsearch and OpenSearch. Each
adapter calls the REST API of the engine with
fetch, with no SDK. -
Postgres. Full-text search with typo matches, BM25 (ParadeDB, or Neon
lakebase_text), pgvector, and hybrid search with reciprocal rank fusion. Use a Scribe server, or use PostgREST or the Neon Data API with no server. - In the browser. Orama or MiniSearch, with no network.
-
Pinecone for vectors. You give the
embed()function.
Each adapter passes one conformance suite, which CI runs against the real engines in Docker. The demo above uses four providers on the same books.
Keys stay on the server
A server package mints scoped keys: Algolia secured keys, Typesense scoped keys and
Meilisearch tenant tokens. The key holds the filter of your policy, so each user finds
only the permitted records. Each adapter also accepts a proxy baseUrl.
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),
})
- Sections and ranking: recent commands first, then the commands of the page, "Go to", search hits and the app commands. A built-in fuzzy scorer ranks them.
- Key bindings: a text field keeps its keys, and each surface of a page has its own keys. If two commands use one key, the command with the most context wins. The cheatsheet shows all keys.
- Undo and history: local commands and server commands go on one undo stack. The history panel shows each entry. If a newer change blocks an undo, the panel shows the cause.
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.
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)
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.
- Guide: each package, each provider and each server.
- Stories: each component has a story, made with Jig.
- Source on GitHub.
- llms.txt, the rules for AI coding agents.