$ show gsamokovarov/jump
Jump is a single-binary Go CLI for fuzzy directory navigation, in the family of autojump/z/zoxide. It integrates with bash, zsh, fish, PowerShell, and Nushell by emitting a shell function (default `j`) that hooks PWD changes and calls `jump chdir`, which persists a scored database of visited directories as JSON files under ~/.jump or $XDG_CONFIG_HOME/jump. When the user types `j wc`, the shell function invokes `jump cd wc`, which ranks all entries by longest-common-subsequence fuzzy match against a cleverly normalized path (basename-only unless separators are given, case-sensitive when any capital letter is typed) and prints the best path for the shell to cd into. The tool also supports pins, relative jumps, repo-root-based mode via `j .`, reverse jumps via an empty term, stale-entry cleanup, and exact-match proximity heuristics. The codebase is cleanly layered: cli (argument parsing and command dispatch), cmd (command implementations), config (an interface with file- and in-memory implementations over atomic JSON persistence), scoring (frequency+recency weighted ranking and fuzzy sort), fuzzy (LCS algorithm and path normalizer), importer (parsers for autojump.txt, z's .z file, and zoxide's binary db.zo), and shell (Go-embedded integration scripts compiled via text/template). Everything is local files; there is no daemon, server, or network dependency. Test coverage is thorough across all packages, including adversarial importer tests for truncated, oversized, and corrupt zoxide databases and shell template compilation tests. Craftsmanship is strong: the atomic file helper, LCS implementation, path normalizer, and zoxide binary parser are genuinely reusable modules. Minor blemishes include a global command registry, duplicated version constants (0.67.0 in cmd/version.go vs 0.69.0 in the Makefile), a leftover defunct .travis.yml CI config, and a copy-paste error in the settings error message (--preserve validation prints 'slash, ignore' instead of 'true, false'). Overall this is a mature, well-maintained developer tool with an elegant core search/scoring design.
The LLM identified 6 files worth highlighting for reuse:
A space-optimized (two rolling rows) memoized longest-common-subsequence length implementation, O(n*m) with only O(min(n,m)) extra memory. Pure stdlib, no internal imports, and directly extractable into any fuzzy-search, diff, or autocomplete library. The comment references the algorithm source and the code is compact and correct, with symmetry tests proving order-independence.
Encapsulates the heuristics that make path fuzzy matching usable: lowercase paths unless the term contains capitals, match only the basename unless the term has OS separators, walk back exactly as many path chunks as the term has separators, and strip glob wildcards. Self-contained and applicable to any path-aware fuzzy search engine; the 'finalChunks' trick is a non-obvious solution to the deep-search precision problem.
A tiny atomic read-modify-write file handle: creates a temp file in the target directory, copies existing content so readers see the old state, tracks a dirty flag so failed writes never clobber the original, and renames into place on Close. Entirely stdlib-based, ~90 lines, and extractable as a micro-library for any Go application needing crash-safe JSON or config persistence.
A hardened decoder for zoxide's bincode db.zo format: rejects unsupported versions, enforces a 32 MiB size limit mirroring zoxide's own guard, and bounds-checks every length-prefixed string read so corrupt files fail cleanly instead of panicking or allocating wildly. The pure parseZoxideDB/zoxideDBReader functions are directly reusable by any tool that needs to read zoxide history, and the edge-case tests (truncation, oversize, corrupt length) are exemplary.
A compact weight-times-relevance scoring model: relevance decays by age (4x within the hour, 2x within the day, 0.5x within the week, 0.25x otherwise), and the injectable 'Now' variable makes recency logic deterministically testable. Simple, well-tested, and portable to any frequency/recency ranking problem such as shell history, MRU lists, or search suggestions.
Generic JSON persistence helpers tuned for read-modify-write config files: Decode tolerates trailing content by looping until io.EOF, and Encode seeks to start and truncates before writing, making repeated decode/encode cycles safe on the same handle. The minimal WriteSeekerTruncater interface keeps it mockable and framework-free, so it slots into any Go project needing robust JSON file state.