Skip to content

Scout

Scout is the code search built into gerald. Given a task in plain words, it returns the pieces of your project most likely to matter: the methods, their tests, and the files they depend on. It runs on your machine, needs no model, GPU or network, and is free: no licence and no sign-in.

  • Inside Fill. When Gerald writes a method, Scout finds who calls it and the same-named methods elsewhere in the project, and Gerald shows those to the model. You do not run anything; see Fill.
  • On its own. gerald scout prints the context for a task, to read or to paste into another tool.
Terminal window
gerald scout "cart total"
# Project file: test/cart_test.rb [89..194]
def test_total
assert_equal 6, Cart.new([1, 2, 3]).total
assert_equal 0, Cart.new([]).total
end
# Project file: cart.rb [66..97]
def total
@prices.sum
end

Each heading names the file and the byte range that follows. The best matches come first. With nothing relevant, Scout prints nothing.

gerald scout [TASK] [options]
Option Default
--root <DIR> . Where to search
--exclude <GLOB> Leave out matching paths, such as 'vendor/**'. Repeatable
--max-bytes <N> 16384 The most context to return
--json Print JSON: the context, plus each ranked piece with its score and reason

gerald scout is not listed in gerald --help.

Scout follows your .gitignore, and skips hidden files, symlinks, binary files, files over 1 MiB and .git. It never reads outside --root.

  • Ruby is split by method. In a Rails app, a model brings its test or spec and the schema; a controller brings its routes.
  • Rust, Python, JavaScript, TypeScript, Go, Java, C, C++, C#, PHP, Kotlin and Swift are split by declaration.
  • Everything else is split into chunks of whole lines.

Matching is by words and identifiers, not meaning: name the thing you are looking for.

A search index at ~/.cache/gerald/scout/index.sqlite (or under XDG_CACHE_HOME), capped at about 64 MiB. It holds terms from your code and stays on this machine. Results always come from the files as they are now, never from the index. It is safe to delete; Scout rebuilds it.