Repository navigation
feat(search): the query language's parser - #334
Merged
Merged
Conversation
Phase 2, item 4: a pure function from the search string to a tree — every word required, "phrases", -word and -"phrase" left out, OR binding tighter than the implied AND, and the six filters from: chat: after: before: has: in:. after: and before: take a local day or a count of days back. Only those six names are filters, so a link or a time stays text. It refuses, before anything is searched: only negations, OR without a word on a side or beside a left-out word, a filter given twice, a day that is not one, an unknown in: source, an empty value. Nothing calls it yet; the search service (item 6) will. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Task
Phase 2, item 4:
src/search/query.ts, a pure function from the string to a tree, with the errors of §4.Why
The search service (item 6) and
messages search(item 7) take one string with operators. Parsing it apart from the search keeps every rule testable on its own.What
parseQuery(query, { now })→{ required: Term[][], excluded, from?, chat?, after?, before?, has[], in? }.requiredis AND of OR-groups; words stay as typed.from chat after before has inare filters, sohttps://…,12:30andto:meare text.after:/before:take a local day (2026-01-31) or days back (7d).after:is inclusive,before:exclusive.has:may repeat; every other filter appears at most once.Testing
src/search/query.test.ts: 18 cases — every operator, OR precedence, links and times as text, filters alone, and each refusal with its message. lint, typecheck, test:coverage (693), docs:check.Reviewed against the review checklist — §B for code.
🤖 Generated with Claude Code