Skip to main content

sparrow/cmd_handlers/
prelude.rs

1// src/cmd_handlers/prelude.rs — common imports for all handler modules.
2//
3// Every extracted handler does `use super::prelude::*;` and gets the full
4// CLI vocabulary in one shot: types, traits, helpers, and the per-run
5// flags. Anything a handler needs from elsewhere in the crate goes here so
6// the handlers stay short.
7
8pub use std::collections::HashMap;
9pub use std::path::{Path, PathBuf};
10pub use std::sync::Arc;
11
12pub use anyhow::anyhow;
13pub use sparrow::agent::{AgentStore, FsAgentStore, Soul};
14pub use sparrow::auth::{AuthStore, Credential};
15pub use sparrow::autonomy::GitCheckpoints;
16pub use sparrow::capabilities::mcp::{BasicMcpClient, McpClient, McpServer, Transport};
17pub use sparrow::capabilities::{FsSkillLibrary, Skill, SkillLibrary};
18pub use sparrow::cli::{Cli, Commands, ImportSource};
19pub use sparrow::config::{Config, ConfigStore, FsConfigStore, ProviderConfig};
20pub use sparrow::console::WebViewServer;
21pub use sparrow::engine::Engine;
22pub use sparrow::event::{AutonomyLevel, Event, RunId};
23pub use sparrow::extras::{ChatSession, Distiller, ReExecuter};
24pub use sparrow::gateway::discord::DiscordTransport;
25pub use sparrow::gateway::slack::SlackTransport;
26pub use sparrow::gateway::telegram::TelegramTransport;
27pub use sparrow::gateway::ws::WebSocketApi;
28pub use sparrow::gateway::{GatewayMessage, GatewayResponse, GatewayTransport, MessageRouter};
29pub use sparrow::memory::{Memory, SqliteMemory};
30pub use sparrow::onboarding::migration::Migration;
31pub use sparrow::runtime::event_bus::EventBus;
32pub use sparrow::runtime::recorder::{FsRecorder, Recorder, Replayer, RunInputs};
33pub use sparrow::runtime::scheduler::{Job, MemoryScheduler, Scheduler};
34pub use sparrow::runtime::{Runtime, SparrowRuntime};
35pub use sparrow::tui::Tui;
36
37// Per-run flags. These live in the prelude (rather than in one handler) so
38// every handler that calls `run_task` can construct them.
39
40/// How `run_task` resolves the conversation context for this run.
41#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
42pub enum SessionMode {
43    /// Continue this directory's session (existing behaviour).
44    #[default]
45    Auto,
46    /// Ignore any saved session — start clean.
47    Fresh,
48    /// Continue the most recently updated session from ANY surface.
49    ContinueLast,
50}
51
52/// Per-invocation run options threaded from the CLI flags.
53#[derive(Debug, Clone, Copy, Default)]
54pub struct RunFlags {
55    pub session_mode: SessionMode,
56    /// Skip the pre-run quote confirmation (--yes, or non-interactive).
57    pub assume_yes: bool,
58}
59
60// Cross-handler helpers. They live in run_task_cmd, agent_cmd, gateway_cmd,
61// and memory_graph_cmd respectively — re-exported here so any handler can
62// call them via the prelude without having to remember which sibling owns
63// each one.
64
65pub use super::handle_agent_cmd::{build_provider_brains, config_for_soul};
66pub use super::handle_gateway_cmd::sanitize_file_component;
67pub use super::handle_memory_graph_cmd::current_repo_head;
68pub use super::handle_run_task_cmd::{redacted_config_snapshot, run_task};