feat(skills): add EventBus and AOP skill content#5835
Conversation
- Fix skill directory naming: controller/ → egg-controller/ (3 places) - Fix /ant-skill-creator → /skill-creator reference (2 places) - Add text language specifier to fenced code blocks (3 places) - Update skill descriptions with new capabilities (background task, Ajv) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
background-task.md: - Fix run() execution timing: task starts immediately, not deferred to after response. Framework waits at Context preDestroy - Fix error log format: no space after colon to match implementation ajv-validate.md: - Fix example file path to match module directory convention - Remove hardcoded 422 status from AjvInvalidParamError description Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- egg/SKILL.md: add ajv/validate/schema keywords to controller routing, add background task to core routing, update quick reference table and protocol/use-case table - egg-core/SKILL.md: add BackgroundTaskHelper to description - egg-controller/SKILL.md: add Ajv/TypeBox validation to description Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add EventBus reference doc to egg-core skill covering usage patterns, common errors, cork/uncork, testing with EventWaiter, and type-safe event declarations. Restructure SKILL.md with "代码组织与依赖注入" and "异步任务" sections, adding BackgroundTaskHelper vs EventBus comparison table. Update entry skill routing for EventBus keywords. Add 7 EventBus eval cases (id 27-33) and 2 routing eval cases. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add AOP reference doc to egg-core skill covering Advice lifecycle, Pointcut vs Crosscut selection, three Crosscut matching modes (CLASS, NAME, CUSTOM), execution order with order parameter, and adviceParams. Update SKILL.md with AOP decision tree and entry skill routing. Add 8 AOP eval cases (id 34-41) and 1 routing eval case. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis PR updates skill documentation paths ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly expands the capabilities of the AI agent skills for the Egg framework by integrating detailed documentation for EventBus and Aspect-Oriented Programming (AOP). It also addresses existing documentation inaccuracies and improves naming conventions, particularly for controller-related skills. The changes aim to provide a more robust and comprehensive knowledge base, enabling the AI agent to offer better guidance on advanced architectural patterns and cross-cutting concerns within Egg applications, all validated through new evaluation scenarios. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## next #5835 +/- ##
=======================================
Coverage 85.62% 85.63%
=======================================
Files 665 665
Lines 13004 13004
Branches 1495 1495
=======================================
+ Hits 11135 11136 +1
+ Misses 1745 1744 -1
Partials 124 124 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/skills/egg-core/SKILL.md (1)
201-212: Add language identifiers to decision tree code blocksThe decision tree blocks at lines 201-212 and 218-224 are missing language identifiers. While these are ASCII-art decision trees (not code), consider adding
textorplaintextas the language identifier for consistency and to satisfy linting rules.✨ Suggested fix for language identifiers
-``` +```text 需要在请求之外执行任务? │ ├─ 请求返回后执行,依赖当前请求上下文-``` +```text 需要在方法执行前后添加通用逻辑? │ ├─ 针对特定方法 → `@Pointcut`(在目标方法上声明)As per coding guidelines, the markdownlint tool flagged these blocks (MD040 rule).
Also applies to: 218-224
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/skills/egg-core/SKILL.md` around lines 201 - 212, The fenced ASCII decision-tree blocks labeled "需要在请求之外执行任务?" and "需要在方法执行前后添加通用逻辑?" in SKILL.md are missing language identifiers; update each triple-backtick fence to use a neutral language tag such as ```text (or ```plaintext) so the blocks are treated as plain text and satisfy markdownlint MD040. Locate the two code fences containing those exact decision-tree snippets and add the language identifier to both fences.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/skills/egg-core/SKILL.md`:
- Around line 201-212: The fenced ASCII decision-tree blocks labeled
"需要在请求之外执行任务?" and "需要在方法执行前后添加通用逻辑?" in SKILL.md are missing language
identifiers; update each triple-backtick fence to use a neutral language tag
such as ```text (or ```plaintext) so the blocks are treated as plain text and
satisfy markdownlint MD040. Locate the two code fences containing those exact
decision-tree snippets and add the language identifier to both fences.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: e6cb1d09-a3f7-4552-a6ce-dc4d2320920c
📒 Files selected for processing (10)
packages/skills/CLAUDE.mdpackages/skills/egg-controller/SKILL.mdpackages/skills/egg-controller/references/ajv-validate.mdpackages/skills/egg-core/SKILL.mdpackages/skills/egg-core/references/aop.mdpackages/skills/egg-core/references/background-task.mdpackages/skills/egg-core/references/eventbus.mdpackages/skills/egg/SKILL.mdpackages/skills/eval/evals-egg-core.jsonpackages/skills/eval/evals-routing.json
There was a problem hiding this comment.
Pull request overview
This PR expands the @eggjs/skills documentation set by adding new EventBus and AOP skill/reference content under egg-core, updating the egg entry skill routing/decision tree accordingly, and extending the evaluation datasets to cover the new topics.
Changes:
- Add new
egg-corereference docs for EventBus and AOP, and updateegg-core/SKILL.mddecision trees to route users to them. - Update the
eggentrySKILL.mdto include new routing keywords/quick tables for EventBus/AOP (and Ajv validation under controller). - Extend eval cases for routing and egg-core to cover EventBus/AOP scenarios; adjust some existing docs for accuracy/wording.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/skills/eval/evals-routing.json | Adds routing eval prompts for EventBus/AOP queries. |
| packages/skills/eval/evals-egg-core.json | Extends egg-core eval coverage to include eventbus + aop scenarios. |
| packages/skills/egg/SKILL.md | Updates entry-skill routing keywords/tables to include EventBus/AOP and controller validation. |
| packages/skills/egg-core/SKILL.md | Restructures sections and adds decision guidance for async tasks (BackgroundTaskHelper vs EventBus) and AOP. |
| packages/skills/egg-core/references/eventbus.md | New EventBus reference guide (typing, handlers, cork/uncork, unittest waiter). |
| packages/skills/egg-core/references/background-task.md | Corrects/clarifies BackgroundTaskHelper execution timing and logging details. |
| packages/skills/egg-core/references/aop.md | New AOP reference guide (Advice/Pointcut/Crosscut/order/adviceParams). |
| packages/skills/egg-controller/references/ajv-validate.md | Small doc refinements (example path + wording). |
| packages/skills/egg-controller/SKILL.md | Expands description to include parameter validation scope. |
| packages/skills/CLAUDE.md | Updates skill-creator references and corrects some structural naming in docs. |
You can also share your feedback on Copilot code review. Take the survey.
- Fix Advice default initType from Context to Singleton (matches code) - Fix cork/uncork example to use declared event name - Add missing OrderService import in test example - Replace ant-skill-creator with /skill-creator in CLAUDE.md Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Deploying egg-v3 with
|
| Latest commit: |
272df43
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://550ec661.egg-v3.pages.dev |
| Branch Preview URL: | https://feat-skills-eventbus-aop.egg-v3.pages.dev |
Deploying egg with
|
| Latest commit: |
272df43
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8f4b4ba0.egg-cci.pages.dev |
| Branch Preview URL: | https://feat-skills-eventbus-aop.egg-cci.pages.dev |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
packages/skills/egg-core/references/aop.md (2)
1-219: Consider adding an end-to-end complete example.While the document provides good code snippets, it lacks a complete end-to-end example showing how all pieces fit together (Advice class, Service class, configuration, and potentially tests). This would help users understand the full integration pattern.
As per coding guidelines, reference documents must include end-to-end complete examples from configuration to controller to service to tests.
🔗 Suggested end-to-end example structure
Add a section showing:
## 完整示例:订单服务事务与日志 ### 1. 定义 Advice(app/aspect/transaction-advice.ts) \`\`\`typescript // Full Advice implementation with transaction logic \`\`\` ### 2. 应用到 Service(app/service/order-service.ts) \`\`\`typescript // Service with `@Pointcut` decorators \`\`\` ### 3. Controller 调用(app/controller/order-controller.ts) \`\`\`typescript // HTTPController calling the service \`\`\` ### 4. 测试(test/app/service/order-service.test.ts) \`\`\`typescript // Test verifying Advice behavior \`\`\` ### 执行流程 1. Controller 接收请求 2. 调用 OrderService.createOrder 3. TransactionAdvice.beforeCall 开启事务 4. 执行业务逻辑 5. TransactionAdvice.afterReturn 提交事务 6. 返回结果🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/skills/egg-core/references/aop.md` around lines 1 - 219, Add a complete end-to-end example section showing configuration-to-test flow: create an Advice file (e.g. app/aspect/TransactionAdvice implementing IAdvice with beforeCall/afterReturn/afterThrow/afterFinally), a Service (e.g. app/service/OrderService with `@Pointcut`(TransactionAdvice) on createOrder), a Controller (e.g. app/controller/OrderController calling OrderService.createOrder), and a test (e.g. test/app/service/order-service.test.ts) that asserts transaction start/commit/rollback behavior; include any minimal config needed to load AOP, note the important symbols (TransactionAdvice, OrderService.createOrder, OrderController, AdviceContext methods like ctx.set/get), and add a short execution flow steps list mapping controller → service → Advice hooks → result so readers can follow the lifecycle.
213-219: Enhance the scenario table into a decision tree.The current "典型场景" table is helpful but doesn't follow the required scenario-based decision tree format. Consider restructuring this section to guide users through a series of questions that lead to the appropriate AOP approach.
As per coding guidelines, reference documents must include scenario-based decision trees.
🌳 Suggested decision tree format
## 场景决策树需要添加切面逻辑?
├─ 是否只针对特定的几个方法?
│ ├─ 是 → 使用@Pointcut
│ │ ├─ 需要传递不同参数?→ 使用 adviceParams
│ │ └─ 需要控制执行顺序?→ 设置 order 参数
│ └─ 否 → 继续判断
│ ├─ 是否针对一类方法(如所有 Service 的写操作)?
│ │ └─ 是 → 使用@Crosscut+ NAME 模式(正则匹配)
│ ├─ 是否需要自定义匹配逻辑?
│ │ └─ 是 → 使用@Crosscut+ CUSTOM 模式
│ └─ 是否针对特定类的所有方法?
│ └─ 是 → 使用@Crosscut+ CLASS 模式
```
你的需求 推荐方案 说明 为 OrderService.createOrder 添加日志 @Pointcut(LogAdvice)精确控制单个方法 所有 Service 的 create*/update*/delete* 方法加审计 @Crosscut(NAME)+ 正则批量匹配写操作 特定方法需要事务包裹 @Pointcut(TransactionAdvice)使用 around 管理事务 所有 Repository 方法监控性能 @Crosscut(CUSTOM)+ 回调自定义匹配逻辑 </details> <details> <summary>🤖 Prompt for AI Agents</summary>Verify each finding against the current code and only fix it if needed.
In
@packages/skills/egg-core/references/aop.mdaround lines 213 - 219, Replace
the existing "典型场景" table with a scenario-based decision tree titled "场景决策树"
that guides readers through questions to choose between@Pointcutand@Crosscut
variants; specifically, ask "是否只针对特定的几个方法?" → yes: use@Pointcut(Advice) and
mention adviceParams and order for parameter passing and execution order (e.g.,
LogAdvice, TransactionAdvice), otherwise continue to ask if it's a class-wide or
pattern-based match → use@Crosscut(NAME) for regex pattern matching (e.g.,
matching create*/update*/delete*),@Crosscut(CUSTOM) for custom matcher
callbacks, and@Crosscut(CLASS) for all methods on a class; after the tree, add
a compact mapping table of example needs to recommended solutions referencing
@Pointcut(LogAdvice),@Pointcut(TransactionAdvice),@Crosscut(NAME), and
@Crosscut(CUSTOM) to make choices concrete.</details> </blockquote></details> </blockquote></details> <details> <summary>🤖 Prompt for all review comments with AI agents</summary>Verify each finding against the current code and only fix it if needed.
Inline comments:
In@packages/skills/egg-core/references/aop.md:
- Line 15: Add a new "文件约定" section before the existing "核心概念" header that
documents where Advice classes live and naming rules: state that Advice classes
should be placed under app/aspect/, each Advice in its own file using kebab-case
(e.g. log-advice.ts, transaction-advice.ts), include a short directory structure
example showing app/aspect/ alongside app/service/, and note that Advice is
auto-scanned by the framework (no manual registration in config required);
reference the "核心概念" header so the new section is inserted immediately above it
and mention "Advice" and "app/aspect" explicitly to guide readers.
Nitpick comments:
In@packages/skills/egg-core/references/aop.md:
- Around line 1-219: Add a complete end-to-end example section showing
configuration-to-test flow: create an Advice file (e.g.
app/aspect/TransactionAdvice implementing IAdvice with
beforeCall/afterReturn/afterThrow/afterFinally), a Service (e.g.
app/service/OrderService with@Pointcut(TransactionAdvice) on createOrder), a
Controller (e.g. app/controller/OrderController calling
OrderService.createOrder), and a test (e.g.
test/app/service/order-service.test.ts) that asserts transaction
start/commit/rollback behavior; include any minimal config needed to load AOP,
note the important symbols (TransactionAdvice, OrderService.createOrder,
OrderController, AdviceContext methods like ctx.set/get), and add a short
execution flow steps list mapping controller → service → Advice hooks → result
so readers can follow the lifecycle.- Around line 213-219: Replace the existing "典型场景" table with a scenario-based
decision tree titled "场景决策树" that guides readers through questions to choose
between@Pointcutand@Crosscutvariants; specifically, ask "是否只针对特定的几个方法?" →
yes: use@Pointcut(Advice) and mention adviceParams and order for parameter
passing and execution order (e.g., LogAdvice, TransactionAdvice), otherwise
continue to ask if it's a class-wide or pattern-based match → use
@Crosscut(NAME) for regex pattern matching (e.g., matching
create*/update*/delete*),@Crosscut(CUSTOM) for custom matcher callbacks, and
@Crosscut(CLASS) for all methods on a class; after the tree, add a compact
mapping table of example needs to recommended solutions referencing
@Pointcut(LogAdvice),@Pointcut(TransactionAdvice),@Crosscut(NAME), and
@Crosscut(CUSTOM) to make choices concrete.</details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: defaults **Review profile**: CHILL **Plan**: Pro **Run ID**: `448907fe-29c1-44cc-ae71-8481f01e274e` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 87e941c37f87bf78e0344dc9ff41163b7e7b859d and 272df435bb30ad7d90f3852c4c9f4f5c383f3bc1. </details> <details> <summary>📒 Files selected for processing (3)</summary> * `packages/skills/CLAUDE.md` * `packages/skills/egg-core/references/aop.md` * `packages/skills/egg-core/references/eventbus.md` </details> <details> <summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary> * packages/skills/egg-core/references/eventbus.md </details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
|
|
||
| --- | ||
|
|
||
| ## 核心概念 |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
Add file conventions section.
The document is missing a section on file conventions (directory structure, naming rules, configuration file locations). Reference documents must include guidance on where Advice classes should be placed in the project structure.
As per coding guidelines, reference documents must include file conventions.
📁 Suggested file conventions section to add
Add a section before "核心概念" covering:
## 文件约定
### 目录结构
- Advice 类建议放在 `app/aspect/` 目录
- 文件命名:kebab-case,如 `log-advice.ts`, `transaction-advice.ts`
- 每个 Advice 一个文件
示例结构:
\`\`\`
app/
├── aspect/
│ ├── log-advice.ts
│ ├── transaction-advice.ts
│ └── cache-advice.ts
├── service/
│ └── order-service.ts
\`\`\`
### 配置
Advice 会自动被框架扫描加载,无需在配置文件中注册。🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/skills/egg-core/references/aop.md` at line 15, Add a new "文件约定"
section before the existing "核心概念" header that documents where Advice classes
live and naming rules: state that Advice classes should be placed under
app/aspect/, each Advice in its own file using kebab-case (e.g. log-advice.ts,
transaction-advice.ts), include a short directory structure example showing
app/aspect/ alongside app/service/, and note that Advice is auto-scanned by the
framework (no manual registration in config required); reference the "核心概念"
header so the new section is inserted immediately above it and mention "Advice"
and "app/aspect" explicitly to guide readers.
Summary
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
Documentation
New Features