heathrow 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +58 -0
  3. data/README.md +205 -0
  4. data/bin/heathrow +42 -0
  5. data/bin/heathrowd +283 -0
  6. data/docs/ARCHITECTURE.md +1172 -0
  7. data/docs/DATABASE_SCHEMA.md +685 -0
  8. data/docs/DEVELOPMENT_WORKFLOW.md +867 -0
  9. data/docs/DISCORD_SETUP.md +142 -0
  10. data/docs/GMAIL_OAUTH_SETUP.md +120 -0
  11. data/docs/PLUGIN_SYSTEM.md +1370 -0
  12. data/docs/PROJECT_PLAN.md +1022 -0
  13. data/docs/README.md +417 -0
  14. data/docs/REDDIT_SETUP.md +174 -0
  15. data/docs/REPLY_FORWARD.md +182 -0
  16. data/docs/WHATSAPP_TELEGRAM_SETUP.md +306 -0
  17. data/heathrow.gemspec +34 -0
  18. data/heathrowd.service +21 -0
  19. data/img/heathrow.svg +95 -0
  20. data/img/rss_threaded.png +0 -0
  21. data/img/sources.png +0 -0
  22. data/lib/heathrow/address_book.rb +42 -0
  23. data/lib/heathrow/config.rb +332 -0
  24. data/lib/heathrow/database.rb +731 -0
  25. data/lib/heathrow/database_new.rb +392 -0
  26. data/lib/heathrow/event_bus.rb +175 -0
  27. data/lib/heathrow/logger.rb +122 -0
  28. data/lib/heathrow/message.rb +176 -0
  29. data/lib/heathrow/message_composer.rb +399 -0
  30. data/lib/heathrow/message_organizer.rb +774 -0
  31. data/lib/heathrow/migrations/001_initial_schema.rb +248 -0
  32. data/lib/heathrow/notmuch.rb +45 -0
  33. data/lib/heathrow/oauth2_smtp.rb +254 -0
  34. data/lib/heathrow/plugin/base.rb +212 -0
  35. data/lib/heathrow/plugin_manager.rb +141 -0
  36. data/lib/heathrow/poller.rb +93 -0
  37. data/lib/heathrow/smtp_sender.rb +204 -0
  38. data/lib/heathrow/source.rb +39 -0
  39. data/lib/heathrow/sources/base.rb +74 -0
  40. data/lib/heathrow/sources/discord.rb +357 -0
  41. data/lib/heathrow/sources/gmail.rb +294 -0
  42. data/lib/heathrow/sources/imap.rb +198 -0
  43. data/lib/heathrow/sources/instagram.rb +307 -0
  44. data/lib/heathrow/sources/instagram_fetch.py +101 -0
  45. data/lib/heathrow/sources/instagram_send.py +55 -0
  46. data/lib/heathrow/sources/instagram_send_marionette.py +104 -0
  47. data/lib/heathrow/sources/maildir.rb +606 -0
  48. data/lib/heathrow/sources/messenger.rb +212 -0
  49. data/lib/heathrow/sources/messenger_fetch.js +297 -0
  50. data/lib/heathrow/sources/messenger_fetch_marionette.py +138 -0
  51. data/lib/heathrow/sources/messenger_send.js +32 -0
  52. data/lib/heathrow/sources/messenger_send.py +100 -0
  53. data/lib/heathrow/sources/reddit.rb +461 -0
  54. data/lib/heathrow/sources/rss.rb +299 -0
  55. data/lib/heathrow/sources/slack.rb +375 -0
  56. data/lib/heathrow/sources/source_manager.rb +328 -0
  57. data/lib/heathrow/sources/telegram.rb +498 -0
  58. data/lib/heathrow/sources/webpage.rb +207 -0
  59. data/lib/heathrow/sources/weechat.rb +479 -0
  60. data/lib/heathrow/sources/whatsapp.rb +474 -0
  61. data/lib/heathrow/ui/application.rb +8098 -0
  62. data/lib/heathrow/ui/navigation.rb +8 -0
  63. data/lib/heathrow/ui/panes.rb +8 -0
  64. data/lib/heathrow/ui/source_wizard.rb +567 -0
  65. data/lib/heathrow/ui/threaded_view.rb +780 -0
  66. data/lib/heathrow/ui/views.rb +8 -0
  67. data/lib/heathrow/version.rb +3 -0
  68. data/lib/heathrow/wizards/discord_wizard.rb +193 -0
  69. data/lib/heathrow/wizards/slack_wizard.rb +140 -0
  70. data/lib/heathrow.rb +55 -0
  71. metadata +147 -0
