Skip to content

Commit f720056

Browse files
committed
chore: relocate C++ guides and MCP build scripts
Move C/ guides under docs/cpp/ and build_mcp into scripts/, with thin root wrappers for compatibility. Update README, CONTRIBUTING, doctor, and keys template paths accordingly.
1 parent e23fd30 commit f720056

10 files changed

Lines changed: 204 additions & 195 deletions

File tree

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ uv sync
1313
Build the MCP ripgrep tool when you need agent-side code search:
1414

1515
```bash
16-
chmod +x build_mcp.sh
17-
./build_mcp.sh
16+
chmod +x scripts/build_mcp.sh
17+
./scripts/build_mcp.sh
1818
```
1919

2020
Run the environment doctor on a new machine:

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ uv sync
6565

6666
```bash
6767
# macOS / Linux
68-
chmod +x build_mcp.sh
69-
./build_mcp.sh
68+
chmod +x scripts/build_mcp.sh
69+
./scripts/build_mcp.sh
7070

7171
# Windows
72-
build_mcp.bat
72+
scripts\build_mcp.bat
7373
```
7474

7575
### 配置模型
@@ -263,14 +263,15 @@ PureAutoCodeQL/
263263
├── api/ # FastAPI 服务端
264264
├── config/ # LLM Provider 与运行配置
265265
├── core/ # 分析上下文、流水线和编排器
266-
├── docs/ # 使用指南与功能说明
266+
├── docs/ # 使用指南与功能说明(含 docs/cpp/)
267267
├── Information/ # GHSA / NVD 情报获取
268268
├── prompts/ # 各语言与各阶段提示词
269-
├── pure_auto_codeql/ # 规范化 Python 包命名空间
270-
├── pure_auto_codeql/application/ # CLI/API 共享工作流服务
271-
├── pure_auto_codeql/cli/ # 打包后的 CLI 实现
272-
── pure_auto_codeql/agents/ # CVE、Source、Sink、CodeQL 生成等 Agent
269+
├── pure_auto_codeql/ # 规范化 Python 包命名空间
270+
├── application/ # CLI/API 共享工作流服务
271+
├── cli/ # 打包后的 CLI 实现
272+
│ └── agents/ # CVE、Source、Sink、CodeQL 生成等 Agent
273273
├── resources/ # CodeQL 模板、知识库与扩展库
274+
├── scripts/ # API 启动、MCP 构建与 smoke 脚本
274275
├── services/ # LLM、LSP、路径精选等服务
275276
├── tools/ # CodeQL 组合、LSP 查询、MCP 工具
276277
├── utils/ # 案例解析、项目导入、CodeQL 执行等工具
@@ -289,7 +290,7 @@ PureAutoCodeQL/
289290
| [docs/output_files_guide.md](docs/output_files_guide.md) | 输出文件结构和用途 |
290291
| [docs/path_selection_run_guide.md](docs/path_selection_run_guide.md) | 路径精选模块运行说明 |
291292
| [docs/extra_input_files_simple.md](docs/extra_input_files_simple.md) | `inputs/` 额外上下文文件 |
292-
| [C/CPP_TWO_STEP_BUILD_GUIDE.md](C/CPP_TWO_STEP_BUILD_GUIDE.md) | C/C++ 两步走建库策略 |
293+
| [docs/cpp/CPP_TWO_STEP_BUILD_GUIDE.md](docs/cpp/CPP_TWO_STEP_BUILD_GUIDE.md) | C/C++ 两步走建库策略 |
293294
| [docs/archive/](docs/archive/) | 历史设计方案、诊断笔记和阶段性总结 |
294295

295296
## 测试

build_mcp.bat

