9
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
this post was submitted on 23 Jun 2026
9 points (73.7% liked)
Free Open-Source Artificial Intelligence
4816 readers
27 users here now
Welcome to Free Open-Source Artificial Intelligence!
We are a community dedicated to forwarding the availability and access to:
Free Open Source Artificial Intelligence (F.O.S.A.I.)
More AI Communities
LLM Leaderboards
Developer Resources
GitHub Projects
FOSAI Time Capsule
- The Internet is Healing
- General Resources
- FOSAI Welcome Message
- FOSAI Crash Course
- FOSAI Nexus Resource Hub
- FOSAI LLM Guide
founded 3 years ago
MODERATORS
I implemented a system for exploring my own source code via tools a while back. I have
find_files,read_source_codeand a few others that allow putting in a project name and/or filename as parameters (restricted heavily based on permissions I've set in my custom harness). It's been pretty good at following tasks like "Read the source code in thefooproject and update the documentation insuch-and-such.md" -- which I have mermaid.js sequence diagrams embedded into. (I don't give it direct file write access; it just gives my output in my chat client and I copy over what it spits out and diff against what was in git then tweak if needed.)Quoting directly from the code works well with no particular special effort. It is absolutely terrible at giving line numbers though (hallucinates everything when it tries to do that). I have a few ideas on how I might be able to improve that -- the most straightforward is to just inject comments with the line number into the return from the tool call (so that it can quote the number instead of trying to estimate position). If that's not good enough, I've also got an AST-based source code reader (only for JS and Python though) that can return line numbers, It was intended for skeletonizing code so that I could throw larger files at an LLM without it having to read the entire thing and then just pull chunks out with
read_source_codebased on line number ranges -- but it hasn't been particularly effective at making good use of that capability. Maybe that concept could be repurposed for quoting code to the user though if the simpler approaches aren't good enough... 🤔️TL;DR: This is relevant to my interests and I might build my own too!
I'm not sure if I'm missing something, but can this not be solved with one Linux command?
grepThe command has a
-noption to output line numbers and-C xto providexlines of context.There's no extra software required, doesn't need an LLM, doesn't hallucinate, just a plain search.
What the LLM can do that grep can't is that it can find things by imperfect description. You need to know a text string that's exactly in the file to get grep/ack/etc. to locate it; you can be vague with an LLM and it may still be able to figure it out. It's the difference between searching for
FooBarFactoryalready knowing the exact name and trying to find the file it's in (where grep, etc. are great) and "find the code that instantiates FooBar objects infooproject and tell me what it's called" when you don't know if it was FooBarManager or FooBarFactory or it's actually a function calledmake_foo_bar()instead of factory class or there are actually three different ways to do it because of legacy code.So, a fuzzy search then?
There's several command line tools for that too.
More like a conceptual search. e.g. I've used my source code explorer to get a survey of how the template handling works in llama.cpp since the sample chat code doesn't apply the same logic that llama-cli actually does.
yea no ur right, grep works great fir doin codebase search. dunno what this other peeps is going on about, for the case of file search, grep rules.
i know that generally, quoting stuff from files works well. the point here is less about being useful but more about being 100% verifiable.
indexing things with line numbers absolutely works, but u gotta actually put line numbers in the tool output. Meaning, the
read_source_codeshould return the line number at the start if each line, e.g.it eats up tokens, but does make line index hit rate almost always correct.
Are you thinking to make something like a
quote_snippettool that you give a file and line range to and have it (deterministically) present that to the user as part of the response?yyyyes exactly.