Skip to content

searchLocal resource

The searchLocal executor walks a local directory and returns matching files by filename glob pattern and/or content keyword. See Search resources for how it relates to searchWeb.

It works in both modes: as a DAG step in workflow mode, and inside any workflow the LLM calls as a tool in agent mode.

Configuration

yaml
# resources/search.yaml
searchLocal:
  path: "/data/documents"    # required: directory to search
  query: "invoice total"     # optional: keyword in file contents
  glob: "*.txt"              # optional: filename pattern
  limit: 10                  # optional: max results (0 = unlimited)
FieldTypeRequiredDefaultDescription
pathstringyes-Directory to search recursively
querystringno-Case-insensitive keyword to find in file contents
globstringno-Filename glob pattern (e.g. *.md, report_*.csv)
limitintegerno0Max results (0 = unlimited)

When both query and glob are set, a file must match both to be included.

Output

KeyTypeDescription
resultsarrayList of matching file objects
countintegerNumber of results
pathstringThe search root used
jsonstringFull result as JSON string

Each result object:

KeyTypeDescription
pathstringFull file path
namestringFilename
sizeintegerFile size in bytes
isDirboolAlways false

Examples

Find all Markdown files:

yaml
# resources/find-docs.yaml
actionId: findDocs
searchLocal:
  path: "/workspace/docs"
  glob: "*.md"

Find files containing a keyword:

yaml
# resources/find-invoices.yaml
actionId: findInvoices
searchLocal:
  path: "/data/uploads"
  query: "overdue"
  limit: 20

Feed results into an LLM:

yaml
# resources/find-files.yaml
actionId: findFiles
searchLocal:
  path: "/data/reports"
  query: "{{ get('query') }}"

---
actionId: answer
requires: [findFiles]
chat:
  model: llama3.2:1b
  prompt: "Files found: {{ output('findFiles').results }}. Summarize."

Indexed search (ranked results)

index: true switches searchLocal from a plain directory walk to a persistent TF-IDF inverted index, giving each result a relevance score instead of just a yes/no filename/content match. The index is built once (or incrementally reused) at <path>/.kdeps/index.db and speeds up repeated searches of the same folder.

yaml
searchLocal:
  path: "/workspace/docs"
  query: "authentication flow"
  index: true                # build/use a persistent TF-IDF index instead of walking every search
  fuzzy: true                 # optional: Levenshtein fuzzy matching (requires index: true)
  maxDistance: 2               # optional: max edit distance for fuzzy matching, default 2
  indexDBPath: "/custom/index.db"  # optional: override the default <path>/.kdeps/index.db
  graphBoost: true             # optional: re-rank using the folder's link/topic graph (requires index: true)
FieldTypeRequiredDefaultDescription
indexboolnofalseBuild/use a persistent TF-IDF inverted index instead of a plain walk
fuzzyboolnofalseEnable Levenshtein fuzzy term matching (requires index: true)
maxDistanceintegerno2Max edit distance for fuzzy matching
indexDBPathstringno<path>/.kdeps/index.dbWhere the TF-IDF index is stored
graphBoostboolnofalseRe-rank results using the same kartographer reference/topic graph codeIntelligence's indexFolder/graphAll builds - requires index: true

How graphBoost ranks results: searchLocal already ranks by TF-IDF. graphBoost additionally builds a graph of the folder - markdown links and shared topics:/tags: frontmatter - at <path>/.kdeps/graph.db (kept separate from indexDBPath). A result linked from, or sharing a topic with, a top-5 TF-IDF match gets boosted 25% before the final sort, so a lower-scoring-but-connected document can outrank a higher-scoring-but-isolated one - useful when the top match is a short "index" page.

yaml
# resources/search-graph.yaml
actionId: findRelatedDocs
searchLocal:
  path: "/workspace/docs"
  query: "{{ get('query') }}"
  index: true
  graphBoost: true

Indexed-mode output rows add two fields on top of the base result shape:

KeyTypeDescription
scorefloatTF-IDF relevance score (post-boost when graphBoost is set)
matchCountintegerNumber of distinct query terms matched
snippetstringText excerpt around the match

See also

Released under the Apache 2.0 License.