mcpField
E
enhance-cross-file

enhance-cross-file

github.com/agent-shAgent 工作流1.0k85 次安装2 天前更新
代码仓库

关于 enhance-cross-file

enhance-cross-file 分析代码库中 Agent、技能与工作流之间的语义一致性,并报告跨文件问题,供人工审查。检查项包括未声明的工具使用、缺失的 Agent 引用、重复指令和冲突规则。

主要功能

  1. 01检测未声明的工具使用
  2. 02查找缺失的 Agent 引用
  3. 03识别重复指令
  4. 04标记相互矛盾的规则
  5. 05报告孤立的 Agent 与技能

适用场景

  1. 01审计 Agent 与技能配置
  2. 02变更前检查工作流引用
  3. 03查找跨文件的不一致指令

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/agent-sh/agentsys --skill enhance-cross-file

安装后在 Claude Code 中输入/enhance-cross-file确认已加载。

详细介绍

enhance-cross-file

分析智能体、技能和工作流之间的跨文件语义一致性。

解析参数

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

用途

检测跨多个文件的问题——单文件分析无法发现的问题:

  • 在提示词正文中使用、但未在 frontmatter 中声明的工具
  • 不存在的智能体引用
  • 跨文件的重复指令(增加维护负担)
  • 相互矛盾的规则(ALWAYS 与 NEVER 冲突)
  • 未被任何工作流引用的孤立智能体
  • 技能工具不匹配(allowed-tools 与实际使用情况不符)

工作流

  1. 运行分析器 - 执行 JavaScript 分析器以获取发现结果:

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

    指定路径:a.analyze('./plugins/enhance')

  2. 解析结果 - 分析器返回包含 summary 和 findings 的 JSON

  3. 报告 - 按类别分组返回发现结果

JavaScript 分析器(lib/enhance/cross-file-analyzer.js)实现了所有跨文件检测功能。以下模式为参考文档。

检测模式

1. 工具一致性(中等确定性)

tool_not_in_allowed_list:在提示词正文中使用、但未列入 frontmatter 的 tools: 列表中的工具

# Frontmatter declares:
tools: Read, Grep

# But body uses:
Use Write({ file_path: "/out" })  # <- Not declared!

skill_tool_mismatch:技能的 allowed-tools 与技能正文中的实际工具使用情况不符

2. 工作流一致性(中等确定性)

missing_workflow_agent:subagent_type: "plugin:agent-name" 引用了不存在的智能体

orphaned_prompt:智能体文件存在,但没有工作流引用它(可能是入口点——请手动检查)

incomplete_phase_transition:工作流阶段提到了“Phase N”,但没有对应章节

3. 指令一致性(中等确定性)

duplicate_instructions:相同的 MUST/NEVER 指令出现在 3 个或更多文件中(提取到共享位置)

contradictory_rules:一个文件写着“ALWAYS X”,而另一个文件写着“NEVER X”

输出格式

## 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 |

约束

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

模式统计

类别模式数可自动修复
工具一致性20
工作流30
一致性30
总计80

评论

支持 Markdown