read: implement context model, resolver, and per-source readers - #168
Open
anish749 wants to merge 7 commits into
Open
read: implement context model, resolver, and per-source readers#168anish749 wants to merge 7 commits into
anish749 wants to merge 7 commits into
Conversation
anish749
force-pushed
the
read-protocol-context-and-readers
branch
2 times, most recently
from
April 11, 2026 21:53
007b07e to
b31bcaf
Compare
Adds the read protocol foundation: context-based account resolution, per-source read algorithms, and a unified CLI surface.
- Propagate errors from store.ReadMeta instead of _ assignment - Propagate errors from readDriveComments instead of silent fallback - Collect parse errors in loops (gmail, calendar, drive, linear) using errors.Join pattern instead of log-then-swallow - Propagate loadPendingDeletes and scanner errors - Propagate cobra flag parse errors in CLI layer - Revert unintended reordering of LinearConfig in config.go — only change is the two new fields (Contexts, DefaultContext)
Delete internal/reader/ entirely — it duplicated types, parsing, dedup, and formatting that already exist in modelv1, compact, and store. The read command is now thin dispatch: - Context resolution picks accounts (pctx.ResolveContextName + Resolve) - Source dispatch picks directories (paths type chain) - store.ReadLines + compact.DedupGWS handle JSONL reading and dedup - GWS sources output raw JSON lines (no custom formatters) - Messaging sources use existing store.ReadConversation + modelv1.FormatDateFile - Drive sources cat markdown/CSV content + raw comment JSONL Also: - ContextName is now a typed string, resolved once at CLI boundary - pctx.Resolve no longer reads env vars — receives ContextName from caller - Revert daemon.go identity context to original "default"
anish749
force-pushed
the
read-protocol-context-and-readers
branch
from
April 12, 2026 19:28
d18d073 to
e4edb6b
Compare
Use read.Glob (rg-backed) for --since and all-files cases instead of hand-rolled listDateFilesInDir + selectDateFiles. For --date, construct the path directly — no listing needed. Removes listDateFilesInDir, selectDateFiles, and filterLinesByTime (which also had a double-append bug).
Move ReadGWSLines, ReadDriveContent, ReadMessaging, ReadLinearIssue, and fuzzy matchers from cli/read.go to commands/read.go — following the existing pattern where cli/ is thin flag parsing and commands/ has testable business logic. Add 17 tests covering: - Gmail dedup, sort, last-N, default-last, empty dir - Calendar via the same GWS path - Messaging fuzzy match (exact, single, ambiguous, none) - Drive content + comments, no match - Linear issue dedup, fuzzy match, not found - filterCancelled no-op for non-events cli/read.go is now pure dispatch: parse flags → resolve context → call commands → print output.
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.
Problem
The read protocol defines a unified selection model for reading data across all sources, but pigeon's read command currently requires explicit platform/account/contact flags with no workspace-scoping concept.
Solution
Implements the context and reader layers from the read protocol:
config/context.go): Contexts in config.yaml map platform keys to account identifiers, with string-or-array YAML supportpctx/): Resolution chain (flag → env → default → infer), source-to-platform mapping, account matching per platformreader/): Gmail, Calendar, Drive, Slack, WhatsApp, Linear — each with dedup, filtering, and sorting per protocol speccli/read.go):pigeon read <source> [selector] [flags]replaces the old--platform --account --contactsurfacepigeon list --context=support