🤖 Project Story: RefactorBot Society
💡 Inspiration
Updating old, messy computer code is a tedious and risky task. While single AI prompts can translate code, they often miss deep software engineering standards and accidentally introduce dangerous security flaws. I wanted to move away from relying on a single AI draft. Instead, I built an automated "Society" of specialized AI workers that debate, collaborate, and thoroughly check each other's work. It mimics a strict, professional engineering team where code has to earn its right to be published.
⚙️ What it Does
RefactorBot Society takes outdated, complicated code (like old, callback-heavy Node.js) and updates it into clean, modern systems (like asynchronous FastAPI). Instead of trusting the first attempt, the system puts the code through a rigorous review loop with five AI agents:The Parser: Analyzes the old code to spot flaws and weak links.The Architect: Drafts a clean, modern blueprint for the system.The Developer: Turns the blueprint into functional, modern code.The QA Engineer: Acts as a ruthless security guard, checking for hidden bugs, crashes, and vulnerabilities.The Senior Reviewer: Steps in if the QA Engineer rejects the code, helping mediate problems and sending instructions back to the Developer.The system only shows the final code to the user once it passes the QA Engineer's strict tests.
🛠️ How I Built It
The backend uses modern, standard tools (TypeScript and Node.js) to manage the agents. The application runs "serverless" on Alibaba Cloud Function Compute, meaning it scales automatically and doesn't require managing physical servers. The brains behind these agents run on the Alibaba Cloud DashScope API, utilizing Qwen models. The user interface features a sleek dark-mode dashboard that lets developers watch the agents "think" and negotiate in real-time.
📐 How the Code is Scored
To make sure the code isn't just following rules, but is actually safe, the QA agent calculates a security score S (ranging from 0 to 100) by checking if the code tries to access risky websites or contains known threats.(S=\max \left(0.0,\min \left(100.0,100.0-P_{DNS}-P_{Threat}\right)\right))Any code that scores below 80.0 or shows structural security flaws is automatically rejected.
🚧 Challenges
The hardest part was keeping the serverless system from shutting down the AI agents in the middle of their debates. Because the QA Engineer is incredibly thorough, the agents often take multiple tries to agree on a fix. Initially, the system kept cutting off at 60 seconds. I solved this by extending the maximum execution limit on Alibaba Cloud Function Compute to 300 seconds, giving the agents enough time to have full, human-like technical debates.
🏆 Accomplishments
I am thrilled with how smart the QA Agent is. During testing, the agents were given a broken calculator script and successfully stopped it from letting an unauthorized user take control of the server. Watching the AI catch the bug, escalate it to the Senior Reviewer, and safely rewrite the engine was a huge milestone.
📚 What I Learned
I learned that setting strict rules and boundaries makes for much stronger software. Managing a conversation across multiple AI streams requires incredible precision, but treating the AI like a real-world engineering team—where everyone has a specific, limited job—drastically reduces mistakes and keeps the code accurate
🚀 What's Next
Next, I want to add an "Attacker" agent that actively tries to hack the Developer's code before the QA Agent approves it. I also plan to turn this entire system into a native GitHub Action, which will allow old, forgotten code repositories to get automated, verified, and updated code automatically on a regular schedule.
Built With
- alibaba
- dashscope
- express.js
- fastapi
- github
- html5
- javascript
- node.js
- python
- qwen
- typescript
Log in or sign up for Devpost to join the conversation.