$ show jrswab/lsq
lsq is a CLI tool written in Go that serves as a lightning-fast companion for Logseq, the open-source knowledge base. Its core functionality is creating, appending to, and viewing daily journal entries directly from the terminal, following Logseq's file naming and formatting conventions (Markdown or Org-mode). The tool provides a rich set of flags for targeting specific dates, searching pages via a trie-based index (including alias support), regex searching across journals and pages, and piping content from STDIN. It also supports indentation for nested list items and a configuration file in EDN format for persistent settings. The architecture is a single-binary monolith with clear separation into config, system (file I/O, editor launch), trie, todo state cycling, and an EDN validator module. While the tool is tightly coupled to Logseq's directory structure (journals/ and pages/ folders), the underlying components like the trie search, file appending logic, and configuration loading are well-isolated and could be reused in other Go projects with minimal adaptation.
The LLM identified 2 files worth highlighting for reuse:
A generic trie data structure implemented in Go with Unicode support and NFC normalization. It supports inserting filenames and aliases, and searching by prefix. The implementation uses a map of rune to child nodes, making it fully Unicode-compatible. The removeNonAlpha helper strips file extensions and non-alphanumeric characters, normalizes to lowercase, and applies NFC normalization for consistent matching across composed/decomposed characters. This module has zero dependencies (only golang.org/x/text/norm, which is a Go standard library extension) and could be extracted into a standalone library for any prefix-search use case.
Provides functions CycleState and CyclePriority for cycling through Logseq-compatible TODO states (TODO -> DOING -> DONE) and priorities ([#A] -> [#B] -> [#C]). The logic extracts indentation and bullet marker, then deterministically transforms the line. While the exact string patterns are Logseq-specific, the state machine pattern is cleanly isolated and could be adapted for any TODO system by replacing the state arrays. The code demonstrates careful handling of edge cases (empty lines, missing states, indented content).