Skip to content

Commit 76d2295

Browse files
gxklclaude
andcommitted
docs(skills): add troubleshooting tables based on eval results
- egg-core SKILL.md: add common issues table (naming, AccessLevel, interface type, mixed inject, optional) - egg-controller SKILL.md: add troubleshooting table (MCP imports, z.object, schedule directory) - mcp-controller.md: expand decision tree with @extra use cases Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3bcfd76 commit 76d2295

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

packages/skills/egg-controller/SKILL.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,19 @@ allowed-tools: Read
3838

3939
### Schedule
4040

41-
- **装饰器**`@Schedule<T>`、配置
41+
- **装饰器**`@Schedule<T>`
4242
- **模式**:Worker/All
43+
- **详细文档**`references/schedule.md`
44+
45+
---
46+
47+
## 常见问题排查
48+
49+
| 现象 | 原因 | 解决方案 |
50+
| ---------------------- | ------------------------ | ------------------------------------------------------------------ |
51+
| MCP 装饰器 import 报错 |`'egg'` 导入 | MCP 装饰器从 `'@eggjs/tegg'` 导入,zod 从 `'@eggjs/tegg/zod'` 导入 |
52+
| MCP Schema 报错 | 用了 `z.object()` 包装 | 直接用普通对象 `{ name: z.string() }` |
53+
| 定时任务不生效 | 放在 `app/schedule` 目录 | 放在模块目录中,避免和 egg 默认扫描冲突 |
4354

4455
---
4556

packages/skills/egg-controller/references/mcp-controller.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,11 @@ export default () => {
8686
│ ├─ 资源地址固定 → @MCPResource({ uri: '...' })
8787
│ └─ 资源地址动态 → @MCPResource({ template: [...] })
8888
89-
└─ "Tool 执行中要推送进度"
90-
└─ → @MCPTool + @Extra() 获取 sendNotification
89+
├─ "Tool 执行中要推送进度"
90+
│ └─ → @MCPTool + @Extra() 获取 sendNotification(见下方 @Extra 章节)
91+
92+
└─ "Tool 中需要读取自定义请求头"
93+
└─ → @MCPTool + @Extra() 获取 requestInfo.headers
9194
```
9295

9396
---

packages/skills/egg-core/SKILL.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,16 @@ export class HelloService {
174174
| 使用自定义名称注入 | `@Inject({ name: 'customName' })` |
175175
| 同一抽象多种实现,运行时动态选择 | `QualifierImplDecoratorUtil` + `EggObjectFactory` |
176176

177+
## 常见问题排查
178+
179+
| 现象 | 原因 | 解决方案 |
180+
| ---------------------- | ------------------------------------------ | -------------------------------------------- |
181+
| 模块没被加载 | `eggModule.name` 包含 `-` 等特殊字符 | 改为驼峰命名 |
182+
| `EggPrototypeNotFound` | 跨模块注入但 accessLevel 为 PRIVATE | 改为 `AccessLevel.PUBLIC` |
183+
| 注入对象不对 | 类型为 `interface`/`any`,回退到属性名匹配 | 改用 class 类型或 `@Inject({ name: 'xxx' })` |
184+
| 混用注入方式报错 | 属性注入和构造函数注入不能混用 | 统一使用一种方式 |
185+
| 可选依赖启动报错 | 缺少 optional 标记 | `@Inject({ optional: true })` |
186+
177187
## 参考资料
178188

179189
- 详细的 module 文档,请参阅:`references/module.md`

0 commit comments

Comments
 (0)