Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions cli/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ clap_complete = "4"
dirs = "6"
hmac = "0.13"
inquire = "0.9"
indicatif = "0.18"
jsonschema = "0.46"
keyring-core = "1"
owo-colors = { version = "4", features = ["supports-colors"] }
Expand Down
57 changes: 9 additions & 48 deletions cli/src/cli_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ pub const COMPLETION_CLAP_ABOUT: &str = "Generate deterministic shell completion
pub const COMPLETION_TOP_LEVEL_PURPOSE: &str = "Generate deterministic shell completion scripts";
pub const COMPLETION_SHOW_IN_TOP_LEVEL_HELP: bool = true;

pub const TRACE_CLAP_ABOUT: &str = "Inspect Agent Trace databases and recorded activity";
pub const TRACE_TOP_LEVEL_PURPOSE: &str = "Inspect Agent Trace databases and recorded activity";
pub const TRACE_SHOW_IN_TOP_LEVEL_HELP: bool = true;
pub const SYNC_CLAP_ABOUT: &str =
"Synchronize the current repository's Agent Trace database with the control plane";
pub const SYNC_TOP_LEVEL_PURPOSE: &str =
"Synchronize the current repository's Agent Trace database";
pub const SYNC_SHOW_IN_TOP_LEVEL_HELP: bool = true;

pub const TOP_LEVEL_COMMANDS: &[TopLevelCommandMetadata] = &[
TopLevelCommandMetadata {
Expand Down Expand Up @@ -93,9 +95,9 @@ pub const TOP_LEVEL_COMMANDS: &[TopLevelCommandMetadata] = &[
show_in_top_level_help: COMPLETION_SHOW_IN_TOP_LEVEL_HELP,
},
TopLevelCommandMetadata {
name: crate::services::trace::NAME,
purpose: TRACE_TOP_LEVEL_PURPOSE,
show_in_top_level_help: TRACE_SHOW_IN_TOP_LEVEL_HELP,
name: crate::services::sync::NAME,
purpose: SYNC_TOP_LEVEL_PURPOSE,
show_in_top_level_help: SYNC_SHOW_IN_TOP_LEVEL_HELP,
},
];

Expand Down Expand Up @@ -230,54 +232,13 @@ pub enum Commands {
shell: CompletionShell,
},

#[command(about = TRACE_CLAP_ABOUT, hide = !TRACE_SHOW_IN_TOP_LEVEL_HELP)]
Trace {
#[command(subcommand)]
subcommand: TraceSubcommand,
},
}

#[derive(Subcommand, Debug, Clone, PartialEq, Eq)]
pub enum TraceSubcommand {
#[command(about = "Inspect discovered Agent Trace databases")]
Db {
#[command(subcommand)]
subcommand: TraceDbSubcommand,
},

#[command(about = "Show Agent Trace activity for the current repository (or all with --all)")]
Status {
#[arg(long)]
all: bool,

#[arg(long, value_enum, default_value_t = OutputFormat::Text)]
format: OutputFormat,
},

#[command(
about = "Synchronize the current repository's Agent Trace database with the control plane"
)]
#[command(about = SYNC_CLAP_ABOUT, hide = !SYNC_SHOW_IN_TOP_LEVEL_HELP)]
Sync {
#[arg(long, value_enum, default_value_t = OutputFormat::Text)]
format: OutputFormat,
},
}

#[derive(Subcommand, Debug, Clone, PartialEq, Eq)]
pub enum TraceDbSubcommand {
#[command(about = "List discovered Agent Trace databases with readiness")]
List {
#[arg(long, value_enum, default_value_t = OutputFormat::Text)]
format: OutputFormat,
},

#[command(about = "Open an embedded SQL shell for an Agent Trace database")]
Shell {
#[arg(value_name = "repository-id-or-alias")]
identifier: Option<String>,
},
}

