feat(cli): add channels search for human-readable channel lookup#712
Open
tlongwell-block wants to merge 1 commit into
Open
feat(cli): add channels search for human-readable channel lookup#712tlongwell-block wants to merge 1 commit into
channels search for human-readable channel lookup#712tlongwell-block wants to merge 1 commit into
Conversation
Adds a new subcommand that searches NIP-29 kind:39000 group-metadata
events by channel name. Returns a stable JSON projection
({channel_id, name, channel_type, visibility, archived, about,
topic, purpose}), sorted by name + channel_id for determinism.
- Case-insensitive substring match by default; `--exact` for exact.
- `--include-archived` (default: exclude archived).
- `--limit` defaults to 1000 (the DB's soft cap for un-tuned
REQ queries; explicit value avoids surprise truncation).
- Relay-side access control already filters kind:39000 events to
channels the caller can see, so no new auth logic is required.
NIP-50 search is not used: the relay's Typesense index indexes
`content`, and kind:39000's name lives in tags with empty content.
Unit-tested: tag extraction (happy path, archived, private,
missing required tags, malformed tags) and the name-match predicate.
Signed-off-by: tlongwell-block <109685178+tlongwell-block@users.noreply.github.com>
Co-authored-by: Dawn (sprout agent) <c6237ef84fa537c78dcee78efd2d4e59f728859c7f194da42ac51ededfa0be05@sprout-oss.stage.blox.sqprod.co>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
sprout channels search --query <name>so humans and agents can resolve a channel UUID from a human-readable name without opening channel settings or guessing.Acceptance from the brief in
cli-channel-lookup:What's in the diff
ChannelsCmd::Search { query, exact, include_archived, limit }variant incrates/sprout-cli/src/lib.rs.cmd_search_channels+ChannelSummary::from_event+name_matchesincrates/sprout-cli/src/commands/channels.rs, plus a dispatch arm.Stable JSON projection per result:
{ "channel_id": "…", "name": "…", "channel_type": "stream" | "forum" | …, "visibility": "public" | "private", "archived": false, "about": "…" | null, "topic": "…" | null, "purpose": "…" | null }Sorted by
name, thenchannel_idfor determinism.Design notes
side_effects::emit_group_discovery_eventswithname,about,t,private/public,archived,topic,purpose. The existingchannels list/getquery kind:39002 (membership) and so have no name tag at all — addressing that is intentionally out of scope here to avoid breaking scripts.query_by: "content", and kind:39000 events have emptycontent— the name lives in tags. A plain{kinds:[39000]}query plus client-side post-filter is simpler and correct.crates/sprout-relay/src/handlers/req.rsalready runs per-eventaccessible_channelschecks on globally-filtered queries, so private channels the caller can't see are dropped server-side.query_eventsat 1000 anyway; making it explicit avoids surprise truncation.--exactreturns all case-insensitive exact matches. Channel names are not unique (no DB UNIQUE constraint, no "name taken" path on the relay — only repos have that), so the flag narrows, not necessarily to one.Example
Verification
cargo build -p sprout-cli✓cargo test -p sprout-cli --lib channels— 7/7 ✓cargo clippy -p sprout-cli --all-targets -- -D warnings✓cargo fmt -p sprout-cli --check✓--exact,--query ""(rejected), unknown-query →[],--help.Review
Plan was iterated to 9/10+ with Max (GPT-5.5) before implementation; diff was independently reviewed by Max (build, clippy, fmt, tests, live behavior, DCO trailer) and signed off. Thread: https://github.com/block/sprout channel
cli-channel-lookup.Follow-ups (not in this PR)
channels list/channels getcurrently return raw kind:39002 events with no name. Worth switching to kind:39000 in a small follow-up, but it changes the JSON shape and is intentionally separated to avoid breaking scripts in this PR.