Skip to main content

nexus_core/
lib.rs

1//! nexus-chat-core (lib crate `nexus_core`): the engine behind the `nexus`
2//! TUI and (later) the nexus host API. Owns all domain logic — sessions, research pipeline, provider
3//! clients, tools, files, skills, `SQLite` state — with no knowledge of the
4//! terminal UI. Phase 2e moved every piece of view state (composer, popup
5//! chrome, render caches, theme) into the TUI crate's `AppView`.
6//!
7//! Doc-lint allows: the domain surface the TUI/CLI/host drive directly
8//! (`Db`, provider, config, `App`'s event handlers) is still pub, so the
9//! per-item doc lints would be noise until the Phase 4 host API pass
10//! privatizes it. They're crate-scoped deliberately — the 2e goal (zero
11//! TUI deps) is unaffected.
12#![allow(
13    clippy::missing_errors_doc,
14    clippy::missing_panics_doc,
15    clippy::must_use_candidate
16)]
17
18pub mod app;
19pub mod app_templates;
20pub mod appserver;
21pub mod citations;
22pub mod config;
23pub mod db;
24pub mod extract;
25pub mod host;
26pub mod markdown;
27pub mod provider;
28pub mod skills;
29pub mod space;
30pub mod sync;
31pub mod tools;
32pub mod update;
33
34use anyhow::Result;
35
36/// One bootstrap for every frontend (TUI, CLI, Phase 4 host): credentials →
37/// space → db → appserver → toolbox. This is what `main.rs` and
38/// `cli.rs::build_app` both used to hand-roll.
39pub async fn boot(saved: config::SavedCreds) -> Result<app::App> {
40    // A single bootstrap key just seeds App::new's "reasonable defaults"
41    // guess (utility model strings); rebuild_all_backends below populates
42    // every configured backend regardless of which one this picked.
43    let key = config::first_configured(&saved).map(|(_, k)| k);
44    let space = space::Space::open()?;
45    let db = db::Db::open(&space.db_path())?;
46    let mut app = app::App::new(db, key.as_deref(), space);
47    app.saved = saved;
48    app.rebuild_all_backends();
49    app.app_server = appserver::AppServer::start(app.space.spaces_root()).await;
50    app.refresh_toolbox();
51    Ok(app)
52}