Skip to content

feat(cli): digest command for windowed per-channel summary#46

Open
mvanhorn wants to merge 2 commits intosteipete:mainfrom
mvanhorn:feat/digest-windowed-per-channel-summary
Open

feat(cli): digest command for windowed per-channel summary#46
mvanhorn wants to merge 2 commits intosteipete:mainfrom
mvanhorn:feat/digest-windowed-per-channel-summary

Conversation

@mvanhorn
Copy link
Copy Markdown

Simulated Demo

Summary

Adds discrawl digest, a per-channel activity summary over a time window. discrawl already has report for repo-wide README dumps and messages / search for retrieval; digest answers "what happened in this guild over the last N days, per channel."

Ports vincentkoc/slacrawl#9 (merged 2026-04-22). Same SQL recipe, adapted to discrawl's Discord schema (guild_id, members, mention_events) and the existing stdlib-flag CLI dispatch.

Why this matters

  • Issue Using discrawl as memory augmentation for AI agents #15 (@codexGW's writeup on using discrawl as memory augmentation for AI agents) describes building a --mode raw|distilled|auto reader on top of discrawl's FTS5 tables. A built-in digest gives that workflow a first-class entry point.
  • The schema, indexes (idx_messages_guild_created_id, idx_mentions_guild_event), and internal/report/ package are already exactly what digest needs. One SQL recipe away.
  • Keeps the focused-commands shape. Per-channel windowed activity is one of the most-asked questions of an org-memory archive.

Output

$ discrawl digest --since 7d

general (text)
  messages=42 threads=3 authors=8
  top posters  alice (12), bob (9), carol (7)
  top mentions @oncall (4), @sre (2)

incidents (text)
  messages=11 threads=2 authors=4
  top posters  alice (5), dave (3)
  top mentions @oncall-bot (3)

releases (text)
  messages=4 threads=1 authors=2
  top posters  carol (3)
  top mentions -

Window: 2026-04-18 to 2026-04-25 (7d)
Totals: messages=57 threads=6 channels=3 authors=11

Flags

  • --since lookback window. Accepts Go durations (72h) plus Nd shorthand (7d, 30d). Default 7d.
  • --guild filter to one guild. When omitted, falls back to default_guild_id from config when set.
  • --channel drill into one channel by id or name.
  • --top-n number of top posters / mention targets per channel. Default 3.
  • Inherits --json and --plain from the root CLI.

Scope

  • No schema changes. Uses existing messages / channels / members / mention_events tables.
  • No new dependencies in go.mod.
  • New: internal/report/digest.go, internal/report/digest_test.go, internal/cli/digest.go, internal/cli/digest_test.go.
  • Touched: internal/cli/cli.go (one switch case), internal/cli/output.go (text and plain renderers + usage), internal/report/report.go (added snake_case JSON tags to RankedCount), README.md, SPEC.md.
  • Tests cover: happy path, window filter, channel filter (id and name), guild filter, default top-n, top-mentions ranking, negative-since normalization, JSON output schema, CLI dispatch.

Test plan

  • gofmt -l . clean
  • go vet ./... clean
  • go build ./cmd/discrawl
  • go test ./... passes (11 packages, all green)

Self-reviewed via codex review before pushing. Found one snake_case JSON tag inconsistency on RankedCount, fixed in a follow-up commit on this branch.

Open questions

  1. Default --top-n: went with 3 to match what report already does internally for top channels and authors. Happy to change to 1 or 5.
  2. Naming: digest matched the natural framing vs summary or folding into report --digest. The slacrawl PR went the same direction; happy to rename.
  3. Helper sharing: kept digest's SQL local to internal/report/digest.go. If you'd rather factor topPosters / topMentions style helpers into report.go so both commands share them later, easy follow-up.
  4. JSON tag change on RankedCount: added json:"name" and json:"count" so digest's top_posters and top_mentions serialize as snake_case (consistent with the rest of the digest schema). The existing report command renders Markdown, so this change is observable only via JSON consumers; no current caller uses JSON for RankedCount.

Related work

This is the first half of a two-PR sequence. The follow-up is discrawl analytics (subcommand group with quiet and trends), porting vincentkoc/slacrawl#13. Stacked on top of this PR so analytics digest can shim to runDigest and share the implementation.

This contribution was developed with AI assistance.

Adds discrawl digest, a per-channel activity summary over a time window.
discrawl already has report for repo-wide README dumps and messages /
search for retrieval; digest answers what happened in this guild over
the last N days, per channel.

Ports vincentkoc/slacrawl#9 (merged 2026-04-22). Same SQL recipe,
adapted to discrawl's Discord schema (guild_id, members, mention_events)
and the existing stdlib-flag CLI dispatch.

This contribution was developed with AI assistance.
RankedCount is reused by digest's top_posters/top_mentions slices.
Without JSON tags, those nested entries serialized as {Name, Count}
while the rest of the digest schema uses snake_case ({channel_id,
messages, ...}). Tag the fields so --json output is consistent.

Surfaced by codex review on the previous commit.
@chatgpt-codex-connector
Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant