top | item 47023355

(no title)

hallh | 15 days ago

We've tackled this problem slightly differently where I work. We have AI agents contribute in a large legacy codebase, and without proper guidance, the agents quickly get lost or reimplement existing functionality.

To help the agents understand the codebase, we indexed our code into a graph database using an AST, allowing the agent to easily find linked pages, features, databases, tests, etc from any one point in the code, which helped it produce much more accurate plans with less human intervention and guidance. This is combined with semantic search, where we've indexed the code based on our application's terminology, so when an agent is asked to investigate a task or bug for a specific feature, it'll find the place in the code that implements that feature, and can navigate the graph of dependencies from there to get the big picture.

We provide these tools to the coding agents via MCP and it has worked really well for us. Devs and QAs can find the blast radius of bugs and critical changes very quickly, and the first draft quality of AI generated plans requires much less feedback and corrections for larger changes.

In our case, I doubt that a general purpose AST would work as well. It might be better than a simple grep, especially for indirect dependencies or relationships. But IMO, it'd be far more interesting to start looking at application frameworks or even programming languages that provide this direct traversability out of the box. I remember when reading about Wasp[0] that I thought it would be interesting to see it go this way, and provide tooling specifically for AI agents.

[0] https://wasp.sh/

discuss

order

namibj|13 days ago

Who'd have thought advanced semantic navigation and search as e.g. in the IDEA (Jetbrains) family of IDEs with framework awareness helps not just humans?

Also note it's "structural search (and replace)" that let's you: - essentially regex against the semantically annotated AST, which gives you things like match on function calls that are given an (otherwise arbitrary) object that implements some particular interface (be that interface nominally typed as in Java, or structurally typed as in TypeScript). - or fancier, database queries with a join condition equality matching a string type, that are invoked from inside a loop, with another database query outside and in front of that very loop.

Personally I hated when due to a poorly debated user wish, they turned off auto indenting in full file column space for multi-line inline SQL in PHP, not only forcing a massive commit that messes up `git blame`, but also just annoyingly throwing the outer PHP context's indentation level away causing the SQL to be waaay too far left.

andout_|13 days ago

This is close to what we're doing with [Encore](https://encore.cloud). The framework parses your application code through static analysis at compile time to build a full graph of services, APIs, databases, queues, cron jobs, and their dependencies. It uses that graph to provision infrastructure, generate architecture diagrams, API docs, and wire up observability automatically.

The interesting side effect is that AI tools get this traversability for free. When business logic and infrastructure declarations live in the same code, an AI agent doesn't need a separate graph database or MCP tool to understand what a service depends on or what infrastructure it needs. It's all in the type signatures. The agent generates standard TypeScript or Go, and the framework handles everything from there to running in production.

Our users see this work really well with AI agents as the agent can scaffold a complete service with databases and pub/sub, and it's deployable immediately because the framework already understands what the code needs.

SOLAR_FIELDS|14 days ago

I’m currently experimenting with something similar on a smaller scale using continue.dev’s code indexing implementation to expose a context mcp server for both semantic and code search. Tricky part is of course context management.