@@ -0,0 +1,1022 @@
1
+ # Heathrow - Universal Communication Terminal
2
+ ## Complete Implementation Plan
3
+
4
+ **Vision:** Replace mutt, weechat, newsboat, messenger, discord, reddit, whatsapp, slack, teams, and more with one unified terminal application.
5
+
6
+ **Metaphor:** Like Heathrow Airport - all communication "flights" route through one central hub with multiple terminals (platforms), gates (channels), arrivals (inbox), and departures (outbox).
7
+
8
+ ---
9
+
10
+ ## Table of Contents
11
+
12
+ 1. [Architecture Overview](#architecture-overview)
13
+ 2. [Phase 0: Foundation](#phase-0-foundation)
14
+ 3. [Phase 1: Email Mastery](#phase-1-email-mastery)
15
+ 4. [Phase 2: Chat Platforms](#phase-2-chat-platforms)
16
+ 5. [Phase 3: Social & News](#phase-3-social--news)
17
+ 6. [Phase 4: Proprietary Messengers](#phase-4-proprietary-messengers)
18
+ 5. [Phase 5: Advanced Features](#phase-5-advanced-features)
19
+ 6. [Phase 6: Polish & Distribution](#phase-6-polish--distribution)
20
+ 7. [Development Principles](#development-principles)
21
+ 8. [Timeline](#timeline)
22
+
23
+ ---
24
+
25
+ ## Architecture Overview
26
+
27
+ ### Core Principle: Modular Isolation
28
+
29
+ Every component is a self-contained LEGO piece:
30
+ - **No shared state** between plugins
31
+ - **Clear interfaces** defined via contracts
32
+ - **Independent testing** for each module
33
+ - **Graceful degradation** if one plugin fails
34
+ - **Hot-reload capability** for plugins without restart
35
+
36
+ ### System Layers
37
+
38
+ ```
39
+ ┌─────────────────────────────────────────────────────────┐
40
+ │ UI Layer (rcurses) │
41
+ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌──────────────┐ │
42
+ │ │ Panes │ │ Input │ │ Render │ │ Key Binding │ │
43
+ │ └─────────┘ └─────────┘ └─────────┘ └──────────────┘ │
44
+ └─────────────────────────────────────────────────────────┘
45
+
46
+ ┌─────────────────────────────────────────────────────────┐
47
+ │ Application Layer │
48
+ │ ┌──────────────┐ ┌─────────────┐ ┌─────────────────┐ │
49
+ │ │ Message │ │ View │ │ Filter │ │
50
+ │ │ Router │ │ Manager │ │ Engine │ │
51
+ │ └──────────────┘ └─────────────┘ └─────────────────┘ │
52
+ └─────────────────────────────────────────────────────────┘
53
+
54
+ ┌─────────────────────────────────────────────────────────┐
55
+ │ Core Layer │
56
+ │ ┌──────────────┐ ┌─────────────┐ ┌─────────────────┐ │
57
+ │ │ Plugin │ │ Config │ │ Database │ │
58
+ │ │ Manager │ │ Manager │ │ Layer │ │
59
+ │ └──────────────┘ └─────────────┘ └─────────────────┘ │
60
+ │ ┌──────────────┐ ┌─────────────┐ ┌─────────────────┐ │
61
+ │ │ Event │ │ Logger │ │ Cache │ │
62
+ │ │ Bus │ │ │ │ │ │
63
+ │ └──────────────┘ └─────────────┘ └─────────────────┘ │
64
+ └─────────────────────────────────────────────────────────┘
65
+
66
+ ┌─────────────────────────────────────────────────────────┐
67
+ │ Plugin Layer │
68
+ │ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌──────┐ │
69
+ │ │ Gmail │ │ Slack │ │Discord │ │ RSS │ │ etc. │ │
70
+ │ └────────┘ └────────┘ └────────┘ └────────┘ └──────┘ │
71
+ └─────────────────────────────────────────────────────────┘
72
+ ```
73
+
74
+ ### Component Isolation Matrix
75
+
76
+ | Component | Depends On | Used By | Can Break? |
77
+ |----------------|----------------------|----------------------|------------|
78
+ | Plugin | Core API only | Plugin Manager | ✓ Safe |
79
+ | Plugin Manager | Event Bus, Logger | Application Layer | ✗ Critical |
80
+ | Message Router | Database, Event Bus | Application Layer | ✗ Critical |
81
+ | Filter Engine | Message Router | View Manager | ✓ Safe |
82
+ | View Manager | Filter Engine, DB | UI Layer | ✓ Safe |
83
+ | UI Layer | Application Layer | User | ✗ Critical |
84
+ | Database | None | All layers | ✗ Critical |
85
+ | Event Bus | Logger | All components | ✗ Critical |
86
+
87
+ **Legend:**
88
+ - ✓ Safe: Can crash without bringing down the system
89
+ - ✗ Critical: Must never crash (extensive testing required)
90
+
91
+ ---
92
+
93
+ ## Phase 0: Foundation
94
+
95
+ **Goal:** Build unbreakable core that all future features rely on.
96
+
97
+ **Duration:** 2-4 weeks
98
+
99
+ **Success Criteria:** Can add new plugin without touching core code.
100
+
101
+ ### 0.1: Project Rename (Heathrow → Heathrow)
102
+
103
+ **Files to modify:**
104
+ - `bin/heathrow` → `bin/heathrow`
105
+ - `lib/heathrow.rb` → `lib/heathrow.rb`
106
+ - `lib/heathrow/*` → `lib/heathrow/*`
107
+ - `README.md`
108
+ - `CLAUDE.md`
109
+ - All require statements
110
+
111
+ **Testing:** Ensure app still runs after rename.
112
+
113
+ **Isolation:** This is purely cosmetic, no logic changes.
114
+
115
+ ### 0.2: Database Layer (Critical Component)
116
+
117
+ **File:** `lib/heathrow/database.rb`
118
+
119
+ **Interface:**
120
+ ```ruby
121
+ module Heathrow
122
+ class Database
123
+ def initialize(db_path)
124
+ def exec(sql, params = [])
125
+ def query(sql, params = [])
126
+ def transaction(&block)
127
+ def migrate(version)
128
+ end
129
+ end
130
+ ```
131
+
132
+ **Schema:** See `docs/DATABASE_SCHEMA.md`
133
+
134
+ **Testing:**
135
+ - Unit tests for each method
136
+ - Transaction rollback tests
137
+ - Concurrent access tests
138
+ - Migration tests
139
+
140
+ **Isolation:** Only this class touches SQLite directly.
141
+
142
+ ### 0.3: Configuration Manager (Critical Component)
143
+
144
+ **File:** `lib/heathrow/config.rb`
145
+
146
+ **Interface:**
147
+ ```ruby
148
+ module Heathrow
149
+ class Config
150
+ def initialize(config_path = "~/.heathrow/config.yml")
151
+ def get(key_path) # e.g., "plugins.gmail.enabled"
152
+ def set(key_path, value)
153
+ def save
154
+ def reload
155
+ def validate
156
+ end
157
+ end
158
+ ```
159
+
160
+ **Configuration Structure:** See `docs/CONFIGURATION.md`
161
+
162
+ **Testing:**
163
+ - Load/save round-trip
164
+ - Nested key access
165
+ - Validation rules
166
+ - Default values
167
+
168
+ **Isolation:** Only this class reads config files.
169
+
170
+ ### 0.4: Event Bus (Critical Component)
171
+
172
+ **File:** `lib/heathrow/event_bus.rb`
173
+
174
+ **Interface:**
175
+ ```ruby
176
+ module Heathrow
177
+ class EventBus
178
+ def subscribe(event_type, &handler)
179
+ def unsubscribe(handler_id)
180
+ def publish(event_type, data)
181
+ def clear
182
+ end
183
+ end
184
+ ```
185
+
186
+ **Events:**
187
+ - `message:received`
188
+ - `message:sent`
189
+ - `message:read`
190
+ - `plugin:loaded`
191
+ - `plugin:error`
192
+ - `view:changed`
193
+ - `ui:refresh`
194
+
195
+ **Testing:**
196
+ - Subscribe/unsubscribe
197
+ - Multiple handlers
198
+ - Error in handler doesn't crash bus
199
+ - Performance (1000+ events/sec)
200
+
201
+ **Isolation:** Async event delivery, handlers can't block each other.
202
+
203
+ ### 0.5: Plugin Manager (Critical Component)
204
+
205
+ **File:** `lib/heathrow/plugin_manager.rb`
206
+
207
+ **Interface:**
208
+ ```ruby
209
+ module Heathrow
210
+ class PluginManager
211
+ def initialize(event_bus, config, db)
212
+ def load_all
213
+ def load_plugin(name)
214
+ def unload_plugin(name)
215
+ def get_plugin(name)
216
+ def list_plugins
217
+ def reload_plugin(name)
218
+ end
219
+ end
220
+ ```
221
+
222
+ **Plugin Discovery:**
223
+ - Scan `lib/heathrow/plugins/*.rb`
224
+ - Auto-register classes inheriting from `Heathrow::Plugin::Base`
225
+
226
+ **Testing:**
227
+ - Load valid plugin
228
+ - Handle invalid plugin gracefully
229
+ - Reload without memory leak
230
+ - Plugin crash doesn't crash manager
231
+
232
+ **Isolation:** Each plugin runs in its own error boundary.
233
+
234
+ ### 0.6: Plugin Base Class (Critical Component)
235
+
236
+ **File:** `lib/heathrow/plugin/base.rb`
237
+
238
+ **Interface:**
239
+ ```ruby
240
+ module Heathrow
241
+ module Plugin
242
+ class Base
243
+ attr_reader :name, :config, :capabilities
244
+
245
+ def initialize(config, event_bus, db)
246
+ def start # Called when plugin loads
247
+ def stop # Called when plugin unloads
248
+ def fetch_messages # Returns Message[]
249
+ def send_message(message, target)
250
+ def capabilities # Returns Symbol[]
251
+ def status # Returns Hash (connected, last_sync, etc.)
252
+
253
+ protected
254
+ def log(level, message)
255
+ def emit_event(type, data)
256
+ def store_credential(key, value)
257
+ def retrieve_credential(key)
258
+ end
259
+ end
260
+ end
261
+ ```
262
+
263
+ **Capabilities:**
264
+ - `:read` - Can fetch messages
265
+ - `:write` - Can send messages
266
+ - `:real_time` - Can stream messages (websocket/long-poll)
267
+ - `:attachments` - Supports file attachments
268
+ - `:threads` - Supports threaded conversations
269
+ - `:search` - Supports server-side search
270
+ - `:reactions` - Supports emoji reactions
271
+ - `:typing` - Supports typing indicators
272
+
273
+ **Testing:**
274
+ - Base class provides defaults
275
+ - Subclass can override
276
+ - Error handling wrapper
277
+
278
+ **Isolation:** Plugins can only access core via this interface.
279
+
280
+ ### 0.7: Message Model (Critical Component)
281
+
282
+ **File:** `lib/heathrow/message.rb`
283
+
284
+ **Interface:**
285
+ ```ruby
286
+ module Heathrow
287
+ class Message
288
+ attr_accessor :id, :source_id, :external_id, :thread_id
289
+ attr_accessor :sender, :recipients, :subject, :content
290
+ attr_accessor :html_content, :timestamp, :read, :starred
291
+ attr_accessor :labels, :metadata
292
+
293
+ def initialize(attributes = {})
294
+ def to_h
295
+ def self.from_h(hash)
296
+ def save(db)
297
+ def self.find(db, id)
298
+ def self.where(db, conditions)
299
+ end
300
+ end
301
+ ```
302
+
303
+ **Testing:**
304
+ - Serialization round-trip
305
+ - Database persistence
306
+ - Query methods
307
+ - Validation
308
+
309
+ **Isolation:** All plugins return this normalized format.
310
+
311
+ ### 0.8: Logger (Critical Component)
312
+
313
+ **File:** `lib/heathrow/logger.rb`
314
+
315
+ **Interface:**
316
+ ```ruby
317
+ module Heathrow
318
+ class Logger
319
+ def initialize(log_path = "~/.heathrow/heathrow.log")
320
+ def debug(component, message)
321
+ def info(component, message)
322
+ def warn(component, message)
323
+ def error(component, message, exception = nil)
324
+ def rotate
325
+ end
326
+ end
327
+ ```
328
+
329
+ **Features:**
330
+ - Thread-safe
331
+ - Automatic rotation (10MB files, keep 5)
332
+ - Structured logging (JSON lines)
333
+ - Performance tracking
334
+
335
+ **Testing:**
336
+ - Concurrent writes
337
+ - Rotation logic
338
+ - Exception formatting
339
+
340
+ **Isolation:** Never crashes, swallows its own errors.
341
+
342
+ ---
343
+
344
+ ## Phase 1: Email Mastery
345
+
346
+ **Goal:** Replace mutt entirely.
347
+
348
+ **Duration:** 6-8 weeks
349
+
350
+ **Success Criteria:** Daily email workflow works better than mutt.
351
+
352
+ ### 1.1: Gmail Plugin (Two-way)
353
+
354
+ **File:** `lib/heathrow/plugins/gmail.rb`
355
+
356
+ **Dependencies:**
357
+ - `google-api-client` gem
358
+ - OAuth2 token storage
359
+
360
+ **Features:**
361
+ - OAuth2 authentication flow
362
+ - Fetch emails (IMAP-like)
363
+ - Send emails (SMTP)
364
+ - Thread support
365
+ - Label management
366
+ - Search
367
+
368
+ **Testing:**
369
+ - Mock Gmail API responses
370
+ - Integration test with test account
371
+ - Rate limit handling
372
+
373
+ **Isolation:** Crashes don't affect other plugins.
374
+
375
+ ### 1.2: Generic IMAP/SMTP Plugin (Two-way)
376
+
377
+ **File:** `lib/heathrow/plugins/imap_smtp.rb`
378
+
379
+ **Dependencies:**
380
+ - `net/imap` (stdlib)
381
+ - `net/smtp` (stdlib)
382
+
383
+ **Features:**
384
+ - Multi-account support
385
+ - TLS/SSL
386
+ - Folder management
387
+ - Server-side search
388
+
389
+ **Testing:**
390
+ - Mock IMAP server
391
+ - Various auth methods (PLAIN, LOGIN, CRAM-MD5)
392
+ - Connection failures
393
+
394
+ **Isolation:** Independent from Gmail plugin.
395
+
396
+ ### 1.3: Email Composer UI
397
+
398
+ **File:** `lib/heathrow/ui/composer.rb`
399
+
400
+ **Interface:**
401
+ ```ruby
402
+ module Heathrow
403
+ module UI
404
+ class Composer
405
+ def initialize(pane, message = nil) # nil for new, Message for reply
406
+ def edit # Returns Message or nil (cancelled)
407
+ def add_attachment(path)
408
+ def set_recipients(to, cc = [], bcc = [])
409
+ end
410
+ end
411
+ end
412
+ ```
413
+
414
+ **Features:**
415
+ - Multi-line editor
416
+ - To/Cc/Bcc fields
417
+ - Subject line
418
+ - Attachment list
419
+ - Send/Cancel/Draft
420
+
421
+ **Testing:**
422
+ - Manual testing in terminal
423
+ - Key binding tests
424
+
425
+ **Isolation:** Only reads/writes Message objects.
426
+
427
+ ### 1.4: Thread View
428
+
429
+ **File:** `lib/heathrow/ui/thread_view.rb`
430
+
431
+ **Features:**
432
+ - Group messages by thread_id
433
+ - Indent replies
434
+ - Collapse/expand threads
435
+ - Navigate within thread
436
+
437
+ **Testing:**
438
+ - Sample email threads
439
+ - UI rendering tests
440
+
441
+ **Isolation:** Independent component.
442
+
443
+ ### 1.5: Attachment Handling
444
+
445
+ **File:** `lib/heathrow/attachment.rb`
446
+
447
+ **Features:**
448
+ - View in external program
449
+ - Save to disk
450
+ - Attach files to outgoing
451
+ - MIME type detection
452
+
453
+ **Testing:**
454
+ - Various file types
455
+ - Large files
456
+ - Missing files
457
+
458
+ **Isolation:** Separate module.
459
+
460
+ ### 1.6: HTML Rendering
461
+
462
+ **File:** `lib/heathrow/html_renderer.rb`
463
+
464
+ **Dependencies:**
465
+ - `w3m` or `lynx` (external)
466
+
467
+ **Features:**
468
+ - Convert HTML to plain text
469
+ - Preserve links
470
+ - Handle images (show URLs)
471
+
472
+ **Testing:**
473
+ - Various HTML emails
474
+ - Fallback if w3m missing
475
+
476
+ **Isolation:** External process, can't crash app.
477
+
478
+ ---
479
+
480
+ ## Phase 2: Chat Platforms
481
+
482
+ **Goal:** Replace weechat for real-time chat.
483
+
484
+ **Duration:** 8-10 weeks
485
+
486
+ **Success Criteria:** Can chat on Slack/Discord/Telegram without switching apps.
487
+
488
+ ### 2.1: Slack Plugin (Two-way)
489
+
490
+ **File:** `lib/heathrow/plugins/slack.rb`
491
+
492
+ **Dependencies:**
493
+ - `slack-ruby-client` gem or manual REST/RTM API
494
+
495
+ **Features:**
496
+ - OAuth authentication
497
+ - Real-time messaging (WebSocket)
498
+ - Channel list
499
+ - Direct messages
500
+ - File sharing
501
+ - Reactions
502
+ - Thread support
503
+
504
+ **Testing:**
505
+ - Mock Slack API
506
+ - Test workspace integration
507
+
508
+ **Isolation:** Independent plugin.
509
+
510
+ ### 2.2: Discord Plugin (Two-way)
511
+
512
+ **File:** `lib/heathrow/plugins/discord.rb`
513
+
514
+ **Dependencies:**
515
+ - `discordrb` gem or manual gateway API
516
+
517
+ **Features:**
518
+ - Bot token auth
519
+ - Real-time messaging (gateway)
520
+ - Server/channel list
521
+ - Direct messages
522
+ - Embeds
523
+ - Reactions
524
+
525
+ **Testing:**
526
+ - Mock Discord gateway
527
+ - Test server integration
528
+
529
+ **Isolation:** Independent plugin.
530
+
531
+ ### 2.3: Telegram Plugin (Two-way)
532
+
533
+ **File:** `lib/heathrow/plugins/telegram.rb`
534
+
535
+ **Dependencies:**
536
+ - `telegram-bot-ruby` gem
537
+
538
+ **Features:**
539
+ - Bot API
540
+ - User messaging
541
+ - Group chats
542
+ - Media handling
543
+ - Bot commands
544
+
545
+ **Testing:**
546
+ - Mock Telegram API
547
+ - Test bot integration
548
+
549
+ **Isolation:** Independent plugin.
550
+
551
+ ### 2.4: Real-time Message Streaming
552
+
553
+ **File:** `lib/heathrow/stream_manager.rb`
554
+
555
+ **Interface:**
556
+ ```ruby
557
+ module Heathrow
558
+ class StreamManager
559
+ def initialize(plugin_manager, event_bus)
560
+ def start_stream(plugin_name)
561
+ def stop_stream(plugin_name)
562
+ def list_active_streams
563
+ end
564
+ end
565
+ ```
566
+
567
+ **Features:**
568
+ - Background threads for each plugin
569
+ - Auto-reconnect on disconnect
570
+ - Rate limit handling
571
+ - Message queue
572
+
573
+ **Testing:**
574
+ - Connection drops
575
+ - Rapid messages
576
+ - Thread safety
577
+
578
+ **Isolation:** Each stream in separate thread.
579
+
580
+ ### 2.5: IRC Plugin (Two-way)
581
+
582
+ **File:** `lib/heathrow/plugins/irc.rb`
583
+
584
+ **Dependencies:**
585
+ - Manual TCP socket implementation (no gem)
586
+
587
+ **Features:**
588
+ - Multi-server connections
589
+ - Channel management
590
+ - Private messages
591
+ - CTCP
592
+ - SSL/TLS
593
+
594
+ **Testing:**
595
+ - Mock IRC server
596
+ - Integration with freenode test
597
+
598
+ **Isolation:** Independent plugin.
599
+
600
+ ---
601
+
602
+ ## Phase 3: Social & News
603
+
604
+ **Goal:** Replace newsboat and reddit clients.
605
+
606
+ **Duration:** 4-6 weeks
607
+
608
+ **Success Criteria:** Can read RSS feeds and browse reddit.
609
+
610
+ ### 3.1: RSS/Atom Plugin (One-way)
611
+
612
+ **File:** `lib/heathrow/plugins/rss.rb`
613
+
614
+ **Dependencies:**
615
+ - `rss` (stdlib)
616
+
617
+ **Features:**
618
+ - Feed parsing
619
+ - Auto-discovery
620
+ - Update scheduling
621
+ - OPML import/export
622
+
623
+ **Testing:**
624
+ - Various feed formats
625
+ - Malformed feeds
626
+ - Network errors
627
+
628
+ **Isolation:** Independent plugin.
629
+
630
+ ### 3.2: Reddit Plugin (Two-way)
631
+
632
+ **File:** `lib/heathrow/plugins/reddit.rb`
633
+
634
+ **Dependencies:**
635
+ - `redd` gem or manual OAuth2
636
+
637
+ **Features:**
638
+ - OAuth2 authentication
639
+ - Subreddit subscriptions
640
+ - Post/comment viewing
641
+ - Voting
642
+ - Posting/commenting
643
+ - Multireddits
644
+
645
+ **Testing:**
646
+ - Mock Reddit API
647
+ - Test account integration
648
+
649
+ **Isolation:** Independent plugin.
650
+
651
+ ### 3.3: Mastodon/Fediverse Plugin (Two-way)
652
+
653
+ **File:** `lib/heathrow/plugins/mastodon.rb`
654
+
655
+ **Dependencies:**
656
+ - Manual API calls
657
+
658
+ **Features:**
659
+ - OAuth authentication
660
+ - Timeline viewing
661
+ - Tooting/replying
662
+ - Boost/favorite
663
+ - Notifications
664
+
665
+ **Testing:**
666
+ - Mock Mastodon API
667
+ - Test instance integration
668
+
669
+ **Isolation:** Independent plugin.
670
+
671
+ ### 3.4: Hacker News Plugin (One-way, optional two-way)
672
+
673
+ **File:** `lib/heathrow/plugins/hackernews.rb`
674
+
675
+ **Dependencies:**
676
+ - Manual API calls (algolia HN API)
677
+
678
+ **Features:**
679
+ - Front page stories
680
+ - Comments
681
+ - Search
682
+ - User profile
683
+
684
+ **Testing:**
685
+ - Mock HN API
686
+
687
+ **Isolation:** Independent plugin.
688
+
689
+ ---
690
+
691
+ ## Phase 4: Proprietary Messengers
692
+
693
+ **Goal:** Bridge to WhatsApp, Messenger, Signal.
694
+
695
+ **Duration:** 6-8 weeks (reverse engineering required)
696
+
697
+ **Success Criteria:** Can message on WhatsApp without phone.
698
+
699
+ ### 4.1: WhatsApp Plugin (Two-way)
700
+
701
+ **File:** `lib/heathrow/plugins/whatsapp.rb`
702
+
703
+ **Dependencies:**
704
+ - `whatsmeow` (Go binary wrapped) or Ruby port
705
+
706
+ **Features:**
707
+ - QR code auth
708
+ - Contact list
709
+ - Group chats
710
+ - Media handling
711
+ - End-to-end encryption maintained
712
+
713
+ **Testing:**
714
+ - Test account integration
715
+ - Connection stability
716
+
717
+ **Isolation:** Independent plugin, may require external process.
718
+
719
+ ### 4.2: Facebook Messenger Plugin (Two-way)
720
+
721
+ **File:** `lib/heathrow/plugins/messenger.rb`
722
+
723
+ **Dependencies:**
724
+ - Unofficial API or bridge
725
+
726
+ **Features:**
727
+ - Cookie-based auth
728
+ - Message threads
729
+ - Group chats
730
+
731
+ **Testing:**
732
+ - Test account integration
733
+
734
+ **Isolation:** Independent plugin.
735
+
736
+ ### 4.3: Signal Plugin (Two-way, if possible)
737
+
738
+ **File:** `lib/heathrow/plugins/signal.rb`
739
+
740
+ **Dependencies:**
741
+ - `signal-cli` (Java binary wrapped)
742
+
743
+ **Features:**
744
+ - Linked device
745
+ - Message send/receive
746
+ - Group support
747
+ - E2E encryption maintained
748
+
749
+ **Testing:**
750
+ - Test account integration
751
+
752
+ **Isolation:** External process wrapper.
753
+
754
+ ---
755
+
756
+ ## Phase 5: Advanced Features
757
+
758
+ **Goal:** Beyond replacement - innovation.
759
+
760
+ **Duration:** 4-6 weeks
761
+
762
+ **Success Criteria:** Power users can automate workflows.
763
+
764
+ ### 5.1: Unified Search
765
+
766
+ **File:** `lib/heathrow/search.rb`
767
+
768
+ **Interface:**
769
+ ```ruby
770
+ module Heathrow
771
+ class Search
772
+ def initialize(db)
773
+ def query(search_string, filters = {})
774
+ def save_search(name, search_string)
775
+ def saved_searches
776
+ end
777
+ end
778
+ ```
779
+
780
+ **Features:**
781
+ - Full-text search (SQLite FTS5)
782
+ - Search syntax: `from:user subject:important after:2024-01-01`
783
+ - Saved searches
784
+ - Search across all sources
785
+
786
+ **Testing:**
787
+ - Various search queries
788
+ - Performance with large dataset
789
+
790
+ **Isolation:** Standalone module.
791
+
792
+ ### 5.2: Filter Suggestion Engine
793
+
794
+ **File:** `lib/heathrow/filter_suggester.rb`
795
+
796
+ **Features:**
797
+ - Analyze message patterns
798
+ - Suggest automatic filters
799
+ - Learn from user actions
800
+
801
+ **Testing:**
802
+ - Sample datasets
803
+ - Suggestion quality
804
+
805
+ **Isolation:** Optional feature.
806
+
807
+ ### 5.3: Scripting System
808
+
809
+ **File:** `lib/heathrow/scripting.rb`
810
+
811
+ **Interface:**
812
+ ```ruby
813
+ # User scripts in ~/.heathrow/scripts/*.rb
814
+ # Example: auto-reply to specific senders
815
+
816
+ Heathrow.on :message_received do |msg|
817
+ if msg.sender == "boss@company.com"
818
+ reply = Heathrow::Message.new(
819
+ subject: "Re: #{msg.subject}",
820
+ content: "I'll look into this!",
821
+ recipients: [msg.sender]
822
+ )
823
+ Heathrow.send_message(reply)
824
+ end
825
+ end
826
+ ```
827
+
828
+ **Features:**
829
+ - Ruby DSL for automation
830
+ - Safe sandbox
831
+ - Event hooks
832
+
833
+ **Testing:**
834
+ - Sample scripts
835
+ - Sandboxing effectiveness
836
+
837
+ **Isolation:** Scripts run in separate context.
838
+
839
+ ### 5.4: Notification System
840
+
841
+ **File:** `lib/heathrow/notifier.rb`
842
+
843
+ **Features:**
844
+ - Desktop notifications (libnotify)
845
+ - Custom notification rules
846
+ - Sound alerts
847
+ - Urgency levels
848
+
849
+ **Testing:**
850
+ - Notification display
851
+ - Rule matching
852
+
853
+ **Isolation:** External process.
854
+
855
+ ---
856
+
857
+ ## Phase 6: Polish & Distribution
858
+
859
+ **Goal:** Production-ready, easy to install.
860
+
861
+ **Duration:** 2-4 weeks
862
+
863
+ **Success Criteria:** Non-technical users can install and use.
864
+
865
+ ### 6.1: Installation Script
866
+
867
+ **File:** `install.sh`
868
+
869
+ **Features:**
870
+ - Detect OS
871
+ - Install dependencies
872
+ - Setup directories
873
+ - Initial configuration wizard
874
+
875
+ **Testing:**
876
+ - Fresh Ubuntu/Debian
877
+ - Fresh Fedora/RHEL
878
+ - macOS
879
+
880
+ **Isolation:** Standalone script.
881
+
882
+ ### 6.2: Configuration Wizard
883
+
884
+ **File:** `lib/heathrow/wizard.rb`
885
+
886
+ **Features:**
887
+ - Interactive setup
888
+ - Source configuration
889
+ - View creation
890
+ - Test connections
891
+
892
+ **Testing:**
893
+ - Manual testing
894
+
895
+ **Isolation:** Only runs once.
896
+
897
+ ### 6.3: Migration Tools
898
+
899
+ **File:** `lib/heathrow/migration/*.rb`
900
+
901
+ **Features:**
902
+ - Import from mutt config
903
+ - Import from weechat config
904
+ - Import from newsboat config
905
+
906
+ **Testing:**
907
+ - Sample config files
908
+
909
+ **Isolation:** Standalone tools.
910
+
911
+ ### 6.4: Documentation
912
+
913
+ **Files:**
914
+ - `docs/USER_MANUAL.md`
915
+ - `docs/SETUP_GUIDE.md`
916
+ - `docs/TROUBLESHOOTING.md`
917
+ - `docs/API.md`
918
+ - `docs/PLUGIN_DEVELOPMENT.md`
919
+
920
+ **Testing:**
921
+ - Technical review
922
+ - User testing
923
+
924
+ ### 6.5: Package Distribution
925
+
926
+ **Targets:**
927
+ - RubyGems: `gem install heathrow`
928
+ - Debian/Ubuntu: `.deb` package
929
+ - Fedora/RHEL: `.rpm` package
930
+ - macOS: Homebrew formula
931
+ - Arch Linux: AUR package
932
+ - Docker: `docker pull heathrow/heathrow`
933
+
934
+ **Testing:**
935
+ - Install on fresh systems
936
+
937
+ ---
938
+
939
+ ## Development Principles
940
+
941
+ ### 1. One File = One Responsibility
942
+
943
+ Each file should have a single, clear purpose.
944
+
945
+ ### 2. Interfaces First
946
+
947
+ Define the interface before implementation.
948
+
949
+ ### 3. Test Before Merge
950
+
951
+ Every component needs tests before integration.
952
+
953
+ ### 4. Error Boundaries
954
+
955
+ Plugins must not crash core. Core must not crash UI.
956
+
957
+ ### 5. Backward Compatibility
958
+
959
+ Database migrations must be reversible.
960
+
961
+ ### 6. Documentation as Code
962
+
963
+ Update docs with code changes, not after.
964
+
965
+ ### 7. Security by Design
966
+
967
+ - Encrypt credentials at rest
968
+ - No passwords in logs
969
+ - Rate limit API calls
970
+ - Validate all inputs
971
+
972
+ ### 8. Performance Budget
973
+
974
+ - UI must refresh < 100ms
975
+ - Message fetch < 5s
976
+ - Database query < 50ms
977
+ - Memory < 100MB idle
978
+
979
+ ---
980
+
981
+ ## Timeline
982
+
983
+ ### Aggressive (6 months)
984
+
985
+ - **Month 1:** Phase 0 complete
986
+ - **Month 2:** Phase 1 (Email) complete
987
+ - **Month 3:** Phase 2 (Chat) 50% done
988
+ - **Month 4:** Phase 2 complete, Phase 3 (Social) complete
989
+ - **Month 5:** Phase 4 (Messengers) complete
990
+ - **Month 6:** Phase 5 & 6 complete
991
+
992
+ ### Realistic (12 months)
993
+
994
+ - **Month 1-2:** Phase 0 complete (with extensive testing)
995
+ - **Month 3-4:** Phase 1 (Email) complete
996
+ - **Month 5-7:** Phase 2 (Chat) complete
997
+ - **Month 8-9:** Phase 3 (Social) complete
998
+ - **Month 10-11:** Phase 4 (Messengers) complete
999
+ - **Month 12:** Phase 5 & 6 complete
1000
+
1001
+ ### Minimum Viable Product (3 months)
1002
+
1003
+ - **Month 1:** Phase 0 + Gmail plugin only
1004
+ - **Month 2:** Phase 1 (Email only, Gmail + IMAP)
1005
+ - **Month 3:** Phase 2 (Slack + Discord only)
1006
+
1007
+ **Recommendation:** Start with MVP, iterate based on user feedback.
1008
+
1009
+ ---
1010
+
1011
+ ## Next Steps
1012
+
1013
+ 1. Review and approve this plan
1014
+ 2. Create GitHub milestones for each phase
1015
+ 3. Begin Phase 0.1: Rename project
1016
+ 4. Set up CI/CD pipeline
1017
+ 5. Create test framework
1018
+
1019
+ **Questions for user:**
1020
+ - Prefer aggressive, realistic, or MVP timeline?
1021
+ - Any platforms to prioritize/deprioritize?
1022
+ - Any specific features critical for your workflow?