imDarshanGK/AI-dev-assistant

GitHub: imDarshanGK/AI-dev-assistant

一款开源的AI代码分析助手,通过即时错误检测、代码解释和改进建议,帮助开发者提升代码质量与安全。

Stars: 48 | Forks: 185

QyverixAI

调试。理解。交付更快。

一款开源的AI驱动开发者助手,能即时检测错误、用通俗英语解释代码,
并提供可操作的改进建议——无需账户,立即使用。


[![CI](https://static.pigsec.cn/wp-content/uploads/repos/2026/05/5cf3ff4a87075857.svg)](https://github.com/imDarshanGK/AI-dev-assistant/actions) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) [![FastAPI](https://img.shields.io/badge/FastAPI-0.115+-009688?logo=fastapi&logoColor=white)](https://fastapi.tiangolo.com) [![Python](https://img.shields.io/badge/Python-3.12+-3776AB?logo=python&logoColor=white)](https://python.org) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](CONTRIBUTING.md) [![GSSoC 2026](https://img.shields.io/badge/GSSoC-2026-FF6B35?logoColor=white)](https://gssoc.girlscript.tech)
**[现场演示](https://qyverixai.onrender.com)**  ·  **[API 文档](https://qyverixai.onrender.com/docs)**  ·  **[贡献指南](CONTRIBUTING.md)**  ·  **[适合新手的问题](https://github.com/imDarshanGK/AI-dev-assistant/labels/good%20first%20issue)**
## QyverixAI 是什么? QyverixAI 是一个代码分析工作空间。粘贴任何代码,立即获得三项结果: | | 您将获得什么 | |---|---| | **解释** | 语言检测、通俗英语摘要、复杂度评估、函数和类清单 | | **调试** | 针对5种语言超过40种模式的检查,附带精确行号、代码片段和修复建议 | | **改进** | 文档缺口、错误处理、测试、类型安全——外加0-100的质量评分和A-F字母等级 | 无需账户。无需API密钥。完全离线工作。完全开源。 ## 预览 ## 功能特性 | 功能 | 详情 | |---|---| | **40+ 错误模式** | ZeroDivisionError、裸异常捕获、硬编码密钥、eval()、内存泄漏、XSS、NullPointerException等 | | **5种语言** | Python、JavaScript、TypeScript、Java、C++ | | **完整分析端点** | 一次调用——解释 + 调试 + 改进组合,附带计时指标 | | **质量评分** | 0-100分,字母等级A-F,以及优先建议 | | **文件上传** | 拖放或上传 `.py` `.js` `.ts` `.java` `.cpp` | | **深色/浅色模式** | 跨会话持久保存 | | **查询历史** | 本地保存最近50次分析 | | **收藏夹** | 书签并重新加载任何分析 | | **分享链接** | 为任何分析生成一个短期有效的URL并发送给队友 | | **下载结果** | 将完整报告导出为 `.txt` | | **LLM就绪** | 通过环境变量接入OpenAI、Groq、Ollama或任何OpenAI兼容的提供商 | | **速率限制** | 每个IP每分钟30个请求——可配置 | | **Swagger文档** | `/docs` 处的交互式API文档 | | **Gzip压缩** | 自动响应压缩 | ### 语言和模式 | 语言 | 检测到的模式 | |---|---| | **Python** | ZeroDivisionError、裸异常捕获、eval/exec、可变默认值、硬编码密钥、通配符导入、全局变量、缺少类型提示、循环中的字符串拼接、生产环境中的断言、与None比较 | | **JavaScript** | var使用、松散等式 `==`、console.log、回调地狱、innerHTML XSS、未处理的Promise | | **TypeScript** | `any` 类型、非空断言 `!`、未处理的Promise、缺少环境变量验证 | | **Java** | NullPointerException风险、原始类型泛型、宽泛的catch、String `==` 比较、System.exit | | **C++** | 内存泄漏、不安全的gets/scanf、`using namespace std`、有符号/无符号不匹配 | ## 快速开始 ### 前置条件 - Python 3.11 或 3.12 - pip - 现代浏览器(Chrome、Firefox、Edge、Safari) ### 1 - 克隆 ``` git clone https://github.com/imDarshanGK/AI-dev-assistant.git cd AI-dev-assistant ``` ### 2 - 运行后端 ``` cd backend pip install -r requirements.txt uvicorn app.main:app --reload ``` ### 环境设置 将 `.env.example` 复制为 `.env` ``` cp .env.example .env ``` 运行应用前,根据需要更新环境变量值。 重要变量: - `JWT_SECRET` - `DATABASE_URL` - `RATE_LIMIT_PER_MINUTE` - `LLM_API_KEY`(可选) 当 `LLM_ENABLED=false` 时,应用仍可在没有外部AI提供商的情况下运行。 | 端点 | URL | |---|---| | API根路径 | http://localhost:8000/ | | 交互式文档 | http://localhost:8000/docs | | 健康检查 | http://localhost:8000/health | | 注册 | http://localhost:8000/auth/signup | | 登录 | http://localhost:8000/auth/login | | 当前用户 | http://localhost:8000/auth/me | ### 3 - 打开前端 ``` # 无需构建步骤,直接在浏览器中打开 open frontend/index.html ``` 将API URL字段设置为 `http://localhost:8000`,点击 **Ping** 确认绿色的“已连接”状态,然后粘贴任何代码并点击 **分析代码**。 ## API 参考 所有端点接受 `POST` 请求,`Content-Type: application/json`。 **请求体** ``` { "code": "your code here", "language": "python" } ``` `language` 是可选的——引擎会从代码中自动检测它。 ### `POST /explanation/` 返回代码的通俗英语分解。 ``` { "language": "Python", "summary": "A short Python snippet (5 lines) that performs a focused task.", "key_points": [ "Written in Python — 5 non-blank lines of code.", "Defines 1 function: calculate.", "Contains conditional logic — branching control flow." ], "complexity": "Beginner", "line_count": 6, "function_count": 1, "class_count": 0 } ``` ### `POST /debugging/` 返回检测到的问题,附带行号、代码片段和修复建议。 ``` { "issues": [ { "type": "ZeroDivisionError", "line": 2, "description": "Potential division by zero — divisor may be 0 at runtime.", "suggestion": "Guard the divisor: if b == 0: return None", "severity": "error", "code_snippet": "result = a / b" } ], "summary": "Found 1 issue: 1 error, 0 warnings, 0 info.", "clean": false, "error_count": 1, "warning_count": 0, "info_count": 0 } ``` ### `POST /suggestions/` 返回改进建议卡片,附带质量评分。 ``` { "suggestions": [ { "category": "Documentation", "description": "Less than 10% of lines are comments. Add docstrings.", "example": "\"\"\"Calculate the area of a circle given radius r.\"\"\"", "priority": "medium" } ], "overall_score": 72, "grade": "B", "next_step": "Good work. Address the medium-priority items next." } ``` ### `POST /analyze/` 在一个响应中包含所有三种分析,并附带计时信息。 ``` { "provider": "rule-based", "model": "qyverix-engine-v3", "explanation": { "...": "..." }, "debugging": { "...": "..." }, "suggestions": { "...": "..." }, "analysis_time_ms": 1.84 } ``` ### `POST /share/` 和 `GET /share/{id}` 为已保存的分析创建分享链接,然后通过ID加载,创建后七天内有效。 `POST /share/` 接受 `{ "code": "...", "result": { ... } }` 并返回 `{ "id": "short_id" }`。 `GET /share/{id}` 返回已保存的 `{ code, result, created_at }` 载荷,如果分享缺失或已过期则返回 `404`。 ## 项目结构 ``` AI-dev-assistant/ ├── assets/ # Logo and brand assets │ ├── logo-dark.svg │ ├── logo-light.svg │ └── icon.svg ├── backend/ │ ├── app/ │ │ ├── main.py # FastAPI app, middleware, rate limiting │ │ ├── schemas.py # Pydantic v2 request/response models │ │ ├── routers/ │ │ │ ├── analyze.py # POST /analyze/ │ │ │ ├── debugging.py # POST /debugging/ │ │ │ ├── explanation.py # POST /explanation/ │ │ │ ├── suggestions.py # POST /suggestions/ │ │ │ └── auth.py # /auth/signup, /auth/login, /auth/me │ │ └── services/ │ │ ├── code_assistant.py # Rule-based engine — 40+ patterns, 5 languages │ │ └── ai_provider.py # Optional LLM abstraction layer │ ├── requirements.txt │ └── tests/ │ └── test_endpoints.py # 52 tests across all endpoints and languages ├── frontend/ │ └── index.html # Complete UI — no build step, self-contained ├── .github/ │ └── workflows/ │ └── ci.yml # CI on Python 3.11 + 3.12, lint with Ruff ├── .env.example ├── Dockerfile ├── render.yaml ├── CONTRIBUTING.md └── README.md ``` ## 运行测试 ``` cd backend pytest -v ``` 52个测试覆盖所有端点、所有5种语言、10多种单个错误模式、建议评分、完整分析以及边缘情况,包括空代码、Unicode和单行输入。 测试在每次推送和拉取请求时通过GitHub Actions自动运行,覆盖Python 3.11和3.12。 ## 部署 ### Render - 推荐,免费层级 1. Fork此仓库 2. 转到 [render.com](https://render.com) → 新建 Web 服务 3. 连接你的fork - `render.yaml` 会自动配置一切 4. 添加环境变量:`PYTHON_VERSION` = `3.12.0` 5. 点击部署 - 你的应用将在 `https://your-service.onrender.com` 上线 ### Docker ``` docker build -t qyverixai . docker run -p 8000:8000 qyverixai ``` ### Docker Compose 运行完整的本地开发环境: ``` docker compose up --build ``` 可用服务: - 前端 → http://localhost:3000 - 后端API → http://localhost:8000 - PostgreSQL → localhost:5432 停止容器: ``` docker compose down ``` ## 可选的LLM集成 QyverixAI 使用其内置的规则引擎可完全离线工作。要启用更丰富的AI驱动分析,请添加这些环境变量: ``` LLM_ENABLED=true LLM_API_KEY=your-key-here LLM_BASE_URL=https://api.openai.com/v1 LLM_MODEL=gpt-4o-mini LLM_TIMEOUT_SECONDS=30 ``` 兼容 **OpenAI**、**Groq**(免费层级)、**Together AI**、**Ollama**(本地,免费)以及任何OpenAI兼容端点。 ### 提供商可靠性 后端对LLM请求包含内置的弹性: - **指数退避**:超时和连接失败时自动重试。 - **速率限制处理**:在HTTP 429速率限制响应时暂停并重试。 - **优雅降级**:如果LLM提供商完全不可用,可无缝保留离线/基于规则的功能。 ## 配置参考 | 变量 | 默认值 | 描述 | |---|---|---| | `RATE_LIMIT_PER_MINUTE` | `30` | 每个IP每分钟最大请求数 | | `LLM_ENABLED` | `false` | 启用LLM提供商 | | `LLM_API_KEY` | — | 你的LLM提供商的API密钥 | | `LLM_BASE_URL` | `https://api.openai.com/v1` | LLM基础URL | | `LLM_MODEL` | `gpt-4o-mini` | 模型名称 | | `LLM_TIMEOUT_SECONDS` | `30` | 请求超时时间(秒) | 将 `.env.example` 复制为 `.env` 并根据需要填写值。 ## 技术栈 | 层级 | 技术 | |---|---| | 后端 | FastAPI 0.115+、Pydantic v2、Python 3.12 | | 前端 | HTML5、CSS3、Vanilla JS - 无构建步骤、零依赖 | | 测试 | Pytest、FastAPI TestClient | | 代码检查 | Ruff | | 部署 | Docker、Render | | CI | GitHub Actions - Python 3.11 + 3.12 矩阵 | ## 贡献 QyverixAI 是一个 **GSSoC 2026** 开源项目。欢迎所有水平的贡献者。 ``` # 1. 在 GitHub 上 fork 此仓库 # 2. 克隆你的 fork git clone https://github.com/YOUR_USERNAME/AI-dev-assistant.git # 3. 创建一个分支 git checkout -b feat/your-feature-name # 4. 安装并测试 cd backend && pip install -r requirements.txt pytest -v # all 22 tests must pass # 5. 推送并开启一个 pull request ``` 在 [CONTRIBUTING.md](CONTRIBUTING.md) 中阅读完整的工作流程、代码标准和模式指南。 ### 适合GSSoC贡献者的“适合新手的问题” | 任务 | 标签 | |---|---| | 为任何语言添加一个新的错误检测模式 | `easy` | | 为边缘情况添加测试用例 | `easy` | | 改进特定语言的解释要点 | `easy` | | 为前端添加ARIA标签和键盘导航 | `medium` | | 为文件上传添加对新文件类型的支持 | `medium` | | 为Python构建基于AST的深度分析 | `hard` | | 添加VS Code扩展 | `hard` | 浏览所有待解决问题:[github.com/imDarshanGK/AI-dev-assistant/issues](https://github.com/imDarshanGK/AI-dev-assistant/issues) ## 路线图 - [x] 基于规则的代码解释引擎 - [x] 错误检测——跨越5种语言的40+模式 - [x] 改进建议,附带质量评分和字母等级A-F - [x] 包含计时指标的完整分析组合端点 - [x] 每IP速率限制——可配置 - [x] Gzip压缩中间件 - [x] 深色/浅色主题、文件上传、拖放、历史、收藏夹、下载 - [x] LLM提供商抽象层——兼容OpenAI、Groq、Ollama - [x] CI矩阵——Python 3.11 + 3.12 - [ ] 为Python构建基于AST的深度分析 - [ ] 带数据库后端的用户历史(SQLite → PostgreSQL) - [ ] VS Code扩展 - [ ] AI驱动的解释——LLM集成正式发布 - [ ] 多文件分析支持 - [ ] 差异视图——代码改进前后对比 ## 许可证 MIT © [Darshan G K](https://github.com/imDarshanGK)

**[为此仓库点赞](https://github.com/imDarshanGK/AI-dev-assistant)**  ·  **[报告错误](https://github.com/imDarshanGK/AI-dev-assistant/issues/new?template=bug_report.md)**  ·  **[请求功能](https://github.com/imDarshanGK/AI-dev-assistant/issues/new?template=feature_request.md)**
为开源社区构建  ·  GSSoC 2026
标签:AI编程助手, Apex, API文档, AV绕过, bug检测, FastAPI, IPv6支持, Python, 人工智能, 代码分析工具, 代码审查, 代码解释, 代码评分, 代码调试, 代码质量检查, 多模态安全, 多语言支持, 威胁情报, 安全测试框架, 实时分析, 开发者工具, 改进建议, 数据可视化, 无后门, 无需账户, 机器学习, 用户模式Hook绕过, 编程辅助, 自动化测试辅助, 请求拦截, 逆向工具, 错误基检测, 静态代码分析