#[derive(Subcommand, Debug, Clone, PartialEq, Eq)]
pub enum AuthSubcommand {
#[command(about = "Start login flow and store credentials")]
Expand Down
4 changes: 2 additions & 2 deletions cli/src/services/agent_trace_sync/control_plane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl fmt::Display for ControlPlaneError {
match self {
Self::MissingCredentials => write!(
f,
"No stored WorkOS credentials were found. Try: run 'sce auth login' before running 'sce trace sync'."
"No stored WorkOS credentials were found. Try: run 'sce auth login' before running 'sce sync'."
),
Self::AuthenticationFailed(reason) => write!(
f,
Expand Down Expand Up @@ -285,7 +285,7 @@ impl AuthenticatedControlPlaneClient {
let outcome = run_with_retry(
policy,
"agent_trace_sync.ingestion_state",
"check network connectivity and control-plane availability, then rerun 'sce trace sync'",
"check network connectivity and control-plane availability, then rerun 'sce sync'",
|_attempt| {
let url = url.clone();
async move {
Expand Down
3 changes: 1 addition & 2 deletions cli/src/services/checkout/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
//! string, consistent with the existing `agent_trace_id` convention in this
//! codebase.
//!
//! Checkout databases are discovered via filesystem scan in `sce trace db list`
//! (see `cli/src/services/trace/`). There is no central registry file.
//! Checkout identity is repository metadata used by Agent Trace diagnostics.

use std::path::{Path, PathBuf};
use std::process::Command;
Expand Down
26 changes: 11 additions & 15 deletions cli/src/services/command_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const DEFAULT_COMMAND_NAMES: &[&str] = &[
services::hooks::NAME,
services::bash_policy::NAME,
services::setup::NAME,
services::trace::NAME,
services::sync::NAME,
services::version::NAME,
];

Expand All @@ -34,7 +34,7 @@ pub enum RuntimeCommand {
Policy(services::bash_policy::command::PolicyCommand),
Version(services::version::command::VersionCommand),
Completion(services::completion::command::CompletionCommand),
Trace(services::trace::command::TraceCommand),
Sync(services::sync::command::SyncCommand),
}

impl RuntimeCommand {
Expand All @@ -50,7 +50,7 @@ impl RuntimeCommand {
Self::Policy(_) => Cow::Borrowed(services::bash_policy::NAME),
Self::Version(_) => Cow::Borrowed(services::version::NAME),
Self::Completion(_) => Cow::Borrowed(services::completion::NAME),
Self::Trace(_) => Cow::Borrowed(services::trace::NAME),
Self::Sync(_) => Cow::Borrowed(services::sync::NAME),
}
}

Expand Down Expand Up @@ -83,7 +83,7 @@ impl RuntimeCommand {
Self::Policy(command) => command.execute(),
Self::Version(command) => command.execute(context),
Self::Completion(command) => Ok(command.execute(context)),
Self::Trace(command) => command.execute_with_stderr(context, stderr),
Self::Sync(command) => command.execute_with_stderr(context, stderr),
}
}
}
Expand Down Expand Up @@ -192,15 +192,11 @@ pub fn default_runtime_command(name: &str) -> Option<RuntimeCommand> {
},
},
)),
services::trace::NAME => Some(RuntimeCommand::Trace(
services::trace::command::TraceCommand {
request: services::trace::TraceRequest {
subcommand: services::trace::TraceSubcommandRequest::DbList {
format: services::output_format::OutputFormat::Text,
},
},
services::sync::NAME => Some(RuntimeCommand::Sync(services::sync::command::SyncCommand {
request: services::sync::SyncRequest {
format: services::output_format::OutputFormat::Text,
},
)),
})),
_ => None,
}
}
Expand All @@ -224,7 +220,7 @@ mod tests {
"hooks",
"policy",
"setup",
"trace",
"sync",
"version"
]
);
Expand All @@ -237,7 +233,7 @@ mod tests {
for name in DEFAULT_COMMAND_NAMES {
assert!(registry.contains(name));
}
assert!(!registry.contains("sync"));
assert!(registry.contains("sync"));
}

#[test]
Expand All @@ -246,6 +242,6 @@ mod tests {
let command = default_runtime_command(name).expect("command should exist");
assert_eq!(command.name(), *name);
}
assert!(default_runtime_command("sync").is_none());
assert!(default_runtime_command("sync").is_some());
}
}
2 changes: 1 addition & 1 deletion cli/src/services/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ pub mod security;
pub mod setup;
pub mod structured_patch;
pub mod style;
pub mod sync;
pub mod token_storage;
pub mod trace;
pub mod version;
Loading
Loading