TICoder: A Repository-Level Code Generation Framework with Test-Driven Planning and Implementation-Aware Reuse
This paper introduces TICoder, a novel repository-level code generation framework that enhances Large Language Model performance by integrating a test-driven iterative planning mechanism for behavioral guidance and an implementation-aware reuse strategy with dual-view similarity and dual-stage selection to effectively leverage existing repository code, achieving a 11.52% average improvement over state-of-the-art methods.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine you are a master chef (the AI) trying to cook a complex dish based on a customer's vague order: "Make me something with pasta." You have access to a massive library of recipe books (the code repository), but you can only read a few pages at a time.
Most current AI chefs try to solve this by looking up a single recipe that sounds similar to "pasta" and copying it. But this often fails because the customer might want a specific type of pasta, or the recipe might be missing a crucial step like "boil the water first."
TICoder is a new, smarter way to help the AI chef cook. It acts like a highly organized sous-chef who doesn't just find recipes but helps the AI plan the meal and learn exactly how to use the ingredients correctly. Here is how it works, broken down into three simple parts:
1. The "Test-Driven" Planning (The Taste Test)
The Problem: When the AI tries to plan the steps to cook the dish just from the customer's vague words, it often misses the details. It might forget to check if the pasta is gluten-free or if the sauce needs to be simmered for an hour.
The TICoder Solution: Before the AI starts cooking, TICoder asks for a "taste test" (test cases). These are like specific instructions: "The sauce must be spicy," or "The pasta must be al dente."
- How it works: The AI drafts a plan. Then, a "Judge" AI looks at the plan and the taste tests. If the plan doesn't match the tests (e.g., "You forgot the spice!"), the Judge sends it back for refinement.
- The Result: The AI keeps looping through this "draft, judge, fix" cycle until the plan perfectly matches the expected outcome. This ensures the AI knows exactly what to build before it starts building it.
2. The "Implementation-Aware" Reuse (Finding the Right Tool)
The Problem: Once the AI has a plan, it needs to find existing tools (functions) in the library to help.
- Old Way: The AI looks for a tool that sounds like what it needs. It might find a "sauce maker" that works, but it uses the wrong kind of heat or adds salt when it shouldn't. It grabs the tool but doesn't know how to use it properly.
- TICoder Solution: TICoder looks at the tool in two ways:
- Function: Does it do the right job? (e.g., "Yes, it makes sauce.")
- Implementation: Does it work the right way? (e.g., "Yes, it simmers for 20 minutes, just like we need.")
- The Result: It finds the exact tool that matches both the job description and the specific way it needs to be done.
3. The "Usage Pattern" Selection (Learning from Examples)
The Problem: Even if the AI finds the perfect tool, it might not know how to plug it in. Imagine finding a complex espresso machine but not knowing which button to press to get a latte versus a cappuccino.
The TICoder Solution: TICoder doesn't just give the AI the tool; it shows the AI how other chefs used that exact tool in the past.
- It looks at the library to see how this tool was actually used in real recipes.
- It filters through thousands of examples to find the best, most common ways to use it (clustering similar methods) and removes the confusing or weird ones.
- The Result: The AI gets a "cheat sheet" showing the top 2 or 3 best ways to use the tool, ensuring it doesn't make a mistake when assembling the final dish.
The Final Result
When you put all three parts together:
- Planning: The AI knows exactly what to do because it checked its work against "taste tests."
- Retrieval: It finds the perfect tools that match both the job and the method.
- Reuse: It knows exactly how to use those tools because it studied real examples.
The Outcome: In the paper's experiments, this method helped the AI cook (generate code) much better than previous methods. It improved success rates by an average of 11.52% across different types of coding tasks and different AI models. Essentially, TICoder turns a confused AI into a precise, well-planned, and experienced chef.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.