Lines changed: 2 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,3 @@
11
@echo off
2-
setlocal enabledelayedexpansion
3-
chcp 65001 >nul 2>&1
4-
REM 构建脚本:安装和编译 MCP 相关工具
5-
echo ========================================
6-
echo PureAutoCodeQL - MCP 工具构建脚本
7-
echo ========================================
8-
echo.
9-
10-
REM 检查 Node.js 是否安装
11-
REM 先尝试使用 where.exe 查找 node.exe
12-
where.exe node.exe >nul 2>&1
13-
if errorlevel 1 (
14-
REM 如果 where 找不到,直接尝试运行 node
15-
node --version >nul 2>&1
16-
if errorlevel 1 (
17-
echo [错误] 未找到 Node.js,请先安装 Node.js (v18 或更高版本)
18-
echo 下载地址: https://nodejs.org/
19-
exit /b 1
20-
)
21-
)
22-
23-
echo [1/2] 检查 Node.js 版本...
24-
node --version
25-
echo.
26-
27-
REM 构建 mcp_ripgrep
28-
echo [2/2] 构建 mcp_ripgrep...
29-
cd tools\mcp_ripgrep
30-
31-
if not exist "node_modules" (
32-
echo 安装依赖...
33-
call npm install
34-
if %ERRORLEVEL% NEQ 0 (
35-
echo [错误] npm install 失败
36-
cd ..\..
37-
exit /b 1
38-
)
39-
) else (
40-
echo 依赖已存在,跳过安装
41-
)
42-
43-
echo 编译 TypeScript...
44-
call npm run build
45-
if %ERRORLEVEL% NEQ 0 (
46-
echo [错误] TypeScript 编译失败
47-
cd ..\..
48-
exit /b 1
49-
)
50-
51-
cd ..\..
52-
53-
REM 检查编译结果
54-
if exist "tools\mcp_ripgrep\dist\index.js" (
55-
echo.
56-
echo ========================================
57-
echo ✓ 构建成功!
58-
echo ========================================
59-
echo mcp_ripgrep 已编译到: tools\mcp_ripgrep\dist\index.js
60-
echo.
61-
) else (
62-
echo.
63-
echo [错误] 编译后的文件不存在
64-
exit /b 1
65-
)
66-
2+
REM Compatibility wrapper — prefer scripts\build_mcp.bat
3+
call "%~dp0scripts\build_mcp.bat" %*

build_mcp.sh

Lines changed: 2 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,3 @@
11
#!/bin/bash
2-
# 构建脚本:安装和编译 MCP 相关工具
3-
4-
echo "========================================"
5-
echo " PureAutoCodeQL - MCP 工具构建脚本"
6-
echo "========================================"
7-
echo ""
8-
9-
# 检查 Node.js 是否安装
10-
if ! command -v node &> /dev/null; then
11-
echo "[错误] 未找到 Node.js,请先安装 Node.js (v18 或更高版本)"
12-
echo "下载地址: https://nodejs.org/"
13-
exit 1
14-
fi
15-
16-
echo "[1/2] 检查 Node.js 版本..."
17-
NODE_VERSION=$(node --version)
18-
echo "Node.js 版本: $NODE_VERSION"
19-
20-
# 检查 Node.js 版本是否满足要求 (v18 或更高)
21-
NODE_MAJOR=$(echo $NODE_VERSION | cut -d'v' -f2 | cut -d'.' -f1)
22-
if [ "$NODE_MAJOR" -lt 18 ]; then
23-
echo "[错误] Node.js 版本过低,需要 v18 或更高版本,当前版本: $NODE_VERSION"
24-
exit 1
25-
fi
26-
echo "✓ Node.js 版本检查通过"
27-
echo ""
28-
29-
# 构建 mcp_ripgrep
30-
echo "[2/2] 构建 mcp_ripgrep..."
31-
32-
# 保存原始目录
33-
ORIGINAL_DIR=$(pwd)
34-
35-
# 检查目录是否存在
36-
if [ ! -d "tools/mcp_ripgrep" ]; then
37-
echo "[错误] tools/mcp_ripgrep 目录不存在"
38-
exit 1
39-
fi
40-
41-
cd tools/mcp_ripgrep || {
42-
echo "[错误] 无法进入 tools/mcp_ripgrep 目录"
43-
exit 1
44-
}
45-
46-
echo "当前工作目录: $(pwd)"
47-
48-
if [ ! -d "node_modules" ]; then
49-
echo " 安装依赖..."
50-
npm install || {
51-
echo "[错误] npm install 失败"
52-
cd "$ORIGINAL_DIR"
53-
exit 1
54-
}
55-
echo "✓ 依赖安装成功"
56-
else
57-
echo " 依赖已存在,跳过安装"
58-
fi
59-
60-
echo " 编译 TypeScript..."
61-
npm run build || {
62-
echo "[错误] TypeScript 编译失败"
63-
cd "$ORIGINAL_DIR"
64-
exit 1
65-
}
66-
echo "✓ TypeScript 编译成功"
67-
68-
# 返回原始目录
69-
cd "$ORIGINAL_DIR" || {
70-
echo "[错误] 无法返回原始目录"
71-
exit 1
72-
}
73-
74-
# 检查编译结果
75-
DIST_FILE="tools/mcp_ripgrep/dist/index.js"
76-
echo " 检查编译结果: $DIST_FILE"
77-
78-
if [ -f "$DIST_FILE" ]; then
79-
# 检查文件是否为空
80-
FILE_SIZE=$(stat -f%z "$DIST_FILE" 2>/dev/null || stat -c%s "$DIST_FILE" 2>/dev/null || echo "0")
81-
if [ "$FILE_SIZE" -gt 0 ]; then
82-
echo ""
83-
echo "========================================"
84-
echo " ✓ 构建成功!"
85-
echo "========================================"
86-
echo " mcp_ripgrep 已编译到: $DIST_FILE"
87-
echo " 文件大小: $FILE_SIZE 字节"
88-
echo ""
89-
90-
# 设置执行权限
91-
chmod +x "$DIST_FILE" || {
92-
echo "[警告] 无法设置执行权限,但不影响使用"
93-
}
94-
95-
# 验证文件内容
96-
if grep -q "mcp-ripgrep\|MCP\|ripgrep" "$DIST_FILE" 2>/dev/null; then
97-
echo "✓ 文件内容验证通过"
98-
else
99-
echo "[警告] 文件内容验证失败,但文件已生成"
100-
fi
101-
else
102-
echo ""
103-
echo "[错误] 编译后的文件存在但为空"
104-
exit 1
105-
fi
106-
else
107-
echo ""
108-
echo "[错误] 编译后的文件不存在: $DIST_FILE"
109-
echo "调试信息:"
110-
echo "- 当前目录: $(pwd)"
111-
echo "- dist 目录内容:"
112-
if [ -d "tools/mcp_ripgrep/dist" ]; then
113-
ls -la "tools/mcp_ripgrep/dist/" 2>/dev/null || echo "无法列出目录内容"
114-
else
115-
echo "dist 目录不存在"
116-
fi
117-
exit 1
118-
fi
2+
# Compatibility wrapper — prefer ./scripts/build_mcp.sh
3+
exec "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/scripts/build_mcp.sh" "$@"

