内容
# Structurizr DSL 调试器 for Cursor
专为 Cursor IDE 设计的 Structurizr DSL 语法问题调试工具。该工具通过模型上下文协议(MCP)与 Cursor 集成,提供实时的 Structurizr DSL 错误检测、分析和修复建议。
## 功能
- 🔍 **实时错误检测** - 自动捕获 Structurizr DSL 文件中的语法错误
- 🛠️ **建议修复** - 提供智能建议以纠正常见的 DSL 错误
- 🔄 **浏览器集成** - 连接到带有 Structurizr 页面的 Chrome 以监控错误
- 🧩 **Cursor IDE 集成** - 使用 MCP 工具与 Cursor 无缝集成
- ⚙️ **可配置** - 支持自定义 Structurizr 端口配置
- 📊 **错误历史** - 保留捕获的错误日志以供查看
## 要求
- Node.js 14+
- Cursor IDE
- 启用远程调试的 Google Chrome
- 正在本地运行的 Structurizr Lite(通常在端口 8080 上)
## 安装
1. 克隆此仓库:
```bash
git clone https://github.com/your-username/structurizr-dsl-debugger.git
cd structurizr-dsl-debugger
```
2. 安装依赖项:
```bash
npm install
```
3. 设置 Cursor IDE 集成:
```bash
npm run setup
```
## 使用
### 启动 Structurizr
1. 运行 Structurizr Lite(如果尚未运行):
```bash
docker run -it --rm -p 8080:8080 -v /path/to/workspace:/workspace structurizr/lite
```
### 使用调试器
1. 启动启用远程调试的 Chrome:
```bash
google-chrome --remote-debugging-port=9222 http://localhost:8080
```
2. 启动 DSL 调试器:
```bash
# 标准启动(默认端口 8080)
npm start
# 使用自定义 Structurizr 端口
STRUCTURIZR_PORT=9090 npm start
# 使用交互式提示的启动器
npm run debug
```
3. 在 Cursor IDE 中,使用 MCP 工具:
```
connectToBrowser: { "debugPort": 9222, "structurizrPort": 8080 }
getDslErrors: { "count": 5 }
clearDslErrors: {}
fixDslError: { "line": 776, "fix": "dynamic ContainerName ErrorHandlingFlow {" }
```
### 简化版本
如果您遇到主调试器的问题,请尝试简化版本:
```bash
node simplified-dsl-debugger.js
```
使用更短的 MCP 工具名称:
```
connect: { "port": 9222 }
errors: { "count": 5 }
fix: { "line": 776, "solution": "dynamic ContainerName ErrorHandlingFlow {" }
```
### 实用脚本
- **直接捕获错误**:
```bash
npm run capture
```
- **查看捕获的错误**:
```bash
npm run errors
```
## 故障排除
### Chrome 连接问题
- 确保 Chrome 正在端口 9222 上启用远程调试
- 检查 Chrome 是否已经使用 `--remote-debugging-port` 标志运行
- 尝试使用以下命令重启 Chrome:`google-chrome --remote-debugging-port=9222 http://localhost:8080`
### MCP 工具问题
- 验证 MCP 服务器是否正在运行:`npm start`
- 尝试使用简化版本:`node simplified-dsl-debugger.js`
- 检查日志目录中的捕获错误
- 重启 Cursor IDE
### 端口冲突
- Structurizr 默认端口是 8080
- 如果另一个应用程序正在使用端口 8080,您可以:
- 更改 Structurizr 端口
- 将调试器更新为使用新端口:`STRUCTURIZR_PORT=9090 npm start`
## 许可证
MIT