diff options
| author | Pjotr Prins <pjotr.public01@thebird.nl> | 2026-11-17 10:18:26 +0000 |
|---|---|---|
| committer | Pjotr Prins <pjotr.public01@thebird.nl> | 2026-11-17 10:18:26 +0000 |
| commit | b7234d2514b4a693b37cf4968b267a5fafe16678 (patch) | |
| tree | 0691588a6d1507230f9298ac18b855675c4d2eeb /git.odin | |
| parent | b861693dc26a8f9944c3464a34c101af5a81d33c (diff) | |
| download | ai-memory-master.tar.gz | |
A commit that only adds a file recorded nothing: git has no before-side for
the new file, so its hunks carry no context ("@@ -0,0 +1,207 @@"), and Python
and Ruby had no declaration scanner to fall back on. Adding
bin/geno2mdb.py to gemma-wrapper left one commit row and two reasoning
entries with no symbol at all, so `why` could not reach them while `search`
and `list` could.
Both languages are now scanned line by line, which is the right tool here:
in Python and Ruby a declaration is the first token on its line, so the
keyword decides -- `def foo(bar):` declares, `foo(bar)` calls -- the
distinction no C++ line scanner can make.
Python def / async def -> fn, class -> type, and at column 0 only
NAME = value -> const, NAME: Type -> var (an indented assignment
is a local inside a def)
Ruby def / def self.NAME (with ? ! = suffixes) -> fn, class / module ->
type, and a column-0 capitalised NAME = value -> const
An added file needs no special case: every one of its lines is a '+' line,
which git_touched already walks, so the same path that records an added line
in an existing file now records a new file's declarations. Names strip .py
and .rb like .odin and .rs (script.helper); the C family keeps its extension
because a header declaration and the source definition are different rows.
The lookup's last resort was `s.name like '%name'` -- a suffix match -- so
`why geno2mdb` could never find a file's own symbols even though SKILL.md
documents a LIKE '%...%' scan. It is a substring match now, so the file base
works, and the doc is true again.
The check phase commits script.py and script.rb into its throwaway
repository and asserts both land as `add` rows and that `why script`
resolves; measured on gemma-wrapper, sync adds 344 touches over 319 commits
and `why read_snps` reaches the reasoning attached to the commit that
introduced it.
Diffstat (limited to 'git.odin')
| -rw-r--r-- | git.odin | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/git.odin b/git.odin index cbabf3c..0f7c9af 100644 --- a/git.odin +++ b/git.odin @@ -638,7 +638,10 @@ symbol_name :: proc(file, name: string) -> string { if i := strings.last_index_byte(base, '/'); i >= 0 { base = base[i + 1:] } - extensions := [?]string{".odin", ".rs"} + // A C-family name keeps its extension (lmm.cpp.mdb_analyze) because a header + // declaration and the definition in the source are different rows; the others + // are single-file languages, where the base name is enough. + extensions := [?]string{".odin", ".rs", ".py", ".rb"} for ext in extensions { if strings.has_suffix(base, ext) { base = base[:len(base) - len(ext)] |
