autocode-mcp 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- autocode_mcp-0.1.0/.github/workflows/ci.yml +70 -0
- autocode_mcp-0.1.0/.gitignore +59 -0
- autocode_mcp-0.1.0/CHANGELOG.md +60 -0
- autocode_mcp-0.1.0/CLAUDE.md +74 -0
- autocode_mcp-0.1.0/CONTRIBUTING.md +25 -0
- autocode_mcp-0.1.0/LICENSE +21 -0
- autocode_mcp-0.1.0/Makefile +49 -0
- autocode_mcp-0.1.0/PKG-INFO +558 -0
- autocode_mcp-0.1.0/README.md +542 -0
- autocode_mcp-0.1.0/README_CN.md +542 -0
- autocode_mcp-0.1.0/TROUBLESHOOTING.md +206 -0
- autocode_mcp-0.1.0/pyproject.toml +64 -0
- autocode_mcp-0.1.0/src/autocode_mcp/__init__.py +17 -0
- autocode_mcp-0.1.0/src/autocode_mcp/prompts/__init__.py +260 -0
- autocode_mcp-0.1.0/src/autocode_mcp/resources/__init__.py +59 -0
- autocode_mcp-0.1.0/src/autocode_mcp/server.py +181 -0
- autocode_mcp-0.1.0/src/autocode_mcp/tools/__init__.py +31 -0
- autocode_mcp-0.1.0/src/autocode_mcp/tools/base.py +90 -0
- autocode_mcp-0.1.0/src/autocode_mcp/tools/checker.py +173 -0
- autocode_mcp-0.1.0/src/autocode_mcp/tools/file_ops.py +155 -0
- autocode_mcp-0.1.0/src/autocode_mcp/tools/generator.py +254 -0
- autocode_mcp-0.1.0/src/autocode_mcp/tools/interactor.py +317 -0
- autocode_mcp-0.1.0/src/autocode_mcp/tools/problem.py +450 -0
- autocode_mcp-0.1.0/src/autocode_mcp/tools/solution.py +184 -0
- autocode_mcp-0.1.0/src/autocode_mcp/tools/stress_test.py +240 -0
- autocode_mcp-0.1.0/src/autocode_mcp/tools/validator.py +204 -0
- autocode_mcp-0.1.0/src/autocode_mcp/utils/__init__.py +29 -0
- autocode_mcp-0.1.0/src/autocode_mcp/utils/compiler.py +326 -0
- autocode_mcp-0.1.0/src/autocode_mcp/utils/platform.py +42 -0
- autocode_mcp-0.1.0/templates/checker_template.cpp +24 -0
- autocode_mcp-0.1.0/templates/generator_template.cpp +51 -0
- autocode_mcp-0.1.0/templates/interactor_template.cpp +28 -0
- autocode_mcp-0.1.0/templates/testlib.h +6252 -0
- autocode_mcp-0.1.0/templates/validator_template.cpp +23 -0
- autocode_mcp-0.1.0/tests/test_compiler.py +328 -0
- autocode_mcp-0.1.0/tests/test_integration/__init__.py +1 -0
- autocode_mcp-0.1.0/tests/test_integration/test_problem_workflow.py +121 -0
- autocode_mcp-0.1.0/tests/test_integration/test_stress_test.py +66 -0
- autocode_mcp-0.1.0/tests/test_prompts.py +59 -0
- autocode_mcp-0.1.0/tests/test_resources.py +58 -0
- autocode_mcp-0.1.0/tests/test_server.py +110 -0
- autocode_mcp-0.1.0/tests/test_tools/__init__.py +3 -0
- autocode_mcp-0.1.0/tests/test_tools/test_checker.py +92 -0
- autocode_mcp-0.1.0/tests/test_tools/test_file_ops.py +96 -0
- autocode_mcp-0.1.0/tests/test_tools/test_generator.py +164 -0
- autocode_mcp-0.1.0/tests/test_tools/test_interactor.py +142 -0
- autocode_mcp-0.1.0/tests/test_tools/test_problem.py +199 -0
- autocode_mcp-0.1.0/tests/test_tools/test_solution.py +163 -0
- autocode_mcp-0.1.0/tests/test_tools/test_stress_test.py +227 -0
- autocode_mcp-0.1.0/tests/test_tools/test_validator.py +113 -0
- autocode_mcp-0.1.0/uv.lock +729 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [master]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [master]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
lint:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
- uses: actions/setup-python@v5
|
|
15
|
+
with:
|
|
16
|
+
python-version: "3.14"
|
|
17
|
+
- uses: astral-sh/setup-uv@v4
|
|
18
|
+
with:
|
|
19
|
+
enable-cache: true
|
|
20
|
+
- run: uv sync --all-extras
|
|
21
|
+
- run: uv run ruff check .
|
|
22
|
+
|
|
23
|
+
typecheck:
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@v4
|
|
27
|
+
- uses: actions/setup-python@v5
|
|
28
|
+
with:
|
|
29
|
+
python-version: "3.14"
|
|
30
|
+
- uses: astral-sh/setup-uv@v4
|
|
31
|
+
with:
|
|
32
|
+
enable-cache: true
|
|
33
|
+
- run: uv sync --all-extras
|
|
34
|
+
- run: uv run mypy src/
|
|
35
|
+
|
|
36
|
+
test-unit:
|
|
37
|
+
runs-on: ${{ matrix.os }}
|
|
38
|
+
strategy:
|
|
39
|
+
fail-fast: false
|
|
40
|
+
matrix:
|
|
41
|
+
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
42
|
+
python-version: ["3.14"]
|
|
43
|
+
steps:
|
|
44
|
+
- uses: actions/checkout@v4
|
|
45
|
+
- uses: actions/setup-python@v5
|
|
46
|
+
with:
|
|
47
|
+
python-version: ${{ matrix.python-version }}
|
|
48
|
+
- uses: astral-sh/setup-uv@v4
|
|
49
|
+
with:
|
|
50
|
+
enable-cache: true
|
|
51
|
+
- run: uv sync --all-extras
|
|
52
|
+
- run: uv run pytest tests/ -v -m "not integration" --cov --cov-report=xml
|
|
53
|
+
- uses: codecov/codecov-action@v4
|
|
54
|
+
if: matrix.os == 'ubuntu-latest'
|
|
55
|
+
with:
|
|
56
|
+
files: coverage.xml
|
|
57
|
+
flags: unit-tests
|
|
58
|
+
|
|
59
|
+
test-integration:
|
|
60
|
+
runs-on: ubuntu-latest
|
|
61
|
+
steps:
|
|
62
|
+
- uses: actions/checkout@v4
|
|
63
|
+
- uses: actions/setup-python@v5
|
|
64
|
+
with:
|
|
65
|
+
python-version: "3.14"
|
|
66
|
+
- uses: astral-sh/setup-uv@v4
|
|
67
|
+
with:
|
|
68
|
+
enable-cache: true
|
|
69
|
+
- run: uv sync --all-extras
|
|
70
|
+
- run: uv run pytest tests/ -v -m "integration"
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
build/
|
|
8
|
+
develop-eggs/
|
|
9
|
+
dist/
|
|
10
|
+
downloads/
|
|
11
|
+
eggs/
|
|
12
|
+
.eggs/
|
|
13
|
+
lib/
|
|
14
|
+
lib64/
|
|
15
|
+
parts/
|
|
16
|
+
sdist/
|
|
17
|
+
var/
|
|
18
|
+
wheels/
|
|
19
|
+
*.egg-info/
|
|
20
|
+
.installed.cfg
|
|
21
|
+
*.egg
|
|
22
|
+
|
|
23
|
+
# Virtual environments
|
|
24
|
+
.venv/
|
|
25
|
+
venv/
|
|
26
|
+
ENV/
|
|
27
|
+
env/
|
|
28
|
+
|
|
29
|
+
# Testing
|
|
30
|
+
.pytest_cache/
|
|
31
|
+
.coverage
|
|
32
|
+
htmlcov/
|
|
33
|
+
coverage.xml
|
|
34
|
+
*.cover
|
|
35
|
+
|
|
36
|
+
# Type checking
|
|
37
|
+
.mypy_cache/
|
|
38
|
+
.dmypy.json
|
|
39
|
+
dmypy.json
|
|
40
|
+
|
|
41
|
+
# Linting
|
|
42
|
+
.ruff_cache/
|
|
43
|
+
|
|
44
|
+
# IDE
|
|
45
|
+
.idea/
|
|
46
|
+
.vscode/
|
|
47
|
+
*.swp
|
|
48
|
+
*.swo
|
|
49
|
+
*~
|
|
50
|
+
|
|
51
|
+
# Project specific
|
|
52
|
+
*.exe
|
|
53
|
+
*.out
|
|
54
|
+
*.o
|
|
55
|
+
.tmp/
|
|
56
|
+
|
|
57
|
+
# OS
|
|
58
|
+
.DS_Store
|
|
59
|
+
Thumbs.db
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.2.0] - 2026-03-31
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
- 完成 Interactor 完整验证逻辑,实现真实的交互测试
|
|
13
|
+
- 添加 compiler.py 单元测试(14 个测试用例)
|
|
14
|
+
- 创建平台工具模块 `platform.py`,消除 `exe_ext` 判断的代码重复
|
|
15
|
+
- 拆分 `StressTestRunTool.execute` 函数,提高代码可读性
|
|
16
|
+
|
|
17
|
+
### Improvements
|
|
18
|
+
|
|
19
|
+
- 测试代码覆盖从约 50-60% 提升至 80%+
|
|
20
|
+
- 消除 10 处 `exe_ext` 重复代码
|
|
21
|
+
- 通过工具函数封装提高可维护性
|
|
22
|
+
|
|
23
|
+
### Code Quality
|
|
24
|
+
|
|
25
|
+
- 将平台相关逻辑集中到 `platform.py` 模块
|
|
26
|
+
- 重构过长函数,拆分为更小的辅助方法
|
|
27
|
+
- 更新类型注解和导入声明
|
|
28
|
+
|
|
29
|
+
### Breaking Changes
|
|
30
|
+
|
|
31
|
+
- 无
|
|
32
|
+
|
|
33
|
+
## [0.1.0] - 2025-03-30
|
|
34
|
+
|
|
35
|
+
### Features
|
|
36
|
+
|
|
37
|
+
- 初始化 AutoCode MCP Server 基础架构
|
|
38
|
+
- 实现 14 个原子工具:
|
|
39
|
+
- File 工具组:`file_read`, `file_save`
|
|
40
|
+
- Solution 工具组:`solution_build`, `solution_run`
|
|
41
|
+
- Stress Test 工具组:`stress_test_run`
|
|
42
|
+
- Problem 工具组:`problem_create`, `problem_generate_tests`, `problem_pack_polygon`
|
|
43
|
+
- Validator 工具组:`validator_build`, `validator_select`
|
|
44
|
+
- Generator 工具组:`generator_build`, `generator_run`
|
|
45
|
+
- Checker 工具组:`checker_build`
|
|
46
|
+
- Interactor 工具组:`interactor_build`
|
|
47
|
+
- 添加 testlib.h 和 C++ 代码模板
|
|
48
|
+
- 实现 MCP Resources 和 Prompts
|
|
49
|
+
- 添加 51 个测试用例
|
|
50
|
+
|
|
51
|
+
### Design Rationale
|
|
52
|
+
|
|
53
|
+
- **纯工具模式**:Server 不调用任何 LLM,由 Client 提供智能编排
|
|
54
|
+
- **无状态设计**:每次调用独立,状态由 `problem_dir` 参数管理
|
|
55
|
+
- **统一返回格式**:`{success, error, data}`
|
|
56
|
+
|
|
57
|
+
### Notes & Caveats
|
|
58
|
+
|
|
59
|
+
- Windows 平台不支持内存限制(ulimit)
|
|
60
|
+
- 需要 g++ 编译器支持 C++2c 标准
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
此文件为 Claude Code (claude.ai/code) 在此代码仓库中工作时提供指导。
|
|
4
|
+
|
|
5
|
+
## 项目概述
|
|
6
|
+
|
|
7
|
+
AutoCode MCP Server 是基于论文《AutoCode: LLMs as Problem Setters for Competitive Programming》实现的竞赛编程出题辅助工具,提供 Validator-Generator-Checker 框架。
|
|
8
|
+
|
|
9
|
+
## 开发命令
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# 安装依赖
|
|
13
|
+
uv sync
|
|
14
|
+
|
|
15
|
+
# 运行测试
|
|
16
|
+
uv run pytest tests/ -v
|
|
17
|
+
|
|
18
|
+
# 代码检查
|
|
19
|
+
uv run ruff check .
|
|
20
|
+
|
|
21
|
+
# 类型检查
|
|
22
|
+
uv run mypy src/
|
|
23
|
+
|
|
24
|
+
# 运行 MCP Server
|
|
25
|
+
uv run autocode-mcp
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## 项目结构
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
AutoCode/
|
|
32
|
+
├── src/autocode_mcp/ # 源代码
|
|
33
|
+
│ ├── tools/ # MCP 工具实现
|
|
34
|
+
│ ├── resources/ # 模板资源
|
|
35
|
+
│ ├── prompts/ # 工作流提示词
|
|
36
|
+
│ └── utils/ # 工具函数
|
|
37
|
+
├── tests/ # 测试用例
|
|
38
|
+
├── templates/ # C++ 模板文件 (testlib.h 等)
|
|
39
|
+
└── pyproject.toml # 项目配置
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## 工具列表
|
|
43
|
+
|
|
44
|
+
| 工具 | 描述 |
|
|
45
|
+
|------|------|
|
|
46
|
+
| FileSaveTool | 保存文件 |
|
|
47
|
+
| FileReadTool | 读取文件 |
|
|
48
|
+
| FileListTool | 列出文件 |
|
|
49
|
+
| SolutionBuildTool | 构建解法 |
|
|
50
|
+
| SolutionTestTool | 测试解法 |
|
|
51
|
+
| StressTestTool | 压力测试 |
|
|
52
|
+
| ProblemInitTool | 初始化题目 |
|
|
53
|
+
| ProblemGenerateTestsTool | 生成测试数据 |
|
|
54
|
+
| ValidatorBuildTool | 构建校验器 |
|
|
55
|
+
| ValidatorSelectTool | 选择最佳校验器 |
|
|
56
|
+
| GeneratorBuildTool | 构建生成器 |
|
|
57
|
+
| GeneratorRunTool | 运行生成器 |
|
|
58
|
+
| CheckerBuildTool | 构建检查器 |
|
|
59
|
+
| InteractorBuildTool | 构建交互器 |
|
|
60
|
+
|
|
61
|
+
## 出题工作流程
|
|
62
|
+
|
|
63
|
+
1. 初始化题目目录 (`ProblemInitTool`)
|
|
64
|
+
2. 实现解法 (`SolutionBuildTool`)
|
|
65
|
+
3. 构建校验器 (`ValidatorBuildTool`)
|
|
66
|
+
4. 构建生成器 (`GeneratorBuildTool`)
|
|
67
|
+
5. 运行压力测试 (`StressTestTool`)
|
|
68
|
+
6. 生成测试数据 (`ProblemGenerateTestsTool`)
|
|
69
|
+
|
|
70
|
+
## 关键约束
|
|
71
|
+
|
|
72
|
+
- 包管理强制使用 `uv`(绝对禁用 pip/poetry/conda)
|
|
73
|
+
- 运行时强制使用 `uv run`
|
|
74
|
+
- C++ 标准使用 C++2c
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# 贡献指南 (Contributing to AutoCode)
|
|
2
|
+
|
|
3
|
+
由于 AutoCode 是一个旨在产出自动化高质量竞赛题目的辅助工具和 SOP 集合,我们非常珍惜所有形式的建议和改进。
|
|
4
|
+
|
|
5
|
+
## 提交 Issue
|
|
6
|
+
|
|
7
|
+
如果您发现了对拍脚本的 Bug、需要改进 SOP(Agent Prompt),请向我们**提交 Issue**,描述清楚:
|
|
8
|
+
|
|
9
|
+
1. 您所使用的环境(OS 及其版本、Python 版本等)。
|
|
10
|
+
2. 出现的具体问题(带上完整的报错日志)。
|
|
11
|
+
3. 您期望看到的结果。
|
|
12
|
+
|
|
13
|
+
## 提交 Pull Request
|
|
14
|
+
|
|
15
|
+
1. **Fork 本仓库** 到您的账号下。
|
|
16
|
+
2. 新建一个分支用于您的修改:`git checkout -b feature/your-feature-name` 或 `fix/your-bugfix-name`。
|
|
17
|
+
3. 确保您的代码符合本指南和已有的风格规范。如果添加了 Python 脚本用于 Agent 或工具流程,请**确保在独立的 `uv` 环境下进行了良好测试**。
|
|
18
|
+
4. 提交您的修改。提交信息(Commit Message)需要尽量清晰明了。
|
|
19
|
+
5. 创建一个指向本仓库的 Pull Request。
|
|
20
|
+
|
|
21
|
+
## 开发规范提示
|
|
22
|
+
|
|
23
|
+
1. **全局环境**:避免全局安装任何开发依赖,请使用项目内的独立虚拟隔离环境执行相关 Python 程序,并使用 `uv` 统一管理。
|
|
24
|
+
2. **文件编码**:涉及 Windows 命令执行或文件生成的脚本时,请务必保证以 UTF-8 或相应无乱码编码执行。
|
|
25
|
+
3. **遵循 SOP**:如果是针对核心 Agent Prompt 或 SOP 交互进行的改动,建议在拉取请求中附带通过跑通至少一次完整示例题型测试的运行截图。
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 [Developer/Organiation Name]
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
.PHONY: $(MAKECMDGOALS)
|
|
2
|
+
|
|
3
|
+
# 默认目标
|
|
4
|
+
help:
|
|
5
|
+
@echo "Available targets:"
|
|
6
|
+
@echo " setup - 安装依赖"
|
|
7
|
+
@echo " test - 运行测试"
|
|
8
|
+
@echo " test-cov - 运行测试并生成覆盖率报告"
|
|
9
|
+
@echo " lint - 运行 ruff lint 检查"
|
|
10
|
+
@echo " format - 格式化代码"
|
|
11
|
+
@echo " typecheck - 运行 mypy 类型检查"
|
|
12
|
+
@echo " check - 运行所有检查 (lint + typecheck + test)"
|
|
13
|
+
@echo " clean - 清理缓存和临时文件"
|
|
14
|
+
@echo " docs - 启动文档服务器"
|
|
15
|
+
|
|
16
|
+
# 安装依赖
|
|
17
|
+
setup:
|
|
18
|
+
uv sync --all-extras
|
|
19
|
+
|
|
20
|
+
# 运行测试
|
|
21
|
+
test:
|
|
22
|
+
uv run pytest tests/ -v
|
|
23
|
+
|
|
24
|
+
# 运行测试并生成覆盖率报告
|
|
25
|
+
test-cov:
|
|
26
|
+
uv run pytest tests/ --cov=src/autocode_mcp --cov-report=html --cov-report=term
|
|
27
|
+
|
|
28
|
+
# 运行 ruff lint 检查
|
|
29
|
+
lint:
|
|
30
|
+
uv run ruff check src/ tests/
|
|
31
|
+
|
|
32
|
+
# 格式化代码
|
|
33
|
+
format:
|
|
34
|
+
uv run ruff format src/ tests/
|
|
35
|
+
|
|
36
|
+
# 运行 mypy 类型检查
|
|
37
|
+
typecheck:
|
|
38
|
+
uv run mypy src/
|
|
39
|
+
|
|
40
|
+
# 运行所有检查
|
|
41
|
+
check: lint typecheck test
|
|
42
|
+
|
|
43
|
+
# 清理缓存和临时文件(跨平台兼容)
|
|
44
|
+
clean:
|
|
45
|
+
uv run python -c "import shutil, pathlib; [shutil.rmtree(p, ignore_errors=True) for p in pathlib.Path('.').rglob('__pycache__')]; [shutil.rmtree(p, ignore_errors=True) for p in ['.pytest_cache', '.mypy_cache', '.ruff_cache', 'htmlcov', '.coverage'] if pathlib.Path(p).exists()]"
|
|
46
|
+
|
|
47
|
+
# 启动文档服务器 (如果有 mkdocs)
|
|
48
|
+
docs:
|
|
49
|
+
uv run mkdocs serve
|