用途:indexion explore 用于跨目录分析文件相似度,帮助查找重复文件、发现复制粘贴代码,或在重构前了解代码重叠情况。适合在用户询问“哪些文件相似”“哪些文件与 X 相关”时使用,也可作为详细重构分析前的第一遍快速扫描,之后再配合 indexion plan refactor 获取可操作细节。
主要能力:支持多种相似度策略——tfidf(默认,基于 TF-IDF 词元相似度,速度快)、hybrid(根据数据集大小自动选择 TF-IDF 或 APTED,自适应)、ncd(归一化压缩距离,快)、apted(全路径树编辑距离,函数级,慢)、tsed(树结构编辑距离,函数级,慢)。输出格式包括 matrix(完整相似度矩阵,默认)、list(阈值以上排序文件对,最适合查找重复)、cluster(相似文件分组)、json(便于后续处理)。
必要用法:基本命令为 indexion explore <path>。列表格式加阈值:indexion explore --format=list --threshold=0.7。聚类:indexion explore --format=cluster --threshold=0.6。JSON:indexion explore --format=json --threshold=0.5。按扩展名过滤:indexion explore --ext=.mbt --ext=.ts。包含/排除模式:indexion explore --include='.ts' --exclude='_test.ts' src/。函数级策略:indexion explore --strategy=apted --format=list 或 --strategy=tsed --format=list。混合策略:indexion explore --strategy=hybrid --format=list。
适用场景与工作流:先运行 indexion explore --format=list --threshold=0.7 <path> 快速扫描,若存在高相似度文件对,再运行 indexion plan refactor --threshold=0.9 <path> 查看细节,修复重复后重新运行两者验证。
限制与注意:moon.pkg 等配置文件会抬高相似度分数,建议用 --exclude='moon.pkg' 排除;CLI 文件间 96% 以上相似通常意味着工具函数重复,85%–95% 多为结构性相似(不总是可操作);types.mbt 文件显示 100% 相似属正常,类型定义文件共享公开结构体与 getter 模式会抬高 TF-IDF 分数。并未提供收费、价格或平台信息。