Interactive TUI usage: multi-line input, slash commands, hotkeys, headless progress. For the internal rendering architecture (renderer, FileCompleter traversal, charWrap arithmetic), see TUI Internals (Phase 3).

Multi-line Input

You can type freely in the prompt. Press Enter to submit your message.

Pasting multi-line text: When you paste text that contains newlines, Book detects the paste burst (Enter arriving within 20 ms of the last character) and inserts a literal newline into the buffer instead of submitting. The full pasted block is submitted when you press Enter deliberately at the end.

Commands inside TUI (Slash Commands)

  • /model: Opens an interactive selector to change the active model. Falls back to a built-in model list if the API is unreachable.

  • /effort [level]: Sets reasoning effort level for the active session (session-scoped). Invoking bare opens an interactive modal effort selection screen.

  • /effort-default <level>: Sets reasoning effort level and saves it as the global default in configuration (book.json).

  • /resume: Open the full-screen session picker to resume a previous session and restore its full message history (see Session Picker below).

  • /tree: Open an interactive branch-point selector β€” pick any past message to truncate history back to that point and continue from there (see Tree β€” In-Place Branching below).

  • /fork: Fork the current session into a new session file from a selected point.

  • /compact: Compact current in-memory conversation history (runs non-blocking in the background; TUI stays responsive).

  • /skills: Show loaded skills.

  • /clear or /new: Resets the current session history and agent state.

  • /init: Run the project initialisation wizard β€” auto-detects project language and creates .bk/SYSTEM.md, .bk/tools/, and AGENTS.md with language-specific templates.

  • /quit or /exit: Closes Book.

  • /help: Displays available commands and keyboard shortcuts.

Slash command completion: Type / followed by a partial command name and press Tab to complete it. Up to 5 matching commands are shown with their descriptions. Press Escape to dismiss the completion list without clearing the input buffer.

File Attachment Completion

Type @ or # anywhere in the prompt to trigger keyboard-driven file-path completion. The overlap with slash commands is intentional β€” both share the same completion overlay.

compare @src/F          ← type @ then a partial path
                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                          β”‚   src/Foo.kt   πŸ“„ file  β”‚
                          β”‚   src/Foo2.kt  πŸ“„ file  β”‚
                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

How it works:

  1. After typing @ or #, a file completion overlay appears showing up to 8 matching entries from the current working directory.

  2. Navigate with ↑ / ↓ (arrow keys).

  3. Press Tab or Enter to apply the selected entry:

    • Directory β†’ the token updates to @dir/ and the overlay refreshes showing that directory’s children. You can keep drilling down.

    • File β†’ the token is replaced with relative/path (backtick-wrapped), signalling to the agent that this is a file reference. The overlay closes.

  4. Press Escape to dismiss the overlay without modifying the buffer.

  5. Type a space after the trigger to close the token without selecting β€” the overlay disappears and you can continue typing normally.

Filtering & exclusions:

  • Results are filtered by the text typed after @ or # (prefix match, case-sensitive).

  • Sub-directory navigation: @src/ lists the contents of src/; @src/m filters to entries starting with m inside src/.

  • Dotfiles (names starting with .) are always excluded.

  • Entries matching your project’s .gitignore are excluded (supports , *, /-anchored literals, and dir/ directory-only patterns).

  • Directories appear before files; both groups are sorted alphabetically.

  • Results are capped at 8 entries.

Tree β€” In-Place Branching

/tree opens a full-screen interactive message selector over the current session’s history. Unlike /fork (which spawns a new session file), /tree branches in place:

  1. A scrollable list of every message in the current conversation is displayed with its index and a text preview.

  2. Navigate with ↑ / ↓ and press Enter to select the message you want to branch from.

  3. On selection:

    • The in-memory conversation is truncated to the messages up to and including the selected point.

    • sessionManager.branch(entryId) is called to rewrite the on-disk JSONL so the branch is persisted immediately β€” you can resume from the same point in a future session.

  4. You are returned to the chat prompt; subsequent messages continue from the branch point.

  5. Press Escape to cancel without making any changes.

Key Action

↑ / ↓

Move selection up / down

Enter

Branch from selected message

Escape

Cancel and return to chat

/tree vs /fork: Use /tree when you want to keep working in the same session with a revised history. Use /fork when you want to preserve the original session unchanged and explore an alternative in a new file.

Session Picker

/resume opens a full-screen interactive session picker and restores the full message history of the selected session into the active agent context. All TUI timers and status indicators are reset so there is no carry-over from the previous session.

 Resume Session
────────────────────────────────────────────────────
 Type to filter β€’ ↑/↓ move β€’ Enter select β€’ Esc cancel
