npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

z-mcp-vb-migration

v1.0.7

Published

Android ViewBinding 迁移 MCP 服务,将 kotlinx.android.synthetic 自动迁移为 ViewBinding

Readme

z-mcp-vb-migration

基于 @modelcontextprotocol/sdk 实现的 MCP stdio 服务,用于将 Android 项目中的 kotlinx.android.synthetic 迁移到 ViewBinding。

可在 Cursor 等 AI 编程客户端中通过 MCP 工具批量扫描并迁移 Kotlin 文件。

使用

在项目根目录创建 .cursor/mcp.json

{
  "mcpServers": {
    "z-mcp-vb-migration": {
      "command": "npx",
      "args": ["-y", "z-mcp-vb-migration", "--stdio", "--android-module=app"]
    }
  }
}

--android-module 为 Android 模块名,相对 Cursor 工作目录(项目根)解析,如 app 对应 {项目根}/app

提供的工具

| 工具名 | 说明 | | ------ | ---- | | vb_list_kt_files | 扫描项目中仍使用 synthetic 的 Kotlin 文件,返回待迁移列表 | | vb_migrate_kt_file | 迁移指定的 Kotlin 文件到 ViewBinding(自动处理第一个主布局) |

使用示例

列出项目中所有需要迁移 ViewBinding 的 Kotlin 文件

迁移 xxx/Activity.kt 到 ViewBinding

先扫描待迁移文件,再逐个迁移

AI 迁移工作流(推荐)

让 AI 批量迁移、少跑 Gradle,可显著节省时间:

  1. 先扫描vb_list_kt_files 获取待迁移列表
  2. 批量迁移:连续调用 vb_migrate_kt_file 迁移多个文件(如 5~10 个一批)
  3. 不要每迁一个就打包:禁止 assembleDebug / installDebug / 打 APK
  4. 批次结束后再编译一次
    ./gradlew :app:compileDebugKotlin
    只校验 Kotlin 编译,比全量打包快很多
  5. 仅在用户要求或编译报错时再跑完整构建

在 Cursor 中加规则(可选)

在 Android 项目 .cursor/rules/vb-migration.mdc 中写入:

---
description: ViewBinding 迁移时不要频繁打包
globs: **/*.kt
---

使用 z-mcp-vb-migration 迁移 ViewBinding 时:
- 单文件迁移后不要运行 assembleDebug / installDebug
- 批量迁移完成后执行 compileDebugKotlin 验证即可
- 用户未明确要求时不要启动 Gradle 全量构建

迁移说明

  • 自动替换控件 ID(tv_titlebinding.tvTitle),并补全无 android:id<include>
  • 自动修改基类与泛型:
    • BaseActivityBaseActivityVB<XxxBinding>
    • BaseMvpActivity<P>BaseMvpActivityVB<P, XxxBinding>
    • BaseFragment / BaseMvpFragment 同理
  • 自动删除 Activity 的 getContentView(),添加 getViewBinding()
  • Fragment 保留 getLayoutId()(与 getViewBinding() 并存,适配项目基类)
  • 自动将 *Adapter.data = 转为 setNewInstance(...)
  • 成员变量与视图 id 同名时跳过替换,并在 warnings 中提示
  • 迁移结果包含 warnings 字段(合成引用遗漏、非法 this::binding.xxx 等)
  • 仅自动迁移第一个主布局(通过 getContentView / getLayoutId / setContentView 或文件名推断)
  • 多主布局时其余主布局需手动处理;代码 inflate 的子布局(如 item 布局)不会自动迁移