|
| 1 | +# Smart Read Feature - Summary |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +Added a new smart `prbot slack read <url>` command that auto-detects Slack URL types and handles them appropriately, making it much easier to interact with Slack content. |
| 6 | + |
| 7 | +## Key Features |
| 8 | + |
| 9 | +### 1. Auto-Detection of URL Types |
| 10 | + |
| 11 | +The command automatically detects three types of Slack URLs: |
| 12 | + |
| 13 | +- **Message URLs**: Reads nearby messages (20 before + 20 after) with target highlighted |
| 14 | +- **Channel URLs**: Reads recent 10 messages from the channel |
| 15 | +- **File URLs**: Downloads file to current directory and returns path info |
| 16 | + |
| 17 | +### 2. Simple Syntax |
| 18 | + |
| 19 | +```bash |
| 20 | +# One command for everything! |
| 21 | +prbot slack read "<slack_url>" |
| 22 | +``` |
| 23 | + |
| 24 | +No more remembering different flags for different operations! |
| 25 | + |
| 26 | +### 3. YAML Output |
| 27 | + |
| 28 | +All Slack commands now output YAML format (instead of JSON) for better readability by both humans and AI agents. |
| 29 | + |
| 30 | +## Examples |
| 31 | + |
| 32 | +### Message URL |
| 33 | + |
| 34 | +```bash |
| 35 | +$ prbot slack read "https://workspace.slack.com/archives/C123/p1234567890" |
| 36 | +``` |
| 37 | + |
| 38 | +**Output:** YAML with 40 messages (20 before + 20 after), target message has `is_target: true` |
| 39 | + |
| 40 | +### Channel URL |
| 41 | + |
| 42 | +```bash |
| 43 | +$ prbot slack read "https://workspace.slack.com/archives/C123" |
| 44 | +``` |
| 45 | + |
| 46 | +**Output:** YAML with 10 most recent messages from the channel |
| 47 | + |
| 48 | +### File URL |
| 49 | + |
| 50 | +```bash |
| 51 | +$ prbot slack read "https://files.slack.com/files-pri/T123-F456/report.pdf" |
| 52 | +``` |
| 53 | + |
| 54 | +**Output:** YAML with download info: |
| 55 | + |
| 56 | +```yaml |
| 57 | +type: file_downloaded |
| 58 | +file_id: F456 |
| 59 | +file_name: report.pdf |
| 60 | +file_size: 12345 |
| 61 | +downloaded_to: ./report.pdf |
| 62 | +``` |
| 63 | +
|
| 64 | +## Implementation |
| 65 | +
|
| 66 | +### New Files Created |
| 67 | +
|
| 68 | +1. **lib/slack/parseSlackUrlSmart.ts** |
| 69 | + - Smart URL parser that detects message/file/channel URLs |
| 70 | + - Returns structured data with type and extracted info |
| 71 | +
|
| 72 | +2. **lib/slack/msg-read-recent.ts** |
| 73 | + - Function to read recent messages from a channel |
| 74 | + - Outputs YAML format |
| 75 | +
|
| 76 | +### Modified Files |
| 77 | +
|
| 78 | +1. **bot/cli.ts** |
| 79 | + - Added `prbot slack read <url>` command |
| 80 | + - Updated all Slack commands to output YAML instead of JSON |
| 81 | + - Imported new smart URL parser |
| 82 | + |
| 83 | +2. **.bot/AGENT.md** (and symlinked README.md, CLAUDE.md) |
| 84 | + - Added documentation for smart read command |
| 85 | + - Updated output format mentions from JSON to YAML |
| 86 | + - Added as recommended method at top of Slack commands section |
| 87 | + |
| 88 | +3. **CLAUDE.md** (root) |
| 89 | + - Added smart read command documentation |
| 90 | + - Updated usage patterns to use the new command |
| 91 | + - Updated implementation details |
| 92 | + |
| 93 | +## Benefits |
| 94 | + |
| 95 | +### For Humans |
| 96 | + |
| 97 | +- **Easier to type**: Just paste the Slack URL, no need to extract channel/timestamp |
| 98 | +- **One command to remember**: Instead of `read-thread`, `read-nearby`, `download-file`, etc. |
| 99 | +- **Better readability**: YAML output is more human-friendly than JSON |
| 100 | + |
| 101 | +### For AI Agents |
| 102 | + |
| 103 | +- **Simpler integration**: Single command interface for all Slack read operations |
| 104 | +- **Better parsing**: YAML is easier to parse and work with than JSON |
| 105 | +- **Consistent output**: All commands follow the same format |
| 106 | + |
| 107 | +## Testing |
| 108 | + |
| 109 | +All URL types parse correctly: |
| 110 | + |
| 111 | +```bash |
| 112 | +# Message URL |
| 113 | +$ bun lib/slack/parseSlackUrlSmart.ts "https://workspace.slack.com/archives/C123/p1234567890" |
| 114 | +{"type":"message","channel":"C123","ts":"1234567890.123456","url":"..."} |
| 115 | +
|
| 116 | +# Channel URL |
| 117 | +$ bun lib/slack/parseSlackUrlSmart.ts "https://workspace.slack.com/archives/C123" |
| 118 | +{"type":"channel","channel":"C123","url":"..."} |
| 119 | +
|
| 120 | +# File URL |
| 121 | +$ bun lib/slack/parseSlackUrlSmart.ts "https://files.slack.com/files-pri/T123-F456/file.pdf" |
| 122 | +{"type":"file","fileId":"F456","url":"..."} |
| 123 | +``` |
| 124 | + |
| 125 | +## Command Help |
| 126 | + |
| 127 | +``` |
| 128 | +$ prbot slack --help |
| 129 | + |
| 130 | +Commands: |
| 131 | + prbot slack read <url> Smart read: Auto-detect URL type (message/file/channel) |
| 132 | + and read appropriately (YAML output) |
| 133 | + prbot slack update Update a Slack message |
| 134 | + prbot slack read-thread Read and print a Slack thread (YAML) |
| 135 | + prbot slack read-nearby Read nearby messages around a specific timestamp |
| 136 | + prbot slack download-file Download a file from Slack |
| 137 | + prbot slack file-info Get information about a Slack file (YAML) |
| 138 | + prbot slack post-with-files Post a message with file attachments |
| 139 | + prbot slack upload-file Upload a file to Slack |
| 140 | +``` |
| 141 | +
|
| 142 | +## Backward Compatibility |
| 143 | +
|
| 144 | +All existing commands (`read-thread`, `read-nearby`, `download-file`, etc.) still work exactly as before, just with YAML output instead of JSON. The new `read` command is additive and doesn't break any existing functionality. |
0 commit comments