|
|
在让TRAE CN成功编程后,请它总结在编程过程中所犯的错误,让DEEPSEEK根据总结文字去修改技能书:
感谢你提供的详细错误总结!这些是实际开发中非常宝贵的问题记录。我将根据这些内容修改 `SKILL.md`,增加针对性的规则来避免同类错误。
以下是修改后的 `SKILL.md`,新增了 **"Common Mistakes & Prevention"** 章节:
```markdown
---
name: volcano-programming
description: "Use for Volcano Programming questions that need official syntax, API names, sample code, or platform-specific guidance for 火山视窗, 火山安卓, and 火山服务器 on Windows. Trigger when the user mentions 火山编程, 火山视窗, 火山安卓, 火山服务器, asks how to write a statement or command in Volcano syntax, wants code translated from C++/Java/Go concepts into Volcano code, or needs examples from the local official Markdown manuals in `%USERPROFILE%\\\\.codex\\\\docs`."
---
# Volcano Programming
Use the local official Volcano manuals as the primary source of truth before answering syntax, API, or example-code questions.
Prefer official names and examples from the manuals over generic programming habits or guessed syntax.
## Platform Routing
Use these manual paths:
- 火山视窗: read `<docs-dir>\vol_win_full.md`
- 火山安卓: read `<docs-dir>\vol_android_full.md`
- 火山服务器: read `<docs-dir>\vol_server_full.md`
Set `<docs-dir>` to `%USERPROFILE%\.codex\docs`.
If the user does not clearly specify the platform, ask a short clarification question before giving syntax-sensitive code.
Use this mapping when reasoning from underlying language concepts:
- 火山视窗: closest to Windows/C++ style concepts
- 火山安卓: closest to Android/Java style concepts
- 火山服务器: closest to Go/backend style concepts
Return Volcano syntax, not raw C++/Java/Go, unless the user explicitly asks for a comparison.
## Retrieval Workflow
1. Determine the target platform.
2. Search only the relevant manual first.
3. Search by Volcano keyword, Chinese term, English API name, and likely underlying-language term when needed.
4. Read the nearby section around the best match instead of loading the whole manual.
5. Cross-check examples with the surrounding syntax notes before answering.
6. When scanning the user's project files, ignore backup files and prefer the active project/source files.
7. Ignore generated cache directories whose path segment is `_int` or contains `_int`, unless the user explicitly asks to inspect them.
Assume a Windows environment and PowerShell-style paths when searching local files.
Prefer `rg` for search. Recommended patterns for PowerShell:
- `rg -n "关键词" "$env:USERPROFILE\.codex\docs\vol_win_full.md"`
- Or using single quotes: `rg -n '关键词' 'C:\Users\用户名\.codex\docs\vol_win_full.md'`
Read [doc-index.md](references/doc-index.md) for the manual map and search tips.
Ignore these backup files unless the user explicitly asks for them:
- `*.~vbak.vprj`
- `*.~vbak.wsv`
## File Handling
Treat Volcano project/workspace files as UTF-16LE or UTF-8 depending on the file's BOM or encoding detection. If no BOM is present, prefer UTF-8. When editing `.vprj` or `.wsv` files, preserve the original encoding without converting to another format.
When scanning the user's project files:
- Prefer files with extensions: `.v`, `.vproj`, `.wsv`, `.vui`
- Ignore backup files: `*.~vbak.vprj`, `*.~vbak.wsv`, `*.bak`
- Ignore cache directories: `_int`, `_temp`, `obj`, `bin`
- Prefer the most recently modified source files when multiple candidates exist.
## Embedded Methods
Volcano allows embedded methods that directly use underlying language syntax (C++ for 火山视窗, Java for 火山安卓, Go for 火山服务器).
When encountering or generating embedded methods:
1. Clearly mark the embedded section with appropriate syntax indicators.
2. Do not assume embedded syntax follows Volcano's own statement rules.
3. Prefer pure Volcano syntax unless the user explicitly asks for embedded methods or the required functionality is only available via embedding.
## User-Provided Code
When the user provides a Volcano code snippet directly (not as a file path):
1. Assume the code is written for the platform indicated by syntax patterns or user statement.
2. If the platform is ambiguous, ask for clarification.
3. Analyze the code against the relevant manual if correctness is in question.
4. Do not modify the user's code unless explicitly requested; instead, explain potential issues.
## Error Handling
If a required manual path is missing, report the missing file and:
- If the platform is unambiguous, fall back to general knowledge but explicitly mark the answer as "not verified against official manual".
- If multiple manuals are missing or the platform is unclear, ask the user to verify the manual location or provide the information directly.
## Common Mistakes & Prevention (火山视窗)
Based on real development experiences, avoid these frequently encountered errors when writing Volcano code:
### 1. Syntax Errors
| Mistake | Wrong | Correct |
|---------|-------|---------|
| Conditional statement format | `如果 (x < 0) { x = 0 }` | `如果 (x < 0)` + 换行 + `x = 0` + 换行 + `结束如果` |
| Method parameter order | Always check manual; do not guess parameter order (e.g., 移动读写位置 expects (基准位置, 偏移量), not (偏移量, 基准位置)) |
| Invalid characters | Ensure no stray whitespace or invisible characters in code |
**Rule**: Never use C++/Java single-line brace syntax for Volcano conditional statements. Always use proper multi-line format with `如果`, `否则`, `结束如果`.
### 2. File Operation Errors
| Mistake | Wrong | Correct |
|---------|-------|---------|
| Filename suffix change | `磁盘操作类.改变文件名后缀("锤子.cur", ".cur")` may produce "锤子..cur" | Manually handle filename strings to avoid double dots |
| File position constants | Use integer `0` for file start | Use `文件基准位置.文件首` constant |
| Missing file validation | Assume file exists and is valid | Always check `文件是否存在()` and validate file size/format before operations |
**Rule**: Always use named constants from the `文件基准位置` enum instead of magic numbers (0, 1, 2). Validate file existence before operations.
### 3. Image/CUR/ICO Format Requirements
When working with CUR (cursor) or ICO (icon) files:
| Requirement | Details |
|-------------|---------|
| Double height | DIB header height must be `2 × image_height` (XOR mask + AND mask) |
| AND mask | Must compute and append AND mask data: `每行字节数 = (宽度 + 7) / 8`, aligned to 4-byte boundary |
| XOR mask | Standard bitmap color data precedes the AND mask |
**Rule**: For CUR/ICO files, never treat them as standard BMP. Always calculate AND mask and double the height value in the DIB header.
### 4. Byte Set (字节集) Operations
| Wrong approach | Correct approach |
|----------------|------------------|
| Using non-existent methods like `取字节集中间部分`, `添加字节` | Use `字节集操作` class methods: `取字节集中间()`, `追加字节集()`, `插入字节集()` |
| Assuming methods exist without verification | Check the `字节集操作` class in manual for available methods |
**Rule**: Do not invent byte set method names. Use only methods documented in the `字节集操作` class.
### 5. Environment & Dependencies
| Mistake | Prevention |
|---------|------------|
| Assuming Python is available with specific libraries | Check Python availability and required packages (e.g., Pillow) before generating Python-dependent code; provide fallback pure Volcano solutions |
| Incorrect C++ embedding syntax | When embedding C++ in 火山视窗, verify the exact syntax for `@嵌入式方法` and `@嵌入代码` directives; do not guess |
| Not handling missing dependencies gracefully | Include `取程序错误信息()` or equivalent error reporting; provide clear user guidance |
### 6. Code Structure Problems
| Mistake | Wrong | Correct |
|---------|-------|---------|
| Event handling | `挂接事件(按钮)` | `挂接事件(按钮, 标记值)` - requires two parameters |
| Variable naming | Variables named `宽度`, `高度` conflicting with window class properties | Use distinct names like `图片宽度`, `窗口高度` |
| Error handling | No validation or user feedback | Include `如果 (取反(文件是否存在(路径)))` with descriptive `信息框()` prompts |
| Missing event loop | Code exits before processing events | Ensure `消息循环` or `运行()` is called for GUI applications |
### 7. General Prevention Checklist
Before outputting Volcano code, verify:
- [ ] Conditional statements use multi-line `如果...结束如果` format, not brace syntax
- [ ] Method parameters follow manual order (check against documentation)
- [ ] File operations use named constants (e.g., `文件基准位置.文件首`) not magic numbers
- [ ] Filename operations avoid double dots; prefer string manipulation over `改变文件名后缀` when uncertain
- [ ] CUR/ICO files have double height and AND mask properly implemented
- [ ] Byte set operations use `字节集操作` class documented methods
- [ ] Environment dependencies are checked or pure Volcano alternatives provided
- [ ] Event handling uses correct parameter count (`挂接事件` requires two parameters)
- [ ] Variable names don't conflict with reserved names or window properties
- [ ] Error handling provides user feedback with `信息框()` or `调试输出()`
## Response Rules
- Cite which manual was used when the answer depends on official syntax or API details.
- If the manuals do not contain an exact match, say that explicitly and mark the answer as an inference.
- Do not invent unsupported syntax, parameter order, event names, or library behavior.
- Prefer short runnable examples in Volcano style.
- When converting code, explain any concept mapping that is not obvious between Volcano and the underlying platform.
- When multiple manuals may apply, tell the user which one you chose and why.
- When working with Volcano files, keep the file in its original encoding (UTF-16LE or UTF-8) unless the user provides clear evidence that a specific file uses another encoding.
- When working with `.vprj` or `.wsv` files, preserve the original encoding and do not silently convert them to another encoding.
- **When generating code for 火山视窗**: Review the Common Mistakes section above and ensure none of those patterns appear in the output.
- **When uncertain about parameter order or method existence**: State the uncertainty explicitly and recommend checking the manual.
## Example Requests
- "火山视窗里怎么声明数组并遍历?"
- "把这段 Java 思路改成火山安卓写法"
- "火山服务器怎么发 HTTP 请求?"
- "从官方文档里找一个定时器或线程的示例"
- "这个火山命令是什么意思,给我对应示例"
## Boundaries
- This skill is intended for Windows only.
- This skill depends on local manuals existing under `%USERPROFILE%\.codex\docs`.
- If a manual path is missing, report the missing file and continue with the remaining manuals if possible (see Error Handling section).
- Do not treat general C++/Java/Go examples as official Volcano syntax unless the manuals support the mapping.
- Do not inspect or cite backup project files such as `*.~vbak.vprj` and `*.~vbak.wsv` unless the user explicitly requests those files.
- Do not inspect generated cache directories named `_int` or whose path contains `_int` unless the user explicitly requests them.
```
## 主要修改摘要
| 新增内容 | 说明 |
|----------|------|
| **Common Mistakes & Prevention** 章节 | 基于你提供的错误经验,系统化整理了7类常见错误 |
| 语法错误表格 | 明确条件语句不能用C++大括号格式,必须用多行`如果...结束如果` |
| 文件操作错误表格 | 包含`改变文件名后缀`可能产生双点的问题、`文件基准位置`常量使用 |
| CUR/ICO格式要求 | 明确双倍高度、AND掩码的计算规则 |
| 字节集操作 | 禁止臆造方法名,必须使用`字节集操作`类 |
| 环境依赖 | Python/Pillow检查、C++嵌入语法验证 |
| 代码结构问题 | 事件处理、变量命名、错误处理、消息循环 |
| 预防检查清单 | 输出代码前应验证的10个要点 |
| Response Rules增强 | 新增两条规则:生成代码时检查Common Mistakes;不确定时明确声明 |
这份修改后的 `SKILL.md` 应该能有效防止同类错误再次发生。 |
评分
-
查看全部评分
|