Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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


Tree-sitter and LSP solve different problems.

LSP is a full fledged semantics solution providing go-to-definition functionality, trace references, type info etc. But requires a full language server, project configuration, and often a working build. That's great in an IDA, but the burden could be a bit much when it comes to working through an agent.

Tree-sitter handles structural queries giving the LLM the ability to evaluate function signatures, hierarchies and such. Packing this into the recursive language model enables the LLM to decide when it has enough information, it can continue to crawl the code base in bite sized increments to find what it needs. It's a far more minimal solution which lets it respond quickly with minimal overhead.


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.



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.


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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: