Skip to content

Add SQLite index and mark search - #18

Merged
polymorcodeus merged 5 commits into
mainfrom
index-n-search
Aug 24, 2026
Merged

Add SQLite index and mark search#18
polymorcodeus merged 5 commits into
mainfrom
index-n-search

Conversation

@polymorcodeus

@polymorcodeuspolymorcodeus commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a derived SQLite index over the TOML shelf files so reads and searches hit the index instead of a full TOML parse, and a book mark search command with FTS5 full-text search over titles and URLs plus tag, shelf, and collection filters.

What's new

  • Derived SQLite index - a gitignored index (modernc.org/sqlite, pure Go) rebuilt from TOML; shelf list, collection list, and mark list now read from it while writes stay TOML-first.
  • book mark search - FTS5 search over title and URL, non-interactive, with plain-text output (title and URL per line) by default.
  • Tag filtering - --tags uses comma for OR and plus for AND (a,b+c means (a OR b) AND c); --shelf and --collection scope results.
  • Index management - book index rebuild and book index sync recover from corruption and reconcile external edits.

Usage

CommandPurpose
book mark search <query>full-text search over title and URL
book mark search --tags a,b+cfilter by tags (OR within, AND across)
book mark search --shelf X --collection Yscope results to a shelf and collection
book index rebuild / book index syncrebuild or reconcile the index

Behavior changes / guardrails

  • TOML remains the git-committed source of truth; the index is derived and disposable, always rebuildable.
  • Reads reconcile the index with a stat fast path, hashing only when mtime or size changes, so external edits (git pull, manual changes) are picked up without a full rebuild.
  • book mark search is non-interactive; running it with no query and no filters errors with guidance.
  • Tag filters reject empty groups (a,, ,a, a+, +a).
  • Soft-deleted marks (deleted_at) are excluded from search results.
  • The index lives in $XDG_CACHE_HOME/book/index.db, falling back to the config dir (with a .gitignore write) when the cache dir is unavailable.

Testing

  • Unit tests cover the index schema, rebuild, incremental sync (including prune and unchanged-touch), read queries, tag grammar, tag-filtered search, and soft-delete exclusion.
  • make check runs fmt, vet, lint, and tests; all green.

@polymorcodeus
polymorcodeus merged commit bf03673 into mainAug 24, 2026
4 checks passed
@polymorcodeus
polymorcodeus deleted the index-n-search branch August 24, 2026 20:50
Sign up for freeto 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

@polymorcodeus