SuperAPI AI 工具集

enhance-cross-file

编程与开发

查看项目

更新于 10-15 08:44

技能介绍

用途

enhance-cross-file 用于分析智能体(agents)、技能(skills)和工作流(workflows)之间的跨文件语义一致性。它专注于检测那些跨越多个文件、单文件分析无法发现的问题。

主要能力

该工具能够检测以下类别的跨文件问题:

工具一致性

  • tool_not_in_allowed_list:提示正文中使用了某个工具,但该工具未在 frontmatter 的 tools 列表中声明。例如 frontmatter 声明 tools: Read, Grep,但正文中使用了 Write({ file_path: "/out" })。
  • skill_tool_mismatch:技能的 allowed-tools 与技能正文中实际使用的工具不匹配。

工作流一致性

  • missing_workflow_agent:subagent_type: "plugin:agent-name" 引用了不存在的智能体。
  • orphaned_prompt:智能体文件存在,但没有任何工作流引用它(可能是入口点,需手动检查)。
  • incomplete_phase_transition:工作流阶段提到“Phase N”,但没有对应的章节。

指令一致性

  • duplicate_instructions:相同的 MUST/NEVER 指令出现在 3 个及以上文件中(建议提取到共享位置)。
  • contradictory_rules:一个文件说“ALWAYS X”,另一个文件说“NEVER X”。

使用方式

工具通过命令行运行 JavaScript 分析器来获取检测结果。

解析参数:

const args = '$ARGUMENTS'.split(' ').filter(Boolean);
const targetPath = args.find(a => !a.startsWith('--')) || '.';

运行分析器:

node -e "const a = require('./lib/enhance/cross-file-analyzer.js'); console.log(JSON.stringify(a.analyze('.'), null, 2));"

针对特定路径:

a.analyze('./plugins/enhance')

分析器返回包含 summary 和 findings 的 JSON,随后按类别分组报告结果。

输出格式

## Cross-File Analysis

**Files Analyzed**: {agents} agents, {skills} skills, {commands} commands

### Tool Consistency ({n})
| Agent | Issue | Fix |
|-------|-------|-----|
| exploration-agent | Uses Write but not in tools list | Add Write to frontmatter |

### Workflow Issues ({n})
| Source | Issue | Fix |
|--------|-------|-----|
| workflow.md | References nonexistent agent | Check spelling or create agent |

### Instruction Consistency ({n})
| Instruction | Files | Fix |
|-------------|-------|-----|
| "NEVER push --force" | 4 files | Extract to CLAUDE.md |

适用场景

适用于维护包含多个智能体、技能和工作流定义文件的项目,帮助发现配置之间的不一致、重复和矛盾,降低维护负担。

限制

  • 所有检测模式均为中等确定性(MEDIUM certainty),需要结合上下文判断。
  • 不提供自动修复(No auto-fix),因为跨文件修改需要人工审查。
  • 跳过 <bad-example>、<bad_example>、<badexample> 标签内的内容。
  • 跳过信息字符串中包含“bad”的代码块内的内容。
  • 入口点智能体(orchestrator、validator、discoverer)不算作孤立。

模式统计

类别 模式数 可自动修复
工具一致性 2 0
工作流 3 0
一致性 3 0
合计 8 0