How priorityfill/deepseek-reasonix works
1. Repository shape
- This is a monorepo for a Go-based AI coding agent called Reasonix.
- The main product surfaces are a terminal CLI, a desktop app, supporting cloud services, a marketing/community site, and release/packaging tooling.
- The codebase is centered on a single Go module at the root, with a separate TypeScript frontend for the desktop shell and separate worker apps for hosted services.
2. Core runtime: the agent engine
- The architectural center lives under internal/agent, internal/control, internal/provider, internal/tool, internal/plugin, internal/memory, internal/history, internal/session, and internal/checkpoint.
- This layer is responsible for orchestrating turns, model calls, tool execution, memory retrieval/compaction, transcript/history management, checkpointing, and recovery.
- It is intentionally model-agnostic: provider selection and tool availability come from configuration rather than hardcoded assumptions.
3. Primary execution paths
- cmd/reasonix is the main terminal entrypoint.
- desktop/main.go starts the Wails-based desktop application.
- internal/cli implements the terminal UX and command surfaces around the shared engine.
- All of these frontends converge on the same core control/agent packages, so the architecture is “multiple shells, one orchestration core.”
4. Desktop application boundary
- The desktop app is a Go backend plus a React/Vite frontend in desktop/frontend.
- The Go side handles session lifecycle, workspace access, updater, tray, notifications, crash/heartbeat logic, and OS-specific behavior.
- The frontend renders the conversation/workspace UI and talks to Go through the Wails bridge; state is split between local frontend stores and backend-managed session data.
5. Session, workspace, and persistence model
- Reasonix is session-centric: conversations, tool outputs, approvals, and recovery state are stored and restored as local session artifacts.
- internal/store, internal/session, internal/history, internal/control, and many desktop/*session* files show that persistence is local-first and optimized for resume/rewind/recovery.
- Workspace concepts are first-class: the agent operates against a project directory, reads repo files, and maintains project-scoped context such as AGENTS.md, memory files, and task artifacts.
6. Model/provider and cache-aware context flow
- internal/provider contains adapters for OpenAI-compatible backends, including DeepSeek presets called out in the README.
- Configuration loading and provider/model resolution live in internal/config and are driven by reasonix.toml, user config, and environment variables.
- The system is designed around long-running sessions and prefix-cache stability: startup context is kept small and stable, while stale tool output and summary compaction are managed deliberately.
7. Tools, plugins, and sandboxing
- Built-in tools live under internal/tool/builtin and are registered into a shared tool contract.
- External plugins are handled separately under internal/plugin, typically as subprocesses over stdio JSON-RPC / MCP-compatible transport; HTTP transport is also present for some plugin cases.
- Tool execution is constrained by permissions and sandbox layers in internal/permission, internal/sandbox, internal/shellsafe, internal/proc, and related helpers, so file/process/network operations are not free-form.
8. Memory, retrieval, and evidence
- Long-term or user-authored memory is managed under internal/memory, with compiler/summary logic in internal/memorycompiler.
- Evidence and readiness checks are explicit subsystems (internal/evidence, internal/retrieval, internal/guardian) rather than being implicit prompt text.
- This creates a pipeline where the agent can recall relevant project knowledge, then compress or prune it to stay within context limits.
9. Automation and integrations
- The repo includes bot support under internal/bot and internal/botruntime, with adapters for Feishu/Lark, QQ, and Weixin.
- There is also an internal/serve package for hosted session interaction and login/auth flows.
- These integrations suggest Reasonix can be controlled from external chat surfaces and web endpoints, not only from the terminal or desktop UI.
10. Cloud/backend services
- workers/accounts is an authentication and account-management service with user, session, email-token, and device-grant storage.
- workers/crash-report handles crash telemetry and related registry/admin functionality; it also contains a registry sub-app for package/activity tracking.
- workers/forum provides a lightweight community service with identity and antispam logic.
- These services are separate deployment units from the Go client/runtime and represent the hosted backend edge of the ecosystem.
11. Website, documentation, and release surface
- site is the public marketing/community/docs web app built with Astro.
- docs contains the product architecture/specification, configuration, tool contract, checkpoint/rewind docs, and bot guide.
- Release and distribution are automated via GitHub Actions, GoReleaser, npm packaging, and Windows code signing; the product is distributed as a native binary even though parts of the ecosystem are TypeScript-based.
12. How data flows end-to-end
- A user request enters through CLI, desktop, or bot.
- The control layer loads config, resolves the model/provider, assembles context from session/history/memory/workspace state, and invokes the agent loop.
- The agent may call built-in tools or external plugins, collect evidence, update checkpoints/history, and persist the resulting session state locally.
- Optional hosted services handle accounts, crash reporting, community, and release distribution, but the core runtime remains local-first and self-contained.
Main entry points: agent Agent core · control Control · main.go Desktop app · session.go Store
Components 24
Client apps
User-facing shells and desktop frontend.
- CLI · Main terminal binary for local agent sessions.
cmd/reasonix/main.go - Shell UX · Interactive command surfaces and chat TUI around the shared engine.
internal/cli - Desktop app · Go backend entrypoint for the desktop application.
desktop/main.go - Desktop UI · Conversation and workspace shell rendered through the Wails bridge.
desktop/frontend/src
Core runtime
Shared Go orchestration, tools, memory, and persistence.
- Control · Loads config, assembles context, manages approvals, and drives turn execution.
internal/control - Agent core · Model-agnostic loop for planning, tool use, compaction, and recovery.
internal/agent - Providers · Adapters and presets for OpenAI-compatible and other model backends.
internal/provider - Tools · Built-in tool registry, tool results, and session-aware tool execution.
internal/tool - Plugins · Subprocess and HTTP plugin transport, caching, and host-side plugin management.
internal/plugin - Memory · Long-term memory, recall, and user-authored knowledge handling.
internal/memory - Memory compactor · Compresses memory and feedback to stay within context limits.
internal/memorycompiler - History · Transcript and tool history search, stripping, and replay support.
internal/history - Checkpoints · Checkpointing and rewind support for session recovery.
internal/checkpoint/checkpoint.go - Config · Loads reasonix.toml, user config, environment, presets, and model selection.
internal/config/config.go - Store · Local session persistence layer used by the client runtime.
internal/store/session.go - Session core · Session identity, leases, recovery hooks, and event flow within the agent runtime.
internal/agent/session.go - Bots · Chat gateway, rendering, pairing, and platform adapters for external messaging surfaces.
internal/bot - Hosted runtime · Server-side session interaction and login/auth flows.
internal/serve/serve.go
Hosted services
Separate deployment units for accounts, crash reporting, and community.
- Accounts · Hosted account, session, email-token, and device-grant service.
workers/accounts - Crash report · Crash telemetry plus registry/admin and package activity tracking.
workers/crash-report - Forum · Lightweight community service with identity and antispam logic.
workers/forum
Docs and release
Documentation, packaging, automation, and distribution.
Connections 26
- CLI → Shell UX: uses · CLI entrypoint hands off to terminal UX and commands.
- Shell UX → Control: orchestrates · Terminal shell delegates turns and session actions to control.
- Desktop app → Desktop UI: hosts · Wails backend serves the React/Vite desktop shell.
- Desktop app → Control: uses · Desktop backend converges on the shared orchestration core.
- Desktop UI → Control: bridges · Frontend state and actions flow through the Wails bridge into backend session data.
- Control → Config: loads · Configuration determines providers, tools, workspace, and runtime behavior.
- Control → Agent core: drives · Control layer runs the agent loop and turn orchestration.
- Control → Session core: manages · Control manages session lifecycle, resume, and recovery hooks.
- Agent core → Providers: calls · Agent invokes configured model providers.
- Agent core → Tools: executes · Agent runs built-in tools through the shared contract.
- Agent core → Plugins: delegates · Agent can route tool-like work to external plugins.
- Agent core → Memory: recalls · Agent retrieves memory for long-running sessions.
- Agent core → Memory compactor: compacts · Agent compresses memory and feedback to preserve context.
- Agent core → History: reads/writes · Agent tracks transcript and tool history for replay and context maintenance.
- Agent core → Checkpoints: snapshots · Agent checkpoints progress for rewind and recovery.
- Agent core → Store: persists · Session artifacts are stored locally for resume and recovery.
- Session core → Store: stores · Session state is persisted through the local store layer.
- Bots → Control: routes · Bot surfaces feed requests into the same orchestration core.
- Hosted runtime → Accounts: auths with · Hosted session/login flows rely on the accounts service.
- Hosted runtime → Store: manages · Hosted runtime interacts with session state and recovery artifacts.
- Crash report → Desktop app: reports · Desktop app integrates crash telemetry and registry interactions.
- Forum → Website: powers · Community service backs public forum/community pages.
- Website → Accounts: auth flow · Website account and login pages connect to the accounts service.
- Docs → Control: specifies · Documentation defines architecture, contracts, and recovery behavior.
- Release → Desktop app: packages · Release automation builds and signs the desktop distribution.
- Release → CLI: packages · Release automation ships the CLI binary.