Docs/TypeScript/TUI Module
TUItui/README
TUI Module
The TUI surface of indusagi is two cooperating layers: a small terminal-text
toolkit (indusagi/tui) of pure string helpers, key parsing, keybindings, and
autocomplete; and a React + Ink component set (indusagi/react-ink) that renders
the agent conversation, dialogs, diffs, and markdown. Both are wired to a host
React/Ink instance through indusagi/react-host.
Entry points: indusagi/tui, indusagi/react-ink, indusagi/react-host.
Source Map
indusagi/tuiresolves tosrc/ui/index.ts— the toolkit barrel. It re-exports fromsrc/ui/autocomplete.ts,src/ui/editor-component.ts,src/ui/contracts.ts,src/ui/theme-types.ts,src/ui/fuzzy.ts,src/ui/keybindings.ts,src/ui/keys.ts, andsrc/ui/utils.ts.indusagi/react-inkresolves tosrc/react-ink/index.ts— the component barrel. It re-exportssrc/react-ink/types.ts,src/react-ink/theme-adapter.ts, the components undersrc/react-ink/components/**, the markdown renderer undersrc/react-ink/markdown/**, the diff renderer undersrc/react-ink/diff/**, and the helpers undersrc/react-ink/utils/**.indusagi/react-hostresolves tosrc/react-host/index.ts— the React adapter;indusagi/react-host/ink(src/react-host/ink.ts) re-exports Ink'sBox,Text,render,useInput;indusagi/react-host/jsx-runtime(src/react-host/jsx-runtime.ts) re-exports the JSX runtime. The resolver lives insrc/react-host/loader.ts.
What lives where
- Toolkit (
indusagi/tui) — no React. ExportsparseKey/matchesKey/Key,EditorKeybindingsManager+DEFAULT_EDITOR_KEYBINDINGS,CombinedAutocompleteProvider,fuzzyMatch/fuzzyFilter, theComponent/TUI/OverlayOptionscontracts, theEditorComponentinterface, the theme-type interfaces (MarkdownTheme,EditorTheme,SelectListTheme,SettingsListTheme), and ANSI-aware text helpersvisibleWidth,truncateToWidth,wrapTextWithAnsi. - Components (
indusagi/react-ink) — the Ink JSX surface: message views, tool cards, dialogs, a colored diff block, and a markdown renderer. Every component takes its colours through anInkThemeAdapterprop — there is nouseTheme()hook in the rebuild. - Host (
indusagi/react-host) — resolves the consumer's React/Ink at load time so the bundled components run against one React instance.
Core Concepts
Component(src/ui/contracts.ts) definesrender(width), optionalhandleInput(data), lifecycle hooks (onMount/onUnmount/onFocus/onBlur), andinvalidate().InkThemeAdapter(src/react-ink/theme-adapter.ts) maps colour keys and named markdown/diff/syntaxThemeRoles to chalk-painted strings; it is threaded explicitly into every renderer.- Images are rendered as text placeholders (
[image: <mimeType>]) gated by ashowImagesflag — there is no pixel/Kitty/iTerm2 image protocol in this rebuild. See TUI Images.
