refactor(lib): restrict internal module visibility to pub(crate) (#985)

Restrict 19 internal-only modules from pub to pub(crate) in lib.rs,
reducing the public API surface of the library crate.

Modules kept pub (used by integration tests, benchmarks, or are
documented extension points per AGENTS.md):
  agent, channels, config, gateway, memory, observability,
  peripherals, providers, rag, runtime, tools

Modules restricted to pub(crate) (not imported via zeroclaw:: by any
external consumer):
  approval, auth, cost, cron, daemon, doctor, hardware, health,
  heartbeat, identity, integrations, migration, multimodal, onboard,
  security, service, skills, tunnel, util

Also restrict 6 command enums (ServiceCommands, ChannelCommands,
SkillCommands, MigrateCommands, CronCommands, IntegrationCommands)
to pub(crate) — main.rs defines its own copies and does not import
these from the library crate. HardwareCommands and PeripheralCommands
remain pub as main.rs imports them via zeroclaw::.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Alex Gorevski 2026-02-20 02:06:41 -08:00 committed by GitHub
parent f35a365d83
commit 2c407f6a55
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -39,41 +39,41 @@ use clap::Subcommand;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
pub mod agent; pub mod agent;
pub mod approval; pub(crate) mod approval;
pub mod auth; pub(crate) mod auth;
pub mod channels; pub mod channels;
pub mod config; pub mod config;
pub mod cost; pub(crate) mod cost;
pub mod cron; pub(crate) mod cron;
pub mod daemon; pub(crate) mod daemon;
pub mod doctor; pub(crate) mod doctor;
pub mod gateway; pub mod gateway;
pub mod hardware; pub(crate) mod hardware;
pub mod health; pub(crate) mod health;
pub mod heartbeat; pub(crate) mod heartbeat;
pub mod identity; pub(crate) mod identity;
pub mod integrations; pub(crate) mod integrations;
pub mod memory; pub mod memory;
pub mod migration; pub(crate) mod migration;
pub mod multimodal; pub(crate) mod multimodal;
pub mod observability; pub mod observability;
pub mod onboard; pub(crate) mod onboard;
pub mod peripherals; pub mod peripherals;
pub mod providers; pub mod providers;
pub mod rag; pub mod rag;
pub mod runtime; pub mod runtime;
pub mod security; pub(crate) mod security;
pub mod service; pub(crate) mod service;
pub mod skills; pub(crate) mod skills;
pub mod tools; pub mod tools;
pub mod tunnel; pub(crate) mod tunnel;
pub mod util; pub(crate) mod util;
pub use config::Config; pub use config::Config;
/// Service management subcommands /// Service management subcommands
#[derive(Subcommand, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] #[derive(Subcommand, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum ServiceCommands { pub(crate) enum ServiceCommands {
/// Install daemon service unit for auto-start and restart /// Install daemon service unit for auto-start and restart
Install, Install,
/// Start daemon service /// Start daemon service
@ -90,7 +90,7 @@ pub enum ServiceCommands {
/// Channel management subcommands /// Channel management subcommands
#[derive(Subcommand, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] #[derive(Subcommand, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum ChannelCommands { pub(crate) enum ChannelCommands {
/// List all configured channels /// List all configured channels
List, List,
/// Start all configured channels (handled in main.rs for async) /// Start all configured channels (handled in main.rs for async)
@ -139,7 +139,7 @@ Examples:
/// Skills management subcommands /// Skills management subcommands
#[derive(Subcommand, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] #[derive(Subcommand, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum SkillCommands { pub(crate) enum SkillCommands {
/// List all installed skills /// List all installed skills
List, List,
/// Install a new skill from a git URL (HTTPS/SSH) or local path /// Install a new skill from a git URL (HTTPS/SSH) or local path
@ -156,7 +156,7 @@ pub enum SkillCommands {
/// Migration subcommands /// Migration subcommands
#[derive(Subcommand, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] #[derive(Subcommand, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum MigrateCommands { pub(crate) enum MigrateCommands {
/// Import memory from an `OpenClaw` workspace into this `ZeroClaw` workspace /// Import memory from an `OpenClaw` workspace into this `ZeroClaw` workspace
Openclaw { Openclaw {
/// Optional path to `OpenClaw` workspace (defaults to ~/.openclaw/workspace) /// Optional path to `OpenClaw` workspace (defaults to ~/.openclaw/workspace)
@ -171,7 +171,7 @@ pub enum MigrateCommands {
/// Cron subcommands /// Cron subcommands
#[derive(Subcommand, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] #[derive(Subcommand, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum CronCommands { pub(crate) enum CronCommands {
/// List all scheduled tasks /// List all scheduled tasks
List, List,
/// Add a new scheduled task /// Add a new scheduled task
@ -286,7 +286,7 @@ Examples:
/// Integration subcommands /// Integration subcommands
#[derive(Subcommand, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] #[derive(Subcommand, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum IntegrationCommands { pub(crate) enum IntegrationCommands {
/// Show details about a specific integration /// Show details about a specific integration
Info { Info {
/// Integration name /// Integration name