mirror of
https://github.com/block/buzz.git
synced 2026-11-08 18:31:56 +00:00
chore: remove LLM-slop comments across the codebase (#1277)
Signed-off-by: Tyler Longwell <tlongwell@block.xyz> Co-authored-by: npub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67d <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Max <d8473ee32b973aa31a21a65adddcc4b69cc2a8a4dee8121ecd51926e0cddbc02@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Mari <95cae996907d7cab9f5dbf43c0f53edeac6ab0b032a6feae4abfd784e467b3f5@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Quinn <96f056ad5f2305c8ddf637dc65d048aa4c12d7daeb8867690e34fca46b0ef64c@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Sami <f4a42a97e594b77bdbd8ee35191c8b28a94a4cb871d96f32921558275421fb68@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Perci <5a968df9a7494b4e019b9ecf739e088ba61097b4312124e9a88ae5b42e3f5f3e@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Tyler Longwell <tlongwell@block.xyz>
This commit is contained in:
@@ -7,10 +7,6 @@ use sha2::{Digest, Sha256};
|
||||
|
||||
use crate::error::CliError;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Blob / Media types
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Descriptor returned by the relay after a successful upload.
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct BlobDescriptor {
|
||||
@@ -78,10 +74,6 @@ const MAX_IMAGE_BYTES: u64 = 50 * 1024 * 1024;
|
||||
/// Maximum file size for video uploads (500 MB).
|
||||
const MAX_VIDEO_BYTES: u64 = 500 * 1024 * 1024;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// NIP-98 HTTP Auth
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Sign a NIP-98 HTTP auth event (kind:27235) and return the Authorization header value.
|
||||
///
|
||||
/// The event includes:
|
||||
@@ -116,10 +108,6 @@ fn sign_nip98(
|
||||
Ok(format!("Nostr {}", B64.encode(json.as_bytes())))
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// BuzzClient
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
pub struct BuzzClient {
|
||||
http: reqwest::Client,
|
||||
relay_url: String, // base URL, no trailing slash, e.g. "https://relay.buzz.place"
|
||||
@@ -213,10 +201,6 @@ impl BuzzClient {
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// HTTP Bridge: POST /query
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/// Execute a one-shot query via the HTTP bridge.
|
||||
/// `filter` is a Nostr filter object (will be wrapped in an array).
|
||||
/// Returns the raw JSON response (array of events).
|
||||
@@ -261,10 +245,6 @@ impl BuzzClient {
|
||||
self.handle_response(resp).await
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// HTTP Bridge: POST /events
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/// Submit a signed Nostr event via POST /events.
|
||||
pub async fn submit_event(&self, event: nostr::Event) -> Result<String, CliError> {
|
||||
let url = format!("{}/events", self.relay_url);
|
||||
@@ -283,10 +263,6 @@ impl BuzzClient {
|
||||
self.handle_response(resp).await
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// WebSocket publish (ephemeral events)
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/// Publish an ephemeral event via WebSocket with NIP-42 authentication.
|
||||
///
|
||||
/// The relay rejects ephemeral kinds (20000–29999) over HTTP. Delegates to
|
||||
@@ -313,10 +289,6 @@ impl BuzzClient {
|
||||
.to_string())
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// File upload (Blossom protocol)
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/// Upload a file to the relay's Blossom endpoint.
|
||||
/// Returns a BlobDescriptor on success.
|
||||
pub async fn upload_file(&self, file_path: &str) -> Result<BlobDescriptor, CliError> {
|
||||
@@ -423,10 +395,6 @@ impl BuzzClient {
|
||||
.map_err(|e| CliError::Other(format!("invalid upload response: {e}")))
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Response handling
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
async fn handle_response(&self, resp: reqwest::Response) -> Result<String, CliError> {
|
||||
if !resp.status().is_success() {
|
||||
let status = resp.status().as_u16();
|
||||
@@ -458,10 +426,6 @@ impl BuzzClient {
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// URL normalization
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Normalize a relay URL: ws:// → http://, wss:// → https://, strip trailing slash.
|
||||
/// BUZZ_RELAY_URL may be ws/wss (copied from MCP config).
|
||||
pub fn normalize_relay_url(url: &str) -> String {
|
||||
@@ -478,10 +442,6 @@ fn to_ws_url(http_url: &str) -> String {
|
||||
.replace("http://", "ws://")
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Output normalization helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Normalize raw event JSON array into consistent shape.
|
||||
/// Each event becomes: {id, pubkey, kind, content, created_at, tags}
|
||||
pub fn normalize_events(events: &[serde_json::Value]) -> String {
|
||||
|
||||
@@ -7,10 +7,6 @@ use crate::client::{
|
||||
use crate::error::CliError;
|
||||
use crate::validate::{parse_uuid, read_or_stdin, validate_hex64, validate_uuid};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Read commands — POST /query
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
fn extract_channel_metadata(e: &serde_json::Value) -> serde_json::Value {
|
||||
serde_json::json!({
|
||||
"channel_id": extract_d_tag(e),
|
||||
@@ -287,10 +283,6 @@ pub async fn cmd_get_canvas(client: &BuzzClient, channel_id: &str) -> Result<(),
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Write commands — signed events via POST /events
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
pub async fn cmd_create_channel(
|
||||
client: &BuzzClient,
|
||||
name: &str,
|
||||
@@ -566,10 +558,6 @@ pub async fn cmd_set_canvas(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Dispatch
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
pub async fn dispatch(
|
||||
cmd: crate::ChannelsCmd,
|
||||
client: &BuzzClient,
|
||||
|
||||
@@ -125,10 +125,6 @@ pub async fn cmd_add_dm_member(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Dispatch
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
pub async fn dispatch(cmd: crate::DmsCmd, client: &BuzzClient) -> Result<(), CliError> {
|
||||
use crate::DmsCmd;
|
||||
match cmd {
|
||||
|
||||
@@ -308,10 +308,6 @@ async fn cmd_import(
|
||||
publish_own_set(client, &final_set).await
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Dispatch
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
pub async fn dispatch(cmd: crate::EmojiCmd, client: &BuzzClient) -> Result<(), CliError> {
|
||||
use crate::EmojiCmd;
|
||||
match cmd {
|
||||
|
||||
@@ -64,10 +64,6 @@ pub async fn cmd_get_feed(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Dispatch
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
pub async fn dispatch(
|
||||
cmd: crate::FeedCmd,
|
||||
client: &BuzzClient,
|
||||
|
||||
@@ -3,10 +3,6 @@ use crate::error::CliError;
|
||||
use crate::validate::{read_or_stdin, sdk_err, validate_hex64, validate_repo_id};
|
||||
use buzz_sdk::{GitIssueMeta, GitRepoCoord, GitStatusMeta};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Create issue — publish kind:1621
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
pub async fn cmd_create_issue(
|
||||
client: &BuzzClient,
|
||||
repo_owner: &str,
|
||||
@@ -37,10 +33,6 @@ pub async fn cmd_create_issue(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Get issue — query kind:1621 by event id
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
pub async fn cmd_get_issue(client: &BuzzClient, event: &str) -> Result<(), CliError> {
|
||||
validate_hex64(event)?;
|
||||
let filter = serde_json::json!({
|
||||
@@ -52,10 +44,6 @@ pub async fn cmd_get_issue(client: &BuzzClient, event: &str) -> Result<(), CliEr
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// List issues — query kind:1621 by repo coordinate, with optional filters
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
pub async fn cmd_list_issues(
|
||||
client: &BuzzClient,
|
||||
repo_owner: &str,
|
||||
@@ -89,10 +77,6 @@ pub async fn cmd_list_issues(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Status — publish kind:1630/1631/1632/1633 against an issue
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn cmd_issue_status(
|
||||
client: &BuzzClient,
|
||||
@@ -160,10 +144,6 @@ pub async fn cmd_issue_status(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Dispatch
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
pub async fn dispatch(cmd: crate::IssuesCmd, client: &BuzzClient) -> Result<(), CliError> {
|
||||
use crate::IssuesCmd;
|
||||
match cmd {
|
||||
|
||||
@@ -734,10 +734,6 @@ pub async fn cmd_rm(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Dispatch
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
pub async fn dispatch(cmd: crate::MemCmd, client: &BuzzClient) -> Result<(), CliError> {
|
||||
use crate::MemCmd;
|
||||
match cmd {
|
||||
|
||||
@@ -13,10 +13,6 @@ use buzz_sdk::mentions::{
|
||||
MENTION_CAP,
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Extract the thread root event ID from a Nostr tag array.
|
||||
///
|
||||
/// Parses `"e"` tags with NIP-10 markers:
|
||||
@@ -243,10 +239,6 @@ fn parse_member_pubkeys(event: &serde_json::Value) -> Vec<String> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Read commands — POST /query
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
fn format_events(normalized: &str, format: &crate::OutputFormat) -> String {
|
||||
match format {
|
||||
crate::OutputFormat::Compact => {
|
||||
@@ -364,10 +356,6 @@ pub async fn cmd_search(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Write commands — signed events via POST /events
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
pub struct SendMessageParams {
|
||||
pub channel_id: String,
|
||||
pub content: String,
|
||||
@@ -634,10 +622,6 @@ pub async fn cmd_vote_on_post(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Dispatch
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
pub async fn dispatch(
|
||||
cmd: crate::MessagesCmd,
|
||||
client: &BuzzClient,
|
||||
@@ -816,7 +800,6 @@ mod tests {
|
||||
assert!(find_root_from_tags(&json!(null)).is_none());
|
||||
}
|
||||
|
||||
// ── @mention resolution pipeline ────────────────────────────────────
|
||||
//
|
||||
// These tests don't hit the network — they prove that *given* the
|
||||
// events the relay returns, the CLI's parse + match wiring produces
|
||||
|
||||
@@ -41,10 +41,6 @@ pub const KIND_LONG_FORM: u16 = 30023;
|
||||
/// comfortably URL/filename-safe and matches `mem` slug ergonomics.
|
||||
pub const SLUG_MAX_LEN: usize = 80;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Slug validation
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Validate and normalize a slug for use as a NIP-23 `d` tag.
|
||||
///
|
||||
/// Rules: 1..=80 chars, `[a-z0-9._-]` only. Lowercase ascii keeps memory
|
||||
@@ -72,10 +68,6 @@ pub fn parse_slug(raw: &str) -> Result<String, CliError> {
|
||||
Ok(raw.to_string())
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// NoteSnapshot — parsed view of a kind:30023 event, derived once
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Parsed view of a NIP-23 long-form event. Built once via
|
||||
/// [`NoteSnapshot::from_event`] so the tag-parsing footgun lives in exactly
|
||||
/// one place; `set` (carry-forward), `get`/`ls` (output shaping), and the
|
||||
@@ -161,10 +153,6 @@ impl NoteSnapshot {
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Query helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
fn parse_events(json: &str) -> Result<Vec<Event>, CliError> {
|
||||
serde_json::from_str::<Vec<Event>>(json)
|
||||
.map_err(|e| CliError::Other(format!("failed to parse relay response: {e}")))
|
||||
@@ -206,10 +194,6 @@ pub async fn fetch_by_slug(client: &BuzzClient, slug: &str) -> Result<Vec<Event>
|
||||
parse_events(&raw)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Author resolution
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Resolve an `--author` flag value to a `PublicKey`.
|
||||
///
|
||||
/// Accepts:
|
||||
@@ -259,10 +243,6 @@ pub async fn resolve_author(client: &BuzzClient, author_flag: &str) -> Result<Pu
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Coordinate parsing (naddr / kind:pk:d / NIP-21)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Parse a `--naddr` flag. Accepts:
|
||||
/// - bech32 `naddr1…`
|
||||
/// - `<kind>:<pubkey-hex>:<d-tag>` (KPI format)
|
||||
@@ -293,10 +273,6 @@ pub fn coord_for(author: &PublicKey, slug: &str) -> nostr::nips::nip01::Coordina
|
||||
.identifier(slug.to_string())
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Candidate formatting (used when --name resolves to >1 author)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Format a list of candidate notes for the "ambiguous slug" error path.
|
||||
/// One line per candidate; sorted newest-first. Designed so the user can
|
||||
/// paste a pubkey into a follow-up `--author <hex>` invocation.
|
||||
@@ -320,10 +296,6 @@ pub fn format_note_candidates(snapshots: &[NoteSnapshot]) -> String {
|
||||
out
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Output helpers for `get` / `ls`
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#[derive(Debug, serde::Serialize)]
|
||||
struct NoteOutput {
|
||||
id: String,
|
||||
@@ -417,10 +389,6 @@ fn sort_snapshots_newest_first(snapshots: &mut [NoteSnapshot]) {
|
||||
snapshots.sort_by_key(|s| std::cmp::Reverse(s.updated_at));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Event builder for `set` — pure, unit-testable carry-forward logic
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Build the unsigned `EventBuilder` for `notes set`. Pure function — no I/O,
|
||||
/// no clock — so every carry/clear/first-publish case is unit-testable.
|
||||
///
|
||||
@@ -516,10 +484,6 @@ fn now_secs() -> u64 {
|
||||
/// far above any realistic skill-KB note.
|
||||
pub const SET_STDIN_MAX_BYTES: usize = 1024 * 1024;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Dispatch — stubs for verb implementations (filled by follow-up commits).
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
pub async fn cmd_set(
|
||||
client: &BuzzClient,
|
||||
slug: &str,
|
||||
|
||||
@@ -5,10 +5,6 @@ use crate::validate::{
|
||||
};
|
||||
use buzz_sdk::{GitAppliedPatchRef, GitPatchMeta, GitRepoCoord, GitStatus, GitStatusMeta};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Send patch — publish kind:1617
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn cmd_send_patch(
|
||||
client: &BuzzClient,
|
||||
@@ -74,10 +70,6 @@ fn parse_committer(spec: &str) -> Result<(String, String, String, String), CliEr
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Get patch — query kind:1617 by event id
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
pub async fn cmd_get_patch(client: &BuzzClient, event: &str) -> Result<(), CliError> {
|
||||
validate_hex64(event)?;
|
||||
let filter = serde_json::json!({
|
||||
@@ -89,10 +81,6 @@ pub async fn cmd_get_patch(client: &BuzzClient, event: &str) -> Result<(), CliEr
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// List patches — query kind:1617 by repo coordinate, with optional filters
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
pub async fn cmd_list_patches(
|
||||
client: &BuzzClient,
|
||||
repo_owner: &str,
|
||||
@@ -122,10 +110,6 @@ pub async fn cmd_list_patches(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Status — publish kind:1630/1631/1632/1633 against a patch root
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn cmd_patch_status(
|
||||
client: &BuzzClient,
|
||||
@@ -219,10 +203,6 @@ pub(crate) fn parse_status(s: &str) -> Result<GitStatus, CliError> {
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Dispatch
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
pub async fn dispatch(cmd: crate::PatchesCmd, client: &BuzzClient) -> Result<(), CliError> {
|
||||
use crate::PatchesCmd;
|
||||
match cmd {
|
||||
|
||||
@@ -124,10 +124,6 @@ pub async fn cmd_get_reactions(client: &BuzzClient, event_id: &str) -> Result<()
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Dispatch
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
pub async fn dispatch(cmd: crate::ReactionsCmd, client: &BuzzClient) -> Result<(), CliError> {
|
||||
use crate::ReactionsCmd;
|
||||
match cmd {
|
||||
|
||||
@@ -2,10 +2,6 @@ use crate::client::BuzzClient;
|
||||
use crate::error::CliError;
|
||||
use crate::validate::validate_repo_id;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Create repo — publish kind:30617
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
pub async fn cmd_create_repo(
|
||||
client: &BuzzClient,
|
||||
repo_id: &str,
|
||||
@@ -36,10 +32,6 @@ pub async fn cmd_create_repo(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Get repo — query kind:30617 by owner + d-tag
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
pub async fn cmd_get_repo(
|
||||
client: &BuzzClient,
|
||||
repo_id: &str,
|
||||
@@ -64,10 +56,6 @@ pub async fn cmd_get_repo(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// List repos — query kind:30617 by author
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
pub async fn cmd_list_repos(
|
||||
client: &BuzzClient,
|
||||
owner: Option<&str>,
|
||||
@@ -96,10 +84,6 @@ pub async fn cmd_list_repos(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Dispatch
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
pub async fn dispatch(cmd: crate::ReposCmd, client: &BuzzClient) -> Result<(), CliError> {
|
||||
use crate::ReposCmd;
|
||||
match cmd {
|
||||
|
||||
@@ -208,10 +208,6 @@ pub async fn cmd_get_list(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Dispatch
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
pub async fn dispatch(cmd: crate::SocialCmd, client: &BuzzClient) -> Result<(), CliError> {
|
||||
use crate::SocialCmd;
|
||||
match cmd {
|
||||
|
||||
@@ -290,10 +290,6 @@ pub async fn cmd_set_presence(client: &BuzzClient, status: &str) -> Result<(), C
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Dispatch
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
pub async fn dispatch(
|
||||
cmd: crate::UsersCmd,
|
||||
client: &BuzzClient,
|
||||
|
||||
@@ -9,10 +9,6 @@ use crate::validate::{parse_uuid, read_or_stdin, sdk_err, validate_uuid};
|
||||
|
||||
// TODO(phase-4): Replace raw nostr::EventBuilder usage with buzz-sdk builder functions
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Read commands — POST /query
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// List workflows in a channel — query kind:30620 workflow definition events.
|
||||
pub async fn cmd_list_workflows(client: &BuzzClient, channel_id: &str) -> Result<(), CliError> {
|
||||
validate_uuid(channel_id)?;
|
||||
@@ -98,10 +94,6 @@ pub async fn cmd_get_workflow_runs(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Write commands — signed events via POST /events
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Create a workflow — sign and submit a kind:30620 event.
|
||||
pub async fn cmd_create_workflow(
|
||||
client: &BuzzClient,
|
||||
@@ -219,10 +211,6 @@ pub async fn cmd_approve_step(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Dispatch
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
pub async fn dispatch(cmd: crate::WorkflowsCmd, client: &BuzzClient) -> Result<(), CliError> {
|
||||
use crate::WorkflowsCmd;
|
||||
match cmd {
|
||||
|
||||
@@ -45,10 +45,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Top-level CLI
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(
|
||||
name = "buzz",
|
||||
@@ -87,10 +83,6 @@ struct Cli {
|
||||
command: Cmd,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Value enums for typed --type / --visibility / --status flags
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#[derive(Clone, clap::ValueEnum)]
|
||||
pub enum ChannelType {
|
||||
#[value(name = "stream")]
|
||||
@@ -165,10 +157,6 @@ pub enum OutputFormat {
|
||||
Compact,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Subcommand groups
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#[derive(Subcommand)]
|
||||
enum Cmd {
|
||||
/// Send, read, search, and manage messages
|
||||
@@ -224,10 +212,6 @@ enum Cmd {
|
||||
Pack(PackCmd),
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Messages subcommands
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum MessagesCmd {
|
||||
/// Send a message to a channel
|
||||
@@ -364,10 +348,6 @@ pub enum MessagesCmd {
|
||||
},
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Channels subcommands
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum ChannelsCmd {
|
||||
/// List channels visible to the current identity
|
||||
@@ -536,10 +516,6 @@ pub enum ChannelsCmd {
|
||||
},
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Canvas subcommands
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum CanvasCmd {
|
||||
/// Get the canvas document for a channel
|
||||
@@ -559,10 +535,6 @@ pub enum CanvasCmd {
|
||||
},
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Reactions subcommands
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum ReactionsCmd {
|
||||
/// Add an emoji reaction to a message
|
||||
@@ -594,10 +566,6 @@ pub enum ReactionsCmd {
|
||||
},
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Custom emoji subcommands
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum EmojiCmd {
|
||||
/// List the workspace custom emoji palette (union of every member's set)
|
||||
@@ -640,10 +608,6 @@ pub enum EmojiCmd {
|
||||
},
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// DMs subcommands
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum DmsCmd {
|
||||
/// List direct message conversations
|
||||
@@ -675,10 +639,6 @@ pub enum DmsCmd {
|
||||
},
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Users subcommands
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum UsersCmd {
|
||||
/// Look up user profiles by pubkey or name
|
||||
@@ -721,10 +681,6 @@ pub enum UsersCmd {
|
||||
},
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Workflows subcommands
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum WorkflowsCmd {
|
||||
/// List workflows in a channel
|
||||
@@ -804,10 +760,6 @@ pub enum WorkflowsCmd {
|
||||
},
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Feed subcommands
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum FeedCmd {
|
||||
/// Get recent activity feed entries
|
||||
@@ -824,10 +776,6 @@ pub enum FeedCmd {
|
||||
},
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Social subcommands
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum SocialCmd {
|
||||
/// Publish a text note (NIP-01 kind:1)
|
||||
@@ -905,10 +853,6 @@ pub enum SocialCmd {
|
||||
},
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Notes subcommands (NIP-23 long-form)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum NotesCmd {
|
||||
/// Create or update a note. Idempotent upsert keyed by `(me, --name)`.
|
||||
@@ -988,10 +932,6 @@ pub enum NotesCmd {
|
||||
},
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Repos subcommands
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum ReposCmd {
|
||||
/// Announce a git repository (NIP-34)
|
||||
@@ -1035,10 +975,6 @@ pub enum ReposCmd {
|
||||
},
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Patches subcommands
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum PatchesCmd {
|
||||
/// Send a git patch (NIP-34 kind:1617)
|
||||
@@ -1145,10 +1081,6 @@ pub enum PatchesCmd {
|
||||
},
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Issues subcommands
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum IssuesCmd {
|
||||
/// Create a git issue (NIP-34 kind:1621)
|
||||
@@ -1224,10 +1156,6 @@ pub enum IssuesCmd {
|
||||
},
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Upload subcommands
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum UploadCmd {
|
||||
/// Upload a file to the relay's Blossom store
|
||||
@@ -1238,10 +1166,6 @@ pub enum UploadCmd {
|
||||
},
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Mem subcommands (NIP-AE)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Subcommands for `buzz mem`.
|
||||
#[derive(Subcommand)]
|
||||
pub enum MemCmd {
|
||||
@@ -1325,10 +1249,6 @@ pub enum MemCmd {
|
||||
},
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Pack subcommands (local, no relay connection needed)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Subcommands for `buzz pack`.
|
||||
#[derive(Subcommand)]
|
||||
pub enum PackCmd {
|
||||
@@ -1344,10 +1264,6 @@ pub enum PackCmd {
|
||||
},
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Command dispatch
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
async fn run(cli: Cli) -> Result<(), CliError> {
|
||||
let relay_url = client::normalize_relay_url(&cli.relay);
|
||||
|
||||
@@ -1406,10 +1322,6 @@ async fn run(cli: Cli) -> Result<(), CliError> {
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Tests
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
@@ -419,8 +419,6 @@ mod tests {
|
||||
assert!(super::parse_uuid("not-a-uuid").is_err());
|
||||
}
|
||||
|
||||
// ── validate_repo_id ─────────────────────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn validate_repo_id_valid() {
|
||||
assert!(super::validate_repo_id("my-repo").is_ok());
|
||||
|
||||
Reference in New Issue
Block a user