@mistriwork/agent-ui
v1.4.2
Published
Opt-in React workbench, orchestrator, and AI IDE primitives for Mistri Apps, with an optional @pierre/diffs & @pierre/trees adapter.
Maintainers
Readme
@mistriwork/agent-ui
Opt-in React workbench, orchestrator, and AI IDE primitives for Mistri Apps, built on @mistriwork/mistri/ui controls and design tokens.
Primitives
- Workbench shell:
<WorkbenchLayout>,<TabStrip>,<StatusBar>,<CommandPalette> - Orchestrator:
<SessionTree>,<RaceCompare>,<ApprovalQueue>,<PlanView> - Agent interaction & tooling:
<AgentThread>,<AgentComposer>(with attachment chips & slash commands),<ToolCallInspector>,<TerminalOutput>(safe ANSI SGR parser),<ModeSwitcher>,<ModelPicker> - Stream bridges:
streamStateToThreadMessage,mergeStreamingTurn,streamStateToToolCalls,streamStateToApprovals,streamStateToDiffFiles - Pluggable surfaces (zero-dep fallbacks built in):
<AgentUiProvider>,<CodeSurface>,<DiffSurface>,<DiffView>,parseUnifiedDiff,<FileTree>,buildFileTreeNodes - Optional Pierre adapter (
@mistriwork/agent-ui/pierre):createPierreSurfaces,<PierreCodeSurface>,<PierreDiffSurface>,<PierreFileTree>
Quick Start (Zero Extra Dependencies)
import { useState } from 'react';
import {
AgentComposer,
AgentThread,
DiffSurface,
FileTree,
StatusBar,
WorkbenchLayout,
mergeStreamingTurn,
} from '@mistriwork/agent-ui';
import { useAgentStream } from '@mistriwork/mistri/page';
export function CodingWorkbench({ sessionId }: { sessionId: string }) {
const [prompt, setPrompt] = useState('');
const [selectedFile, setSelectedFile] = useState('src/index.ts');
const stream = useAgentStream(sessionId);
const messages = mergeStreamingTurn([], stream, { model: 'claude-sonnet' });
return (
<WorkbenchLayout
sidebar={<FileTree paths={['src/index.ts', 'src/parser.ts']} selectedPath={selectedFile} onSelect={setSelectedFile} searchable />}
main={<DiffSurface patch={stream.diffs[0]?.patch} />}
inspector={
<>
<AgentThread messages={messages} />
<AgentComposer value={prompt} onValueChange={setPrompt} onSubmit={() => {}} />
</>
}
statusBar={<StatusBar items={[{ id: 'status', label: 'Agent', value: stream.status, tone: 'info' }]} />}
/>
);
}Upgrading Code, Diff & File Tree Surfaces with Pierre
Install @pierre/diffs (and optionally @pierre/trees) in your app, then wrap your workbench with <AgentUiProvider>:
import * as pierreDiffs from '@pierre/diffs/react';
import * as pierreTrees from '@pierre/trees/react';
import { AgentUiProvider, CodeSurface, DiffSurface, FileTree } from '@mistriwork/agent-ui';
import { createPierreSurfaces } from '@mistriwork/agent-ui/pierre';
import { useLook } from '@mistriwork/mistri/ui';
export function PierreWorkbench({ children }: { children: React.ReactNode }) {
const { mode } = useLook();
const surfaces = createPierreSurfaces({
diffs: pierreDiffs,
trees: pierreTrees,
themeMode: mode,
diffStyle: 'split',
});
return <AgentUiProvider surfaces={surfaces}>{children}</AgentUiProvider>;
}Every <CodeSurface>, <DiffSurface>, and <FileTree> inside the provider upgrades automatically to Pierre's Shiki viewer, virtualized split/unified diff, lazy @pierre/diffs/edit editor (editable), "Add to chat" selection action (onAddToChat), and @pierre/trees explorer.
