How researai/deepscientist works
1. What this repository is
DeepScientist is a local-first autonomous research system, not a single app. Its core architectural idea is “one quest, one repository”: each research effort becomes a durable Git-backed workspace that can accumulate baselines, experiments, notes, artifacts, and writing over time.
2. Primary runtime and entry points
The main backend is the Python package under src/deepscientist, exposed through the ds CLI. That CLI starts and manages the local daemon, launches quests, coordinates runners, and provides diagnostics and shutdown. The repo also ships separate frontends in src/ui and src/tui.
3. Backend control plane
The daemon package is the control plane. It exposes an API for the UI/TUI, manages sessions, and emits events for long-running operations. This is where the system’s central state transitions happen: project setup, quest lifecycle, task progress, and operational health.
4. Quest/workspace domain
The quest, team, memory, gitops, and runtime_storage modules define the main research-domain boundary. They model a quest as a structured workspace, track state across stages, map work into Git branches/worktrees, and persist accumulated findings so later runs can reuse prior work instead of restarting from scratch.
5. Execution layer for agent work
Agent actions are executed through runner abstractions in runners, shell execution in bash_exec, and tool/runtime services in runtime_tools and mcp. This layer is the boundary between “planning” and “doing”: it runs code, checks environment state, captures logs, and feeds results back into the quest loop.
6. External coding-tool integrations
DeepScientist is designed to plug into existing coding CLIs rather than replace them. The built-in runners target Codex, Claude Code, Kimi Code, and OpenCode. That means the system’s model/execution boundary is intentionally externalized: DeepScientist orchestrates, while the chosen CLI performs many of the actual code-generation and agent steps.
7. Web workspace frontend
src/ui is the primary browser workspace. It is a React/Vite application with a plugin-based surface model: project pages, workspace views, settings, lab/canvas views, file and diff viewers, PDF/markdown/notebook viewers, and a chat/coplilot experience. It talks to the daemon and realtime channels to render quest progress and manipulate local project state.
8. Terminal frontend
src/tui provides a terminal-native interface for the same backend system. It is useful when the machine is remote or when the user wants a lower-friction operational view. Architecturally, it mirrors the web client’s role: a presentation layer over the daemon and quest services.
9. Connector boundary
The channels, bridges, and connector packages integrate external collaboration surfaces such as QQ, Telegram, Slack, Discord, Weixin, WhatsApp, and Lingzhu/Feishu-style flows. These connectors convert inbound messages and attachments into internal events, and they send status updates or responses back out through the same channel adapters.
10. Research-content and artifact pipeline
The artifact and arxiv_library modules handle paper-facing inputs and outputs: papers, PDFs, annotations, figures, metrics, and guidance artifacts. This pipeline connects the “research object” side of the system to the workspace, so imported literature and generated outputs live alongside code and experiment traces.
11. BenchStore and scientific catalogs
benchstore plus the large AISB/catalog tree support benchmark/task catalogs and prompt assembly for research workflows. This is a distinct content layer: curated YAML definitions and generated markdown/prompt material that drive repeatable benchmark-style or challenge-style research runs.
12. Skills and prompts as operating policies
The large skills and src/prompts trees are the system’s behavior library. They encode stage-specific procedures for idea generation, experiments, review, writing, figure polish, rebuttal, and science workflows. In diagram terms, this is a policy/recipe layer consumed by agents and runners, not just documentation.
13. Operations, diagnostics, and safety
admin, doctor, diagnostics, and related settings modules provide system inspection, repair, metrics, and logging. The web UI surfaces these through dedicated settings and control-center pages, which makes operational health part of the product rather than a separate ops tool.
14. Persistence and local boundary
The system is strongly local in its data model: Git repos, worktrees, caches, runtime state, and browser-side indexed storage all matter. That makes the key architectural boundary the local machine or server itself, with external services limited to model CLIs, chat platforms, paper sources, and optional web/search integrations.
15. How data flows end-to-end
Typical flow is: user starts a quest in the UI/TUI or via connectors; the daemon creates/loads the quest workspace; runners and shell tools execute work inside Git-backed repos; memory/artifact/gitops services record the outcomes; the UI reflects progress in real time; and the resulting outputs remain available for later continuation, review, or publication.
Main entry points: quest Quest model · runners Runners · daemon Daemon · ui Web UI
Components 21
Backend core
Python package that owns daemon control plane, quest domain, execution, persistence, and services.
- ds CLI · Main command-line entry for launching and managing the system.
src/deepscientist/cli.py - Daemon · API, session, and event hub for quests and long-running operations.
src/deepscientist/daemon - Quest model · Quest lifecycle, layout, and stage views for a durable research workspace.
src/deepscientist/quest - Team memory · Shared state, frontmatter, and cross-run memory for accumulated findings.
src/deepscientist/team - Git ops · Branch, diff, and graph helpers for Git-backed worktrees and progress tracking.
src/deepscientist/gitops - Runtime storage · Local caches, logs, and storage boundary for quest state and artifacts.
src/deepscientist/runtime_storage.py - Bash exec · Shell execution, monitoring, and runtime control for doing work locally.
src/deepscientist/bash_exec - Runtime tools · Tool registry and service layer exposed to agents during execution.
src/deepscientist/runtime_tools - Runners · Execution adapters for Codex, Claude Code, Kimi, and OpenCode.
src/deepscientist/runners - MCP · Context and server layer for model/tool protocol integration.
src/deepscientist/mcp
User surfaces
Web and terminal clients that present quests and control the daemon.
Integrations
External connectors and coding-tool adapters.
- Channels · Inbound/outbound adapters for QQ, Telegram, Slack, Discord, Weixin, and WhatsApp.
src/deepscientist/channels - Bridges · Registry and bridge layer that normalizes external collaboration flows.
src/deepscientist/bridges - Connector profiles · Profiles and support modules for platform-specific connector behavior.
src/deepscientist/connector
Content layer
Prompts, skills, and benchmark/catalog material used by workflows.
- Prompts · Prompt builder and system/contracts prompts consumed by clients and agents.
src/deepscientist/prompts - Skills · Stage-specific procedures and templates for research, writing, and review.
src/deepscientist/skills - BenchStore · Prompt/catalog assembly for benchmark-style research workflows.
src/deepscientist/benchstore - Artifacts · Paper, PDF, annotation, guidance, and metrics artifact handling.
src/deepscientist/artifact
Operations
Diagnostics, admin, and safety tooling.
- Admin · System charts, logs, repairs, and tool metrics.
src/deepscientist/admin - Diagnostics · Doctor and runner failure diagnostics for inspection and recovery.
src/deepscientist/diagnostics
Connections 23
- ds CLI → Daemon: starts/manages · CLI controls daemon lifecycle and exposes operational commands.
- ds CLI → Quest model: launches quest · CLI initiates quest creation and continuation.
- Daemon → Quest model: orchestrates · Daemon owns quest state transitions and session coordination.
- Daemon → Web UI: serves API · Web UI talks to daemon APIs and realtime events.
- Daemon → TUI: serves API · TUI uses the same backend API and event stream.
- Quest model → Team memory: persists state · Quest data accumulates in shared memory and frontmatter services.
- Quest model → Git ops: maps to git · Quest work is organized as branches, diffs, and worktrees.
- Quest model → Runtime storage: stores locally · Quest runtime state and caches live on the local machine.
- Quest model → Runners: executes via · Quest actions are handed off to runner adapters.
- Runners → Bash exec: runs shell · Runners depend on shell execution and monitoring for local work.
- Runners → Runtime tools: uses tools · Runners consume runtime tools and service registry.
- Runners → MCP: protocol bridge · Runner/tool interactions can flow through MCP services.
- Runners → Connector profiles: integrates CLIs · Adapters target external coding-tool ecosystems and profiles.
- Channels → Bridges: normalizes events · Channel adapters are bridged into internal event flows.
- Bridges → Daemon: feeds events · External messages and attachments become daemon-visible events.
- Web UI → Artifacts: views artifacts · Browser UI renders papers, PDFs, annotations, and outputs.
- Web UI → BenchStore: browses catalog · Web UI exposes benchmark and prompt catalog workflows.
- Web UI → Admin: shows ops · Settings and control-center pages surface admin state.
- TUI → Admin: shows ops · Terminal UI includes operational and diagnostic views.
- Artifacts → Prompts: guided by · Artifact workflows use prompts and contracts for paper-facing tasks.
- Skills → Runners: policy for · Skills define stage procedures consumed by agents and runners.
- Prompts → Web UI: drives copy · UI surfaces use shared prompt text and interaction contracts.
- Admin → Diagnostics: reports health · Admin tools rely on diagnostics and repair signals.