semcode

semcode usage guide

All semcode functions are git aware and default to lookups on the current commit. You can also pass a specific commit you’re interested in, or a branch name.

Regex: all patterns are case-insensitive; no (?i) needed. Applies to function names, commit messages, symbols, and lore email searches.

Common parameters

Conventions: boolean parameters default to false; limit: 0 means unlimited, except where the tool declares an explicit max – in that case the max wins and limit: 0 is rejected.

Code lookup

In the call-graph tools below (find_callers, find_calls, find_callchain), both sides of a call edge include functions and function-like macros.

find_function: search for functions and macros

file_survey: return compact Tree-sitter syntax facts for one workspace file

Note: commit tools use git_ref (not git_sha from the common parameters) and symbol_patterns (singular; AND’d – distinct from lore’s plural symbols_patterns, which is OR’d). They do not accept since_date/until_date; those date filters are lore-only.

Commit selection in find_commit: git_ref and git_range are mutually exclusive. reachable_sha is a filter that may accompany either, or stand alone (with no git_ref or git_range) to mean “all indexed commits reachable from this sha”.

find_commit: search for changes, potentially in a range of commits

Lore (kernel mailing list archive)

Lore tools use symbols_patterns (plural; OR’d within the array – distinct from commit tools’ singular symbol_patterns, which is AND’d). All *_patterns arrays below are OR’d within the array.

lore_search: search lore.kernel.org email archives

Branch / status

list_branches: list indexed branches with indexed SHA and freshness (up-to-date vs. outdated against current tip). No parameters. The tool also returns structuredContent with version: 1 and a branches array of {name, commit, indexed_at} objects. Each commit is the full SHA recorded in the index; indexed_at is the Unix time, in seconds, when the branch was last indexed. compare_branches: compare two branches; shows merge base, ahead/behind status, and indexing status for both

Lazy Loading

Start the server with --lazy to cut initial context ~96%. The server then exposes only three meta-tools (list_categories, get_tools, call_tool); call them in that order to discover and invoke full tools on demand.

Recipes

Locating a backported commit reachable from HEAD (or any other sha)

Repositories that heavily cherry-pick patches store the backport under a different git sha than the upstream commit. Search by commit subject to find it, then narrow to commits reachable from the branch tip with reachable_sha:

find_commit(regex_patterns=["bnxt_en: Fix memory corruption when FW resources change during ifdown"])
find_commit(regex_patterns=["bnxt_en: Fix memory corruption when FW resources change during ifdown"],
            reachable_sha="HEAD")