Live data from Hacker News

Show HN: CodeRLM – Tree-sitter-backed code indexing for LLM agents

github.com

21–30 of 38 posts

Re: Show HN: CodeRLM – Tree-sitter-backed code indexing for LLM agents

#21
post #11

Aider [0] wrote a piece about this [1] way back in Oct 2023! I stumbled upon it in late 2023 when investigating ways to give OpenHands [2] better context dynamically. [0] https://aider.chat/ [1] https://aider.chat/2023/10/22/repomap.html [2] https://openhands.dev/

I am planning to add similar concepts to Yek. Either tree-sitter or ast-grep. Your work here and Aider's work would be my guiding prior art. Thank you for sharing!

https://github.com/mohsen1/yek

Re: Show HN: CodeRLM – Tree-sitter-backed code indexing for LLM agents

#22
post #10

Great idea! I’ve been thinking about something along these lines as well. I recommend configuring it as a tool for Opencode. Going from Claude Code to Opencode was like going from Windows to Mac.

And going to pi agent is like ascending to Linux ;)

Re: Show HN: CodeRLM – Tree-sitter-backed code indexing for LLM agents

#23
post #11

Aider [0] wrote a piece about this [1] way back in Oct 2023! I stumbled upon it in late 2023 when investigating ways to give OpenHands [2] better context dynamically. [0] https://aider.chat/ [1] https://aider.chat/2023/10/22/repomap.html [2] https://openhands.dev/

Aider's repomap is a great idea. I remember participating in the discussion back then.

The unfortunate thing for Python that the repomap mentions, and untyped/duck-typed languages, is that function signatures do not mean a lot.

When it comes to Rust, it's a totally different story, function and method signatures convey a lot of important information. As a general rule, in every LLM query I include maximum one function/method implementation and everything else is function/method signatures.

By not giving mindlessly LLMs whole files and implementations, I have never used more than 200.000 tokens/day, counting input and output. This counts as 30 queries for a whole day of programming, and costs less than a dollar per day not matter which model I use.

Anyway, putting the agent to build the repomap doesn't sound such a great idea. Agents are horribly inefficient. It is better to build the repomap deterministically using something like ast-grep, and then let the agent read the resulting repomap.

Re: Show HN: CodeRLM – Tree-sitter-backed code indexing for LLM agents

#24
post #3

I see a lot of overlap with LSPs, which better agents already use, so I would appreciate a comparison. What does this add?

LSP is designed to help editors, not AI agents, and provides query by cursor position. Treesitter supports query by symbol (find definition, usages, etc), and so is much better suited to what an AI agent may want to do.

Re: Show HN: CodeRLM – Tree-sitter-backed code indexing for LLM agents

#25
post #15

Earlier quoted context omitted.

I don't see why it wouldn't - but I'm not familiar with setup / integration on other platforms. Would love to hear more about your stack and see if we can't find a way for you to try it out

A CLI or slim MCP would do it. IF you want a formal plugin, here's another popular ecosystem: https://opencode.ai/docs/plugins/

My experience is best with cli and a concise skill.md

Re: Show HN: CodeRLM – Tree-sitter-backed code indexing for LLM agents

#26
post #17

I wonder how this sort of thing compares with asking claude to read a ctags file. I have git hooks set up to keep my tags up to date automatically, so that data is already lying around.

ctags just gives you locations of symbol definitions.

TreeSitter will also give you locations of symbol usages, which is obviously very useful to an AI agent. You can basically think of Treesitter as having full syntactic knowledge of the code it is looking at - like a compiler's AST.

There is also a more powerful cousin of ctags, cscope (C/C++) and Pycscope (python) that additonally gives usage locations, and more, as well as gtags that does similar, but supports more languages.

Re: Show HN: CodeRLM – Tree-sitter-backed code indexing for LLM agents

#27
post #3

I see a lot of overlap with LSPs, which better agents already use, so I would appreciate a comparison. What does this add?

LSP is designed to help editors, not AI agents, and provides query by cursor position. Treesitter supports query by symbol (find definition, usages, etc), and so is much better suited to what an AI agent may want to do.

My agent already uses LSP plugins, and the protocol supports querying by symbol:

https://microsoft.github.io/language-server-protocol/specifi...

https://microsoft.github.io/language-server-protocol/specifi...

Re: Show HN: CodeRLM – Tree-sitter-backed code indexing for LLM agents

#28
post #27

Earlier quoted context omitted.

LSP is designed to help editors, not AI agents, and provides query by cursor position. Treesitter supports query by symbol (find definition, usages, etc), and so is much better suited to what an AI agent may want to do.

My agent already uses LSP plugins, and the protocol supports querying by symbol: https://microsoft.github.io/language-server-protocol/specifi... https://microsoft.github.io/language-server-protocol/specifi...

Thanks - I wasn't aware of that, although it still doesn't seem to be what would be most useful to an AI agent.

For example, if the agent wants to modify a function, it may want to know all the places the function is called, which AFAIK Treesitter can provide directly, but it seems with LSP you'd have to use that DocumentSymbol API to process every source file to find the usages, since you're really searching by source file, not by symbol.

Re: Show HN: CodeRLM – Tree-sitter-backed code indexing for LLM agents

#29
post #27

Earlier quoted context omitted.

My agent already uses LSP plugins, and the protocol supports querying by symbol: https://microsoft.github.io/language-server-protocol/specifi... https://microsoft.github.io/language-server-protocol/specifi...

Thanks - I wasn't aware of that, although it still doesn't seem to be what would be most useful to an AI agent. For example, if the agent wants to modify a function, it may want to know all the places the function is called, which AFAIK Treesitter can provide directly, but it seems with LSP you'd have to use that DocumentSymbol API to process every source file to find the usages, since you're really searching by sour…

For that I believe you could use textDocument/references:

https://microsoft.github.io/language-server-protocol/specifi...

Re: Show HN: CodeRLM – Tree-sitter-backed code indexing for LLM agents

#30
post #29

Earlier quoted context omitted.

Thanks - I wasn't aware of that, although it still doesn't seem to be what would be most useful to an AI agent. For example, if the agent wants to modify a function, it may want to know all the places the function is called, which AFAIK Treesitter can provide directly, but it seems with LSP you'd have to use that DocumentSymbol API to process every source file to find the usages, since you're really searching by sour…

For that I believe you could use textDocument/references: https://microsoft.github.io/language-server-protocol/specifi...

Yes, but that one is position-based rather than name-based - I believe it's basically for an editor to ask about whatever is under the cursor.
Post reply on HN