Skip to content
Sign upPro
ComposerCLI composerMenu

CLI composer (Pro)

ProIncluded in $99

A terminal style composer for coding agents: a prompt glyph, history on Up and Down, Ctrl R reverse search, and slash commands that Tab completes.

ProA coding agent in an invoicing service. Up walks history, Ctrl R finds the line about the tax column, and it runs.

Installation

$ pnpm dlx shadcn@latest add @chatcn-pro/cli-composer

Needs chatcn Pro

This command works with a Pro license, along with every Pro component.

Or start free: sign up and get three Pro components on us, with a new one every month.

Usage

tsx
import { CliComposer } from "@/components/ui/chatcn/pro/cli-composer"

<CliComposer
  history={history}
  onHistoryChange={setHistory}
  commands={[{ name: "model", description: "Switch model", args: "<name>" }]}
  context={<><span>~/code/ledger-api</span><span>main</span></>}
  onSubmit={({ text, command }) => (command ? run(command) : send(text))}
/>

It keeps the habits people already have in a shell. Up on the first line walks back through what you sent, Down on the last line walks forward, and your unsent draft is kept and comes back at the end. Ctrl R opens a search line above the input: type and the newest matching line appears with the match marked and a count; Ctrl R again goes further back, Enter or an arrow takes it, Escape puts your draft back. A / at the start lists commands in one aligned column, Up and Down move, Tab completes, and Enter runs a command that needs no arguments. Sent lines are parsed: a known command arrives as { name, args }. The optional context line carries the working directory, branch or anything else. Under it all is the free PromptInput: IME safe Enter, Shift Enter for a new line, paste, and Stop in the send footprint.

Examples

States

ProEmpty with a context line, the command list, one command left, a long multi line draft, running and disabled.

Props

PropTypeNotes
history, defaultHistory, onHistoryChangestring[]Oldest first. Uncontrolled, sent lines are appended
commandsCliCommand[]{ name, description?, args? }. args means it takes arguments
onSubmit({ text, command? }) => voidcommand is { name, args } for a known slash command
contextReactNodeA line above the input: directory, branch, changes
glyphReactNodeThe prompt glyph. Default ›
hideHintsbooleanDrop the key hints under the composer
value, defaultValue, onValueChangestringThe draft, controlled or not
status, onStop"idle" | "submitting" | "streaming", () => voidSend becomes Stop in the same footprint
disabledboolean
labelsPartial<CliComposerLabels>Every string, for translation

Keyboard

KeyAction
Up on the first line, Down on the lastWalk history. Past the newest line, your draft comes back
Ctrl RSearch history; again for an older match
Enter, Right or Left in searchTake the match
Escape or Ctrl G in searchLeave search and restore the draft
/ then Up, Down, TabChoose and complete a command
Enter, Shift EnterSend, new line. Never sends while an IME is composing
EscapeStop the running agent

Accessibility

  • While the command list is open the field is a combobox pointing at the highlighted option.
  • The search match is announced politely as it changes, and No match when nothing fits.
  • The match is drawn over the field with the query marked, while the field keeps focus and value.
  • Spellcheck, autocorrect and capitalization are off, as in a terminal.

Motion

Nothing animates: history, search and completion are all driven from the keyboard. The only motion is the search line's caret blink, which stops under reduced motion.