> my-feature-work     Refactor the auth module    2m ago  14m
  fix-login-bug       Debug the JWT validation    1h ago   8m
  api-redesign        Design the REST API layo…   3d ago  22m
────────────────────────────────────────────────────
 2/3 sessions
Interaction Behaviour

Type characters

Filters sessions by name, first message, or ID prefix (case-insensitive)

Backspace

Remove last character from filter

↑ / ↓

Move selection up/down

Enter

Load selected session and return to chat

Escape

Cancel and return to chat

Columns shown per row: session name (or truncated ID), first message preview, relative age (now, Xm ago, Xh ago, Xd ago, Xw ago), message count.

Full context restore: On Enter, the complete message history is loaded from disk and placed into lastState. Agent-phase, timers, and the UI notice board are all reset to their initial values β€” identical to starting a fresh session, but with the resumed history pre-loaded.

Sessions are automatically named after their first user/assistant exchange. The auto-generated name appears in the picker and in the window title.

Hotkeys

Key Action

Enter

Submit message (or insert newline if pasting); applies selected completion when overlay is open

Tab

Complete a partial slash command or file path (see File Attachment Completion)

Escape

Dismiss completions overlay; or clear input buffer if no completions active

Ctrl+C

Cancel current agent run; or exit Book if idle

Ctrl+D

Exit Book (only when input buffer is empty)

Ctrl+L

Clear and redraw the screen

Ctrl+T

Toggle extended thinking / reasoning visibility

Ctrl+Shift+E

Cycle reasoning effort levels (displays toast if unsupported)

Ctrl+G

Open $VISUAL / $EDITOR to compose a long prompt externally

Arrow Up / Down

Navigate completion overlay (when open); or scroll conversation viewport up / down by 1 line

PageUp / PageDown

Scroll conversation viewport up / down by 10 lines

Alt+Up

Navigate input history β€” previous entry

Alt+Down

Navigate input history β€” next entry

Input history is persisted to ~/.bk/history.txt across sessions. Navigate it with Alt+Up / Alt+Down without affecting the conversation scroll position.

Status Row

While the agent is running, a status row appears below the conversation:

  • Thinking phase: a spinner and a rotating phrase (changes every 3 seconds β€” "thinking", "reticulating splines", "herding semicolons", etc.) plus elapsed time (Xs) or (Xm Ys).

  • Tool execution phase: spinner, the tool name(s) being executed with the most relevant argument extracted β€” e.g. bash(ls -la), read_file(src/Main.kt) β€” plus elapsed time.

  • Done: a "Done in Xs" row stays visible for 5 seconds after the agent finishes, then disappears.

Headless Mode Progress (stderr spinner)

When Book runs with -p and stderr is a TTY, a lightweight progress indicator appears on stderr:

β Έ read_file(src/auth/LoginService.kt)...

The spinner updates the current tool name live and clears itself when the run completes. No output is written to stderr when stderr is piped.

Tool Approval (opt-in)

If the tool_approval.bk.kts script is installed (see Opt-in Tool Approval), the TUI will pause before executing guarded tools (bash, write_file, etc.) and display an approval prompt. While the prompt is shown, the key handler is intercepted:

Key Decision

y / Y

Approve this call once

a / A

Always approve this tool for the rest of the session

n / N

Deny this call

Escape

Deny this call

All other keys are ignored until a decision is made. The approval prompt also shows a diff overlay for file-modifying tools.

CLI Arguments & Options

Positional Argument: prompt

An optional initial prompt to start the session. If provided, Book will process this immediately upon startup.

Options:

  • -m, --model <id>: Specifies the model ID to use (e.g., gpt-4o, claude-3-5-sonnet-20240620).

  • --effort <level>: Reasoning effort level (off, minimal, low, medium, high, xhigh, max), defaulting to high. Persists as global default unless --no-save-effort is passed.

  • --no-save-effort: Suppresses global default persistence when --effort is passed.

  • -s, --session <id|path>: Loads a previous session. You can provide a full path to a .jsonl session file or a session ID found in your sessions directory.

  • -c, --continue: Resume the most recent session for the current directory.

  • -r, --resume <id|name>: Resume a session by ID or name fragment.

Subcommands

ls [path]

Lists files in the specified path (defaults to current directory). This uses Book’s internal ListFilesUseCase.

./gradlew :cli:run --args="ls /home/user/project"

sessions list [--all]

Lists recent sessions (current directory by default, or all directories with --all).

sessions rm <id>

Deletes a specific session by ID (prefix match supported).

sessions clear [--force]

Deletes all sessions and their corresponding log files for the current directory (asks for confirmation unless --force).