-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[github] add copilot instructions #10626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,196 @@ | ||||||||||||
| # GitHub Copilot Instructions for RT-Thread / RT-Thread GitHub Copilot 指南 | ||||||||||||
|
|
||||||||||||
| ## Overview / 概述 | ||||||||||||
|
|
||||||||||||
| RT-Thread is a real-time operating system (RTOS) for embedded devices. When working with RT-Thread code, please follow these guidelines to ensure high-quality contributions. | ||||||||||||
|
|
||||||||||||
| RT-Thread 是一个面向嵌入式设备的实时操作系统(RTOS)。在处理 RT-Thread 代码时,请遵循以下指南以确保高质量的贡献。 | ||||||||||||
|
|
||||||||||||
| ## Code Review Guidelines / 代码审查指南 | ||||||||||||
|
|
||||||||||||
| ### Language Requirements / 语言要求 | ||||||||||||
|
|
||||||||||||
| When reviewing code, provide feedback in **both English and Chinese** to ensure accessibility for all contributors. | ||||||||||||
|
|
||||||||||||
| 在审查代码时,请同时使用**英文和中文**提供反馈,以确保所有贡献者都能理解。 | ||||||||||||
|
|
||||||||||||
| ### Review Focus Areas / 审查重点领域 | ||||||||||||
|
|
||||||||||||
| 1. **Real-Time Performance / 实时性能** | ||||||||||||
| - Verify interrupt handling efficiency / 验证中断处理效率 | ||||||||||||
|
|
||||||||||||
| 2. **Memory Management / 内存管理** | ||||||||||||
| - Detect memory leaks / 检测内存泄漏 | ||||||||||||
| - Verify proper memory allocation/deallocation / 验证正确的内存分配/释放 | ||||||||||||
| - Check stack usage optimization / 检查栈使用优化 | ||||||||||||
|
|
||||||||||||
| 3. **Code Style / 代码风格** | ||||||||||||
| - Follow RT-Thread coding standards / 遵循 RT-Thread 编码标准 | ||||||||||||
| - Maintain consistent naming conventions / 保持一致的命名约定 | ||||||||||||
| - Ensure proper code comments (not documentation) / 确保适当的代码注释(而非文档) | ||||||||||||
|
|
||||||||||||
| ### Review Comment Format / 审查评论格式 | ||||||||||||
|
|
||||||||||||
| When providing review comments, use the following format: | ||||||||||||
|
|
||||||||||||
| 提供审查评论时,请使用以下格式: | ||||||||||||
|
|
||||||||||||
| ``` | ||||||||||||
| [Category/类别]: Brief description / 简要描述 | ||||||||||||
|
|
||||||||||||
| English: Detailed explanation of the issue and suggested improvement. | ||||||||||||
| 中文:问题的详细说明和改进建议。 | ||||||||||||
|
|
||||||||||||
| Example/示例: | ||||||||||||
| ```c | ||||||||||||
| // Your code example here / 你的代码示例 | ||||||||||||
| ``` | ||||||||||||
| ``` | ||||||||||||
|
|
||||||||||||
| ### Common Issues to Check / 常见问题检查 | ||||||||||||
|
|
||||||||||||
| 1. **Resource Management / 资源管理** | ||||||||||||
| - Unclosed file handles / 未关闭的文件句柄 | ||||||||||||
| - Unreleased semaphores / 未释放的信号量 | ||||||||||||
| - Memory not freed after malloc / malloc 后未释放内存 | ||||||||||||
|
|
||||||||||||
| 2. **Error Handling / 错误处理** | ||||||||||||
| - Missing error checks / 缺少错误检查 | ||||||||||||
| - Improper error propagation / 不当的错误传播 | ||||||||||||
| - Silent failures / 静默失败 | ||||||||||||
|
|
||||||||||||
| 3. **Performance Concerns / 性能问题** | ||||||||||||
| - Unnecessary polling / 不必要的轮询 | ||||||||||||
| - Inefficient algorithms in ISRs / ISR 中的低效算法 | ||||||||||||
| - Excessive context switching / 过度的上下文切换 | ||||||||||||
|
|
||||||||||||
| ### Severity Levels / 严重程度级别 | ||||||||||||
|
|
||||||||||||
| - **🔴 Critical/严重**: Issues that may cause system crashes or data corruption / 可能导致系统崩溃或数据损坏的问题 | ||||||||||||
| - **🟠 Major/主要**: Significant bugs or performance issues / 重大错误或性能问题 | ||||||||||||
| - **🟡 Minor/次要**: Code style or minor optimization opportunities / 代码风格或次要优化机会 | ||||||||||||
| - **🟢 Suggestion/建议**: Best practices or enhancement ideas / 最佳实践或增强建议 | ||||||||||||
|
|
||||||||||||
| ## RT-Thread Specific Guidelines / RT-Thread 特定指南 | ||||||||||||
|
|
||||||||||||
| ### Kernel Components / 内核组件 | ||||||||||||
|
|
||||||||||||
| When reviewing kernel-related code: | ||||||||||||
| 审查内核相关代码时: | ||||||||||||
|
|
||||||||||||
| - Verify rt_thread structure usage / 验证 rt_thread 结构使用 | ||||||||||||
|
||||||||||||
| - Verify rt_thread structure usage / 验证 rt_thread 结构使用 | |
| - Verify rt_thread structure usage, including: | |
| - Proper initialization of the rt_thread structure / 正确初始化 rt_thread 结构体 | |
| - Correct thread priority settings / 正确设置线程优先级 | |
| - Appropriate stack size validation / 合理验证栈大小 |
Copilot
AI
Aug 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The exception for 'local function/variable macros' is unclear. Consider providing examples or more specific criteria for when macros should not be UPPERCASE to avoid confusion.
| - **Macros / 宏定义**: UPPERCASE (except for local function/variable macros) | |
| - **Macros / 宏定义**: UPPERCASE for global macros. For macros that are local to a single function or file (such as small helpers or inline utilities), lowercase or mixed case may be used. | |
| - **Examples / 示例**: | |
| - Global macro: `#define RT_THREAD_PRIORITY_MAX 32` | |
| - Local macro (inside a function or file): `#define min(a, b) ((a) < (b) ? (a) : (b))` |
Copilot
AI
Aug 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The instruction to 'hide footbox in sequence diagrams' is a very specific PlantUML detail that seems out of place in general documentation guidelines. Consider moving this to a more detailed PlantUML style guide or removing it for brevity.
| - Prefer Mermaid for diagrams, or PlantUML (hide footbox in sequence diagrams) / 优先使用Mermaid绘图,或PlantUML(时序图隐藏footbox) | |
| - Prefer Mermaid for diagrams, or PlantUML / 优先使用Mermaid绘图,或PlantUML |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The interrupt handling efficiency guideline is too vague. Consider adding specific criteria such as 'Keep ISR execution time under X microseconds' or 'Avoid blocking operations in ISRs' to provide more actionable guidance.