config/keys.example.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ docker_builder_image = "pure-codeql-cpp:latest"
148148
#
149149
# 3. 失败报告(提供诊断信息)
150150
#
151-
# 详细说明请查看:C/CPP_TWO_STEP_BUILD_GUIDE.md
151+
# 详细说明请查看:docs/cpp/CPP_TWO_STEP_BUILD_GUIDE.md
152152

153153

154154
# ============================================================================
File renamed without changes.
File renamed without changes.

scripts/build_mcp.bat

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
@echo off
2+
setlocal enabledelayedexpansion
3+
chcp 65001 >nul 2>&1
4+
REM 构建脚本:安装和编译 MCP 相关工具
5+
REM 可从任意 cwd 调用;始终以仓库根目录为基准。
6+
echo ========================================
7+
echo PureAutoCodeQL - MCP 工具构建脚本
8+
echo ========================================
9+
echo.
10+
11+
set "SCRIPT_DIR=%~dp0"
12+
for %%I in ("%SCRIPT_DIR%..") do set "ROOT_DIR=%%~fI"
13+
cd /d "%ROOT_DIR%"
14+
15+
REM 检查 Node.js 是否安装
16+
where.exe node.exe >nul 2>&1
17+
if errorlevel 1 (
18+
node --version >nul 2>&1
19+
if errorlevel 1 (
20+
echo [错误] 未找到 Node.js,请先安装 Node.js (v18 或更高版本)
21+
echo 下载地址: https://nodejs.org/
22+
exit /b 1
23+
)
24+
)
25+
26+
echo [1/2] 检查 Node.js 版本...
27+
node --version
28+
echo.
29+
30+
REM 构建 mcp_ripgrep
31+
echo [2/2] 构建 mcp_ripgrep...
32+
if not exist "tools\mcp_ripgrep" (
33+
echo [错误] tools\mcp_ripgrep 目录不存在
34+
exit /b 1
35+
)
36+
37+
cd tools\mcp_ripgrep
38+
39+
if not exist "node_modules" (
40+
echo 安装依赖...
41+
call npm install
42+
if %ERRORLEVEL% NEQ 0 (
43+
echo [错误] npm install 失败
44+
exit /b 1
45+
)
46+
) else (
47+
echo 依赖已存在,跳过安装
48+
)
49+
50+
echo 编译 TypeScript...
51+
call npm run build
52+
if %ERRORLEVEL% NEQ 0 (
53+
echo [错误] TypeScript 编译失败
54+
exit /b 1
55+
)
56+
57+
cd /d "%ROOT_DIR%"
58+
59+
REM 检查编译结果
60+
if exist "tools\mcp_ripgrep\dist\index.js" (
61+
echo.
62+
echo ========================================
63+
echo ✓ 构建成功!
64+
echo ========================================
65+
echo mcp_ripgrep 已编译到: tools\mcp_ripgrep\dist\index.js
66+
echo.
67+
) else (
68+
echo.
69+
echo [错误] 编译后的文件不存在
70+
exit /b 1
71+
)

0 commit comments

Comments
 (0)