compat-finder
v2.1.0
Published
Find incompatible targets through guided compatibility checks.
Maintainers
Readme
兼容性问题排查器
English | 简体中文
compat-finder 是一个用于排查多个目标之间兼容性问题的库和命令行工具。
它帮助你用更少的测试轮次找出一个或多个不兼容目标。
为什么用 compat-finder
- 零运行时依赖:安装更轻量,也能降低供应链风险。
- 高效排查算法:默认算法采用二分法结合分治法的策略,通常只需较少测试轮次即可得出结果。
- 不只简单二分:排查结果目标可以是一个或多个。
- 多种接入形式:提供引导式 CLI、开箱即用的会话 API,以及适合自定义流程的高级 API。
- 适合多种运行环境:发布产物为 ESM,可用于浏览器和其他兼容 ESM 的运行时。
- 本地化 CLI:支持英文和简体中文。
文档
完整文档见 howiehz.top/misc/compat-finder。
在线体验
无需安装,打开即可使用:兼容性问题排查器
安装
npm install compat-finder然后即可导入使用:
import { createCompatibilitySession } from "compat-finder";
const session = createCompatibilitySession(["A", "B"]);如果你只是想快速试用 CLI,也可以不安装直接运行:
npx compat-finder --help用法
库使用示例:
import { createCompatibilitySession } from "compat-finder";
const session = createCompatibilitySession(["A", "B", "C", "D"]);
let step = session.current();
while (step.status === "testing") {
const result = askUser(step.targets);
if (result === "undo") {
step = session.undo();
continue;
}
step = session.answer(result === "issue");
}
console.log("最终结果:", step.targets);
function askUser(targets: readonly string[]): "issue" | "pass" | "undo" {
console.log("当前需要测试:", targets);
// 浏览器里可以来自 prompt()、按钮或表单。
// Node.js 里可以来自 readline、测试脚本或你自己的 CLI。
return "issue"; // 复现返回 "issue",未复现返回 "pass",撤销返回 "undo"。
}命令行示例:
启动一轮引导式排查:
npx compat-finder interactive --count 4根据已有回答计算下一步要测试的目标:
npx compat-finder next -c 3 -n "Alpha,Beta,Gamma" -a "y,n"预期会输出如下 JSON:
{
"status": "testing",
"targetCount": 3,
"targets": ["Beta"]
}如果你需要完整命令和 API 说明,可以继续阅读完整文档。
与 AI 协作
如果你想让 AI 智能体帮你继续推进排查流程,或把 compat-finder 集成进自己的项目,可以安装 compat-finder 智能体技能:
npx skills add HowieHz/howiehz-misc --skill compat-finder更多提示词和说明,见与 AI 协作。
相关项目
由 HowieHz/plugin-compatibility-checking-tool 重构而来。
许可证
本项目基于 MIT License 发布。
