├── api ├── __init__.py ├── config.py └── index.py ├── requirements.txt ├── vercel.json ├── .gitignore ├── README.md └── LICENSE /api/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | Flask==3.0.3 2 | requests==2.31.0 3 | mistune==3.1.2 -------------------------------------------------------------------------------- /vercel.json: -------------------------------------------------------------------------------- 1 | { 2 | "rewrites": [ 3 | { "source": "/(.*)", "destination": "/api/index" } 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vercel 2 | *.log 3 | *.pyc 4 | __pycache__ 5 | 6 | # Environments 7 | .env 8 | .venv 9 | env/ 10 | venv/ 11 | ENV/ 12 | env.bak/ 13 | venv.bak/ 14 | .vercel 15 | -------------------------------------------------------------------------------- /api/config.py: -------------------------------------------------------------------------------- 1 | plugin_info = { 2 | "versions": { 3 | "223": { 4 | "since_version": "223", 5 | "until_version": "223.*" 6 | }, 7 | "233": { 8 | "since_version": "233", 9 | "until_version": "233.*" 10 | }, 11 | "241": { 12 | "since_version": "241", 13 | "until_version": "251.*" 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Auto-dev-idea-repository 2 | the Intellij IDEA Custom Plugin Repository 3 | 4 | 1. Go to `Settings` → `Plugins` → `Marketplace` → `Manage Plugin Repositories` 5 | 2. Add the following URL: 6 | ``` 7 | https://plugin.unitmesh.cc/updatePlugins.xml 8 | ``` 9 | 10 | ## Running Locally 11 | 12 | ```bash 13 | npm i -g vercel 14 | vercel dev 15 | ``` 16 | 17 | Your Flask application is now available at `http://localhost:3000`. 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 Unit Mesh - 开源 AI 研发提效解决方案 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /api/index.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, Response, request 2 | import requests 3 | import time 4 | import mistune 5 | import xml.etree.ElementTree as ET 6 | from xml.dom import minidom 7 | from xml.sax.saxutils import escape 8 | from api.config import plugin_info 9 | 10 | # 常量定义 11 | CACHE_TIMEOUT = 300 # 缓存超时时间(秒) 12 | GITHUB_API_URL = "https://api.github.com/repos/unit-mesh/auto-dev/releases/latest" 13 | 14 | # 缓存相关变量 15 | _cache = {} 16 | 17 | # XML模板定义 18 | UPDATES_XML_TEMPLATE = """ 19 | 20 | 21 | 22 | AutoDev 23 | UnitMesh 24 | Github | Issues. 25 |
26 |
27 | 🧙‍AutoDev: The AI-powered coding wizard with multilingual support 🌐, auto code generation 🏗️, and a helpful bug-slaying 28 | assistant 🐞! Customizable prompts 🎨 and a magic Auto Testing feature 🧪 included! 🚀]]>
29 | {change_notes} 30 |
31 |
32 | """ 33 | 34 | app = Flask(__name__) 35 | 36 | def fetch_release_info() -> dict: 37 | """从GitHub获取最新发布信息,使用缓存机制避免频繁请求""" 38 | cache_timestamp = _cache.get('release_info_timestamp', 0) 39 | if _cache and time.time() - cache_timestamp < CACHE_TIMEOUT: 40 | return _cache['release_info'] 41 | 42 | try: 43 | response = requests.get(GITHUB_API_URL) 44 | if response.status_code != 200: 45 | if _cache.get('release_info'): 46 | return _cache['release_info'] 47 | raise Exception(f"Failed to fetch GitHub release: {response.status_code}") 48 | 49 | data = response.json() 50 | _cache['release_info'] = data 51 | _cache['release_info_timestamp'] = time.time() 52 | return data 53 | except Exception as e: 54 | if _cache.get('release_info'): 55 | return _cache['release_info'] 56 | raise e 57 | 58 | def is_version_in_range(version: str, since_version: str, until_version: str) -> bool: 59 | """检查版本是否在指定范围内 60 | 61 | :param version: 要检查的版本号 62 | :param since_version: 最低支持版本 63 | :param until_version: 最高支持版本(支持通配符,如'233.*') 64 | :return: 是否在范围内 65 | """ 66 | if version is None: 67 | return False 68 | 69 | # 移除版本号中的前缀(如'IU-') 70 | version = version.split('-')[-1] 71 | 72 | # 如果until_version包含通配符,只比较主版本号 73 | if until_version.endswith('.*'): 74 | until_version = until_version[:-2] 75 | version = version[:len(until_version)] 76 | since_version = since_version[:len(until_version)] 77 | 78 | return since_version <= version <= until_version 79 | 80 | def fetch_latest_release(idea_version: str, build_version: str = None) -> dict: 81 | """获取指定IDE版本的最新插件发布信息 82 | 83 | :param idea_version: IDEA版本号(如'241') 84 | :param build_version: IDEA构建版本号(如'IU-243.26053.27') 85 | """ 86 | # 如果指定了idea_version,直接使用idea_version 87 | matched_version = idea_version if idea_version else None 88 | # 如果没有提供idea_version, 则使用build_version进行匹配 89 | if not matched_version and build_version: 90 | for version, info in plugin_info["versions"].items(): 91 | if is_version_in_range(build_version, info["since_version"], info["until_version"]): 92 | matched_version = version 93 | break 94 | 95 | if not matched_version: 96 | raise ValueError(f"Unsupported IDE version: {build_version}") 97 | 98 | data = fetch_release_info() 99 | version_info = plugin_info["versions"][matched_version] 100 | tag_name = data["tag_name"] 101 | version = tag_name.lstrip("v") 102 | 103 | # 查找对应版本的插件文件 104 | plugin_file = next( 105 | (asset["browser_download_url"] for asset in data["assets"] 106 | if f"autodev-jetbrains-{version}-{matched_version}.zip" in asset["name"]), 107 | None 108 | ) 109 | 110 | if not plugin_file: 111 | raise Exception(f"Plugin file not found for version {version} {matched_version}") 112 | 113 | change_notes = mistune.html(data.get("body", "")) 114 | 115 | return { 116 | "version": version, 117 | "since_version": version_info["since_version"], 118 | "until_version": version_info["until_version"], 119 | "download_url": plugin_file, 120 | "change_notes": escape(change_notes) 121 | } 122 | 123 | def generate_updates_xml(release_info: dict) -> str: 124 | """生成格式化的更新XML文件""" 125 | xml_content = UPDATES_XML_TEMPLATE.format(**release_info) 126 | dom = minidom.parseString(xml_content) 127 | return dom.toprettyxml(indent=" ") 128 | 129 | @app.route('/') 130 | def home(): 131 | """首页路由,显示支持的IDE版本列表""" 132 | versions = plugin_info["versions"].keys() 133 | version_links = "\n".join(f"
  • {version}
  • " for version in versions) 134 | return f""" 135 | Auto-Dev Plugin Repository Server 136 | 139 | """ 140 | 141 | @app.route('/about') 142 | def about(): 143 | """关于页面路由""" 144 | return 'Auto-Dev Plugin Repository Server' 145 | 146 | @app.route('//updatePlugins.xml') 147 | @app.route('/updatePlugins.xml') 148 | def update_plugins(idea_version=''): 149 | """ 150 | 生成插件更新XML文件的路由 151 | 152 | :param idea_version: 路径指定的IDEA版本 153 | """ 154 | build_version = request.args.get('build', None) 155 | try: 156 | release_info = fetch_latest_release(idea_version, build_version) 157 | xml_content = generate_updates_xml(release_info) 158 | return Response(xml_content, mimetype='application/xml') 159 | except ValueError as e: 160 | return str(e), 400 161 | except Exception as e: 162 | return str(e), 500 163 | --------------------------------------------------------------------------------