内容
<p align="center">
<img src="doc/ariadne-banner.svg" alt="ariadne banner" width="100%">
</p>
<p align="center">
<h1 align="center">ariadne</h1>
<p align="center">
<strong>用于影响测试选择的MCP服务器</strong>
</p>
<p align="center">
<a href="LICENSE"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=flat-square" alt="License"></a>
<a href="https://kotlinlang.org"><img src="https://img.shields.io/badge/Kotlin-2.3.0-7F52FF.svg?style=flat-square&logo=kotlin&logoColor=white" alt="Kotlin"></a>
</p>
</p>
<br>
**ariadne** 是一个MCP(模型上下文协议)服务器,为AI代理提供识别受影响测试的能力。由 [sazanami](https://github.com/MikhailHal/sazanami) 驱动,它分析代码更改并返回仅需运行的测试。
## 功能
- **MCP集成** — 与Claude Code、Claude Desktop和其他MCP兼容的客户端一起工作
- **自动Git差异** — 无需手动传递差异;ariadne在内部运行 `git diff`
- **由sazanami驱动** — 使用Kotlin分析API进行准确的静态分析
## 安装
### 从源代码构建
```bash
git clone --recursive https://github.com/anthropics/ariadne.git
cd ariadne
./gradlew installDist
```
### 配置MCP客户端
将以下内容添加到您的MCP客户端配置中(例如,Claude Desktop):
```json
{
"mcpServers": {
"ariadne": {
"command": "/path/to/ariadne/build/install/ariadne/bin/ariadne"
}
}
}
```
## 使用
配置完成后,AI代理可以使用 `get_affected_tests` 工具:
### 工具:`get_affected_tests`
**参数:**
- `project_path`(必填)— Kotlin项目的路径
- `base_branch`(可选)— 要比较的分支(默认:`origin/main`)
**返回:**
- 受影响的测试FQNs(完全限定名称)列表
### 示例
代理请求:
```json
{
"name": "get_affected_tests",
"arguments": {
"project_path": "/path/to/your/kotlin/project"
}
}
```
响应:
```
com.example.UserServiceTest.testCreateUser
com.example.UserRepositoryTest.testSave
```
## 工作原理
```
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ MCP客户端 │ ──▶ │ ariadne │ ──▶ │ sazanami │
│ (代理) │ │ (MCP服务器)│ │ (分析) │
└─────────────┘ └─────────────┘ └─────────────┘
│
▼
┌─────────────┐
│ git差异 │
└─────────────┘
```
1. **代理调用工具** — 将项目路径传递给ariadne
2. **运行git差异** — ariadne执行 `git diff --unified=0` 对比基准分支
3. **与sazanami分析** — 构建调用图并查找受影响的测试
4. **返回结果** — 测试FQNs列表返回给代理
## 要求
- **JDK 21** 或更高版本
- **Git** — 用于差异检测
## 限制(v0.1)
- 模块发现基于约定:它解析 `settings.gradle(.kts)` 包含、
标准 `src/{main,test}/{kotlin,java}` 布局和 `project(":x")` /
从构建文件中获取类型安全访问器依赖项。动态包含、自定义
源集(Android变体、KMP)和被约定插件注入的依赖项
未被检测 — 参见 [#1](https://github.com/MikhailHal/ariadne/issues/1)
- 每次请求都重建完整图(目前无缓存)
## 许可证
```
Copyright 2025 ariadne contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
```
参见 [LICENSE](LICENSE) 以获取完整文本。