Skip to content
| Marketplace
Sign in
Visual Studio Code>Linters>API Migration AgentNew to Visual Studio Code? Get it now.
API Migration Agent

API Migration Agent

Glimora_X

|
1 install
| (0) | Free
检测废弃API并推荐新的替代方案,帮助开发者平滑迁移框架版本
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

API Migration Agent

一个 VS Code 插件,用于检测代码中的废弃 API 并推荐新的替代方案,帮助开发者平滑迁移框架版本。

功能特性

  • 🔍 实时检测 - 编辑时自动检测废弃 API 使用
  • 💡 Quick Fix - 一键修复,自动替换为新 API
  • 📝 悬停提示 - 鼠标悬停显示详细迁移指南
  • 📊 迁移报告 - 生成可视化的迁移报告
  • ⚙️ 可配置 - 支持自定义 API 变更规则
  • 🔄 热更新 - 配置文件修改后自动生效

安装

从 Marketplace 安装

在 VS Code 扩展市场搜索 "API Migration Agent" 并安装。

从 VSIX 安装

code --install-extension upgrade-biz-core-agent-0.0.1.vsix

使用方法

1. 配置 API 变更规则

在项目根目录创建 api-migration.json 文件:

{
  "frameworkName": "MyFramework",
  "fromVersion": "2.x",
  "toVersion": "3.0",
  "lastUpdated": "2025-12-03",
  "changes": [
    {
      "id": "http-request",
      "category": "network",
      "severity": "breaking",
      "old": {
        "api": "framework.request",
        "signature": "framework.request(url: string)",
        "example": "framework.request('/api/user')"
      },
      "new": {
        "api": "framework.http.request",
        "signature": "framework.http.request(url: string)",
        "example": "framework.http.request('/api/user')"
      },
      "migrationGuide": "在 3.0 中 network API 模块化,需要使用 http.request。",
      "autoFixable": true,
      "tags": ["network", "http"]
    }
  ]
}

2. 命令

打开命令面板 (Cmd+Shift+P / Ctrl+Shift+P):

命令 说明
API Migration: 扫描当前文件 扫描当前打开的文件
API Migration: 扫描整个工作区 扫描工作区所有文件
API Migration: 显示迁移报告 显示可视化迁移报告
API Migration: 重新加载配置 重新加载配置文件

3. 配置项

在 VS Code 设置中:

{
  "apiMigration.enabled": true,
  "apiMigration.severity": "warning"
}

配置文件格式

配置文件位置(按优先级)

  1. 工作区: api-migration.json 或 .api-migration.json
  2. VS Code 文件夹: .vscode/api-migration.json
  3. 用户设置: apiMigration.customConfig
  4. 内置默认配置

字段说明

字段 类型 必填 说明
frameworkName string ✅ 框架名称
fromVersion string ✅ 旧版本号
toVersion string ✅ 新版本号
lastUpdated string ❌ 最后更新日期
changes array ✅ API 变更列表

API 变更字段

字段 类型 必填 说明
id string ✅ 唯一标识符
category enum ✅ 分类: network/utils/ui/storage/auth/lifecycle/other
severity enum ✅ 严重程度: breaking/deprecated/warning/info
old object ✅ 旧 API 定义
new object ✅ 新 API 定义
migrationGuide string ✅ 迁移说明
autoFixable boolean ❌ 是否支持自动修复
tags string[] ❌ 标签,便于搜索
deprecatedSince string ❌ 废弃起始版本
removedIn string ❌ 移除版本

发布插件

1. 准备工作

# 安装 vsce 工具
npm install -g @vscode/vsce

# 创建 Azure DevOps 账号并获取 Personal Access Token
# https://dev.azure.com/

2. 创建发布者

vsce create-publisher your-publisher-name

3. 打包

# 编译
npm run compile

# 打包成 .vsix 文件
vsce package

4. 发布

# 登录
vsce login your-publisher-name

# 发布到 Marketplace
vsce publish

# 或指定版本
vsce publish minor  # 0.0.1 -> 0.1.0
vsce publish patch  # 0.0.1 -> 0.0.2

5. 发布前检查清单

  • [ ] 更新 package.json 中的 publisher 字段
  • [ ] 添加 icon 图标 (128x128 PNG)
  • [ ] 更新 repository 地址
  • [ ] 编写完整的 README
  • [ ] 添加 CHANGELOG.md
  • [ ] 添加 LICENSE 文件

开发

# 安装依赖
npm install

# 编译
npm run compile

# 监听模式
npm run watch

# 调试:按 F5 启动扩展开发宿主

License

MIT

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft