docs(backend): translate AGENT.md to English and fix formatting#7870
docs(backend): translate AGENT.md to English and fix formatting#7870Amartuvshins0404 wants to merge 9 commits into
Conversation
- Translate all Mongolian descriptions to English - Fix import alias examples (~/, @/) - Convert tRPC example to fenced code block - Add missing startPlugin() bootstrap contract documentation - Address AI reviewer feedback from PR erxes#7857
Reviewer's GuideDocuments backend plugin conventions in AGENT.md in English, clarifies import aliases and gateway registration, adds concrete tRPC usage and pagination rules, and documents the required startPlugin() bootstrap contract for backend plugins. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds comprehensive backend plugin development documentation: bootstrap/startPlugin contract, Mongoose/model rules, GraphQL schema/resolver and pagination conventions, tRPC/Express wiring, import/export and worker patterns, inter-plugin messaging, migration rules, import aliasing, and a mandatory RULES.md. ChangesBackend Plugin Development Guidelines
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="backend/plugins/AGENT.md" line_range="19" />
<code_context>
+
+## Join Gateway
+
+Provide the plugin name and the port it runs on. This information is stored from the plugin to Redis, and the gateway and other plugins retrieve it from Redis.
+
+## Imports
</code_context>
<issue_to_address>
**suggestion (typo):** Clarify the Redis sentence by fixing the preposition usage.
“Stored from the plugin to Redis” is awkward. Please rephrase, e.g.: “This information is stored by the plugin in Redis, and the gateway and other plugins retrieve it from Redis.”
```suggestion
Provide the plugin name and the port it runs on. This information is stored by the plugin in Redis, and the gateway and other plugins retrieve it from Redis.
```
</issue_to_address>
### Comment 2
<location path="backend/plugins/AGENT.md" line_range="60" />
<code_context>
+
+## Pagination
+
+When calling a list, you must always return `totalCount` and `pageInfo` in addition to the list data.
+Use the `cursorPaginate` function for all lists.
+
</code_context>
<issue_to_address>
**suggestion (typo):** Consider rephrasing "calling a list" for improved clarity.
You could use alternatives like “When returning a list” or “When fetching a list” to better reflect the behavior without changing the meaning.
```suggestion
When returning a list, you must always return `totalCount` and `pageInfo` in addition to the list data.
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/plugins/AGENT.md`:
- Around line 70-75: The docs incorrectly state plugins should export a
startPlugin() function that returns { graphql, expressRouter, trpcAppRouter,
meta }; instead, update the wording to match actual wiring: plugins must call
startPlugin({ graphql, expressRouter, trpcAppRouter, meta }) from their
entrypoint (as used in main.ts) — mention the exact call signature
startPlugin({...}) and the required config fields graphql, expressRouter,
trpcAppRouter and meta so authors implement the correct entrypoint pattern.
- Line 30: Replace the invalid Apollo Federation snippet "(keyfield: \"_id\")"
with the proper `@key` directive syntax: instruct using `@key`(fields: "_id") on the
entity type (for example "type User `@key`(fields: \"_id\") { _id: ID! ... }") and
mention that for Federation 2+ the `@key` must be available via `@link`; update the
line that currently reads `When defining a schema, you must declare (keyfield:
"_id").` to reference the correct `@key`(fields: "_id") usage and the example
entity form.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
- Replace invalid (keyfield: "_id") with proper @key(fields: "_id") directive - Fix startPlugin() contract: plugins call startPlugin({...}) from entrypoint, not export a function that returns an object - Address CodeRabbit feedback from PR erxes#7870
- Add detailed project structure with file-level explanations - Document startPlugin() configuration with all optional fields - Add complete Database layer guide: schemas, models, types, connectionResolvers - Add GraphQL layer guide: schema definitions, aggregation, typeDefs, resolvers, pagination - Add tRPC layer guide with router initialization pattern - Add Express routes guide - Add Meta system guide: permissions, notifications, tags, properties - Add Import/Export system guide - Add Background Workers guide with BullMQ patterns - Add Inter-Plugin Communication guide - Add Migrations guide - Add Import aliases and development rules with checklists - Include port allocation table for all existing plugins - Include package.json template
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/plugins/AGENT.md`:
- Around line 810-835: The import rule forbids relative imports in the "Rules"
section but several examples in the same document use relative imports; fix by
making the document consistent: either relax the rule text ("Prefer absolute
imports; relative imports allowed in examples") or change all example import
statements to use absolute aliases (`~/`, `@/`) so they comply; update the
“Rules: - Always use absolute paths” line and the conflicting example import
blocks so the prohibition and examples (the example import lines earlier in the
doc) match exactly.
- Line 27: The fenced directory-tree block starting with "```" that contains
"plugin_name_api/" should include a language tag to satisfy markdownlint MD040
and improve rendering; update the opening fence from ``` to ```text (i.e.,
change the code fence that precedes the directory tree to ```text) so the block
becomes a text-fenced block and keep the closing fence as ``` unchanged.
- Around line 769-771: The migration example uses an empty string for
generateModels(''), which will fail in SaaS because generateModels requires a
valid non-empty subdomain; update the migrateTasks function to supply a real
subdomain (or accept one as a parameter) and document it: change migrateTasks to
call generateModels with a proper subdomain value (or add a function parameter
like subdomain and pass it through to generateModels) and ensure any calling
code or README explains the required subdomain format so the example works in
the SaaS flow.
- Around line 134-141: The example defines the onServerInit key twice which
causes the first definition to be overridden; merge the duplicate into a single
async onServerInit function that accepts the app parameter and performs both
initialization tasks (e.g. initialize external services/websockets using the app
arg and then call await initMQWorkers(redis)); update the example to show both
responsibilities in one onServerInit and keep the background worker comment so
plugin authors don’t accidentally drop initialization logic.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
- Move Must Do / Must Not Do rules, port table, and package.json template from AGENT.md into new rules/RULES.md file - Update AGENT.md to reference rules/RULES.md instead of inline content - Keep AGENT.md focused on architecture and patterns guidance
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/plugins/rules/RULES.md`:
- Line 11: Update the checklist item that currently reads "[ ] Index frequently
queried fields and all `_id` fields" by removing the "_id" portion so it reads
"[ ] Index frequently queried fields"; leave the rest of the checklist untouched
and ensure no other references to indexing `_id` remain in RULES.md to avoid
prompting redundant index creation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2c7d5c29-6f7d-40ab-a944-70f668feecee
📒 Files selected for processing (2)
backend/plugins/AGENT.mdbackend/plugins/rules/RULES.md
| - [ ] Register plugin name in `.env` to enable it | ||
| - [ ] Prefix collection names with plugin name (e.g., `operation_tasks`, `frontline_conversations`) | ||
| - [ ] Set `timestamps: true` on all Mongoose schemas | ||
| - [ ] Index frequently queried fields and all `_id` fields |
There was a problem hiding this comment.
Remove the _id indexing requirement from the checklist.
_id is already indexed by default in MongoDB collections, so this rule is misleading and may prompt redundant index definitions. Keep the “frequently queried fields” guidance, but drop “and all _id fields”.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@backend/plugins/rules/RULES.md` at line 11, Update the checklist item that
currently reads "[ ] Index frequently queried fields and all `_id` fields" by
removing the "_id" portion so it reads "[ ] Index frequently queried fields";
leave the rest of the checklist untouched and ensure no other references to
indexing `_id` remain in RULES.md to avoid prompting redundant index creation.
- Add text language tag to directory tree code fence (MD040) - Merge duplicate onServerInit keys into single hook in startPlugin example - Fix migration example to accept subdomain parameter instead of empty string
Replace xiaoju111a/kimi-actions with howardpen9/kimi-code-reviewer which: - Fixes checkout failures on fork PRs (no manual ref fetching needed) - Uses TypeScript instead of Docker (faster startup) - Provides inline annotations via GitHub Checks API - Supports prefix caching for lower costs - Adds configurable .kimi-review.yml support Also update model to kimi-k2.6 and add checks:write permission.
This file was not part of the AGENT.md documentation changes and should not be included in this PR.
|
|
I'll analyze this and get back to you. |




Summary
Translates the backend plugin AGENT.md documentation from Mongolian to English and addresses all AI reviewer feedback from PR #7857.
Changes
startPlugin()bootstrap export documentation with expected return shape (graphql, expressRouter, trpcAppRouter, meta)Related
Type: Documentation
Scope: backend/plugins/AGENT.md
Summary by Sourcery
Documentation:
Summary by CodeRabbit