Skip to main content

memfork/
lib.rs

1//! The `memfork` command: an MCP server, a shared daemon and a command line.
2//!
3//! MemFork gives an agent branchable memory — store and recall things, fork
4//! the whole of memory before a risky step, then merge the fork or discard it.
5//! This crate is what a user installs; the engine underneath is
6//! [`memfork_core`].
7//!
8//! Most people never call this library. They install the binary and run:
9//!
10//! ```sh
11//! memfork init      # register the MCP server with the clients they have
12//! memfork doctor    # what is installed, and what is talking to it
13//! ```
14//!
15//! The library exists because the binary is a thin shell over it, which lets
16//! each piece be tested directly rather than only through a subprocess — and
17//! because the Python package on PyPI offers the same command through an entry
18//! point, so the two must not drift apart.
19//!
20//! ```no_run
21//! // What `memfork mcp` does, minus the argument parsing.
22//! use std::sync::Arc;
23//! use memfork::tools::dispatch::Session;
24//!
25//! # async fn example() -> Result<(), String> {
26//! let session = Arc::new(Session::new(memfork_core::Db::new()));
27//! memfork::mcp::serve_stdio(session).await
28//! # }
29//! ```
30//!
31//! # What is where
32//!
33//! - [`tools`] is the tool registry: one set of definitions serving the MCP
34//!   server, the vendor function-calling formats and `memfork call`.
35//! - [`mcp`] serves those tools over stdio, and [`serve`] serves them over
36//!   loopback HTTP for the daemon.
37//! - [`proxy`] is what a client actually talks to: it answers the handshake
38//!   itself and forwards tool calls to the daemon, starting one if none is
39//!   running.
40//! - [`clients`] is the client adapter registry and the config editors behind
41//!   [`init`], which registers MemFork with the MCP clients on the machine.
42//! - [`doctor`] reports what this install is and what it is talking to.
43//! - [`persist`] is the write-ahead log, snapshots and the lock that gives one
44//!   process ownership of a data directory.
45//! - [`launch`] works out how to start MemFork again, which is not the same
46//!   question as "where is this executable" once a Python wheel is involved.
47//! - [`run`] is the command line itself.
48//!
49//! # Memory is kept, and shared
50//!
51//! What an agent stores is written to a data directory and is still there next
52//! time. Several clients can use one store at once: the first that needs it
53//! starts a daemon that owns the directory, and the rest connect to that,
54//! while each keeps its own current branch. `--ephemeral` keeps nothing and
55//! shares nothing.
56//!
57//! The project README covers installation and the full command reference:
58//! <https://github.com/memforkdb/memfork>. The design is in
59//! [`docs/DESIGN.md`](https://github.com/memforkdb/memfork/blob/main/docs/DESIGN.md).
60
61#![warn(missing_docs)]
62
63#[cfg(feature = "brain")]
64pub mod agent;
65pub mod autopilot;
66pub mod board;
67#[cfg(feature = "brain")]
68pub mod brain;
69pub mod cli;
70pub mod client;
71pub mod clients;
72pub mod daemon;
73#[cfg(feature = "brain")]
74pub mod demo;
75pub mod doctor;
76pub mod events;
77pub mod exec;
78pub mod facts;
79pub mod find;
80pub mod flags;
81pub mod history;
82pub mod init;
83pub mod launch;
84pub mod lessons;
85pub mod maintenance;
86pub mod mcp;
87pub mod namespace;
88pub mod persist;
89pub mod plans;
90pub mod policy;
91pub mod prompts;
92pub mod proxy;
93pub mod render;
94pub mod run;
95pub mod secrets;
96pub mod serve;
97pub mod shared;
98pub mod sidecar;
99pub mod style;
100pub mod tools;
101
102/// The version of this crate.
103pub const VERSION: &str = env!("CARGO_PKG_VERSION");