Architecture
oh-my-dsh builds on published DeepSeek Harness (DSH) packages: sessions, models, tools, commands, permissions, Skills, MCP, LSP, and metering live in Harness plugins, while omdsh owns terminal presentation and human interaction—deliberately avoiding a second agent core.
1. Repository and dependency boundaries
- Runtime dependencies: Every
@deepseek-ai/*package is installed at exact published npm versions and consumed strictly through public exports. - Product packages:
apps/omdsh(@agi-fans/oh-my-dsh): CLI parsing, boot composition,omdsh doctor,omdsh exec,omdsh plugininstaller, and default profile manifest.packages/tui/omdsh-tui(@agi-fans/dsh-tui): reusable terminal UI suite (service definition, local terminal provider, session runtime, slash commands, Markdown/tool rendering, and interactive views).- Read-only references:
refs/deepseek-harnessandrefs/piare research-only and never participate in resolution, builds, tests, or runtime execution.
apps/omdsh/ @agi-fans/oh-my-dsh
├── src/bin.ts CLI entry and argument parsing
├── src/boot.ts Boot and compose plugin tree
├── src/doctor.ts Read-only diagnostics (`omdsh doctor`)
├── src/exec.ts Script mode (`omdsh exec --json`)
├── src/plugin.ts `omdsh plugin` manager
└── config/cordis.yml Default product composition
packages/tui/omdsh-tui/ @agi-fans/dsh-tui
├── src/definition.ts Provider-agnostic TUI Service contract
├── src/runtime/ Local terminal provider, session runtime, runner, settings forms
├── src/commands/ Slash-command plugins (model/session/team/plugins/mcp/etc.)
├── src/chrome/ Themes, display width, Markdown, tool cards, status footer
├── src/input/ Key decoding, editor, clipboard, paste protection
├── src/views/ Transcript viewport, settings panel, diff/file/trajectory/search views
└── src/session/ Session controller and helpers
2. Ownership and data flow
Terminal input → Local TUI Provider → Runner / Command registry → Session Runtime & Harness services
→ Durable session events & metering projections → Pure view layer → Differential renderer
- Local TUI Provider: Sole owner of raw mode, key decoding, cursor state, mouse reporting, and atomic terminal writes.
- Session Runtime: Manages session creation/resume, model/preset selection, tool presentation mapping, and live subagent lists (routing text/image follow-ups for continuable subagents through
SubagentRuntime.prompt). - Commands & tools: Slash commands register via
dsh-commands; tools declare presentation intent viapresentCall/presentResultwhile the TUI handles padding, wrapping, and fallback rendering. - Metering & footer: Token counts, context pressure, duration, titles, and stats come directly from Harness projections—never duplicate UI counters.
- Pure internal modules: ANSI cell width, Markdown formatting, frame diffing, and view transitions remain plain modules rather than speculative runtime plugins.
3. Runtime composition
apps/omdsh/config/cordis.yml layers these capabilities over $OMDSH_HOME/profiles/omdsh:
- Core & models: Cordis loader, DeepSeek account + API-key routes with local OAuth callback host, multi-provider adapter, credentials, settings, and default model.
- Sessions & guardrails: Durable JSONL sessions, SQLite FTS5 search index, auto-titling and metering, remembered approval rules (
approval-rules), turn file recovery snapshots (file-recovery), per-turn changed-file tracking (workspace-changes), tool-result pruning, image offload, and repeat-tool reminders. - Tools & workflows: Platform shell (
bashon POSIX,pwshon Windows), persistent interactive terminals (terminal), background jobs (jobs), scheduled reminders (schedule), web search/fetch, Todo,/goal,/plan,/btwside queries, and command hooks (hook-settings). - Presets & multi-agent:
Standard,PTC,Minimal, andCreatorpresets; three subagent transports (subagent,subagent_fork,subagent_isolated); opt-in Agent Teams (/team); plus bundled Codex, Claude Code, Git Worktrees, Auto review, and Tmux location context integrations. - Extensions: Filesystem Skills, live
/mcpserver manager, staticmcp.json, and read-onlylsp.jsonlanguage servers. - Terminal layer: Local TUI provider, tool presentation bridge, human interaction adapter, slash commands, and runner.
User-installed plugins (/plugins or omdsh plugin add) and $OMDSH_HOME/profiles/omdsh/cordis.patch.yml layer on top at boot (inspect with omdsh --dump-config).
4. Terminal rendering guarantees
Main screen and native scrollback
- Layout is computed in terminal display cells (handling ANSI escapes, CJK text, emoji, combining marks, and unbroken lines), with the input box and status footer anchored at the bottom.
- Native scrollback is never erased: Scrolled-off rows stay immutable snapshots;
/clear, session switches,/resume, and forks append below a labeled divider (/newadds one only when the prior transcript had substantive content). - Alternate screen is used only for true full-screen overlays on direct terminals; tmux, screen, and ConPTY coalesce resize bursts and preserve host scrollback.
Incremental diffing and frame sync
- Completed transcript blocks cache their formatted rows; scrolling and streaming repaint only changed visible rows inside a single DEC 2026 synchronized write.
- Streaming deltas coalesce within an 8 ms frame window while user keystrokes, tool state transitions, and control events flush immediately.
Focus, mouse, and safe exit
- Overlays and docked panels own focus cleanly; approval prompts always take priority over routine views and restore your prior surface and draft once resolved.
- Mouse reporting (1000/1006) respects
Mouse interactionand tmuxmouse off, with full keyboard parity in native mode. Ctrl+Cclears drafts or interrupts active work; pressingCtrl+Ctwice at idle (orCtrl+Dwhen empty) exits with a--resumehint. Pipe mode shares the same command and session semantics without taking over the screen.
5. Verification
- Unit & fake-TTY contract tests: Cell width, ANSI/CJK/emoji layout, Markdown, tool cards, viewport caching, key routing, and lifecycle disposal.
- End-to-end smoke tests:
pnpm smoke:happy(mock LLM happy path) andpnpm smoke(real PTY interaction). - Boundary & doc gates:
pnpm check:boundariesguarantees zero references intorefs/, whilepnpm check:mdand site builds validate bilingual docs. SeeAGENTS.md.