|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +此文件为 Claude Code (claude.ai/code) 在本仓库中工作时提供指导。 |
| 4 | + |
| 5 | +## 项目概述 |
| 6 | + |
| 7 | +这是一个用于 RT-Thread 和 RT-Thread Smart 开发的 VS Code 扩展。该扩展遵循最小化干预 VS Code 的原则,同时允许用户使用 RT-Thread 的脚本功能进行个性化定制。 |
| 8 | + |
| 9 | +## 常用命令 |
| 10 | + |
| 11 | +### 开发相关 |
| 12 | +```bash |
| 13 | +# Install dependencies |
| 14 | +npm install |
| 15 | + |
| 16 | +# Build Vue frontend (required before extension build) |
| 17 | +npm run build:vue |
| 18 | + |
| 19 | +# Compile TypeScript extension |
| 20 | +npm run compile |
| 21 | + |
| 22 | +# Watch mode for development |
| 23 | +npm run watch |
| 24 | + |
| 25 | +# Lint the code |
| 26 | +npm run lint |
| 27 | + |
| 28 | +# Run tests |
| 29 | +npm run test |
| 30 | + |
| 31 | +# Build extension package |
| 32 | +npm run vscode:prepublish |
| 33 | +``` |
| 34 | + |
| 35 | +### Vue 前端开发(在 src/vue 工作区中) |
| 36 | +```bash |
| 37 | +cd src/vue |
| 38 | +npm install |
| 39 | +npm run dev # Development server |
| 40 | +npm run build # Production build |
| 41 | +``` |
| 42 | + |
| 43 | +## 架构说明 |
| 44 | + |
| 45 | +### 扩展结构 |
| 46 | +- **主入口**: `src/extension.ts` - 基于 `rtconfig.h` 或 `.vscode/workspace.json` 的存在来激活 |
| 47 | +- **两种运行模式**: |
| 48 | + - **项目模式** (`isRTThread`): 包含 `rtconfig.h` 的单个 RT-Thread 项目 |
| 49 | + - **工作区模式** (`isRTThreadWorksapce`): 通过 `.vscode/workspace.json` 管理的多个 BSP 项目 |
| 50 | + |
| 51 | +### 核心组件 |
| 52 | +1. **Webviews** (`src/webviews/`): 管理基于 Vue 的 UI 面板 |
| 53 | + - 设置、关于、创建项目、项目视图 |
| 54 | + - 每个 webview 在 `src/vue/` 中都有对应的 Vue 应用 |
| 55 | + |
| 56 | +2. **项目管理** (`src/project/`): |
| 57 | + - 文件资源管理器的树形提供器 |
| 58 | + - 用于视觉指示的文件装饰提供器 |
| 59 | + - BSP 项目的命令执行 |
| 60 | + |
| 61 | +3. **终端集成** (`src/terminal.ts`): |
| 62 | + - 管理 RT-Thread 终端会话 |
| 63 | + - 执行构建命令和自定义菜单命令 |
| 64 | + |
| 65 | +4. **虚拟环境** (`src/venv.ts`): |
| 66 | + - Windows 特定的 Python 虚拟环境设置 |
| 67 | + - 管理 env 脚本安装 |
| 68 | + |
| 69 | +### 配置文件 |
| 70 | +- **`.vscode/workspace.json`**: 多 BSP 工作区配置 |
| 71 | +- **`.vscode/project.json`**: 单个项目文件结构(由 scons 生成) |
| 72 | +- **`~/.env/cfg.json`**: RT-Thread 源码路径配置 |
| 73 | +- **`~/.env/tools/scripts/sdk_cfg.json`**: 工具链配置 |
| 74 | + |
| 75 | +### 构建系统 |
| 76 | +- TypeScript 编译为 CommonJS 用于 VS Code 扩展 |
| 77 | +- Vue 3 + Element Plus 前端使用 Vite 构建 |
| 78 | +- 多页面 Vue 应用构建到 `out/` 目录 |
| 79 | +- 通过 `smart.parallelBuidNumber` 设置支持并行构建 |
| 80 | + |
| 81 | +### 关键设置 |
| 82 | +- `smart.menuCommands`: 自定义终端命令数组 |
| 83 | +- `smart.parallelBuidNumber`: 并行构建的 CPU 核心数 |
| 84 | + |
| 85 | +## 重要说明 |
| 86 | + |
| 87 | +1. 扩展仅在 RT-Thread 项目中激活(包含 `rtconfig.h` 或工作区配置) |
| 88 | +2. Windows 系统在首次运行时需要设置 Python 虚拟环境 |
| 89 | +3. 必须先构建 Vue 前端再编译扩展 |
| 90 | +4. 扩展集成了 Python 扩展(`ms-python.python`) |
| 91 | +5. 文件装饰器在工作区模式下标记当前活动的 BSP |
0 commit comments