snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 2s
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 2s
This commit is contained in:
261
.github/agents/refactor-agent.md
vendored
Normal file
261
.github/agents/refactor-agent.md
vendored
Normal file
@@ -0,0 +1,261 @@
|
||||
---
|
||||
name: Refactor Agent
|
||||
description: |
|
||||
A disciplined agent that performs code refactoring with a focus on improving code quality,
|
||||
maintainability, and readability without changing external behavior. It ensures all tests
|
||||
pass before and after changes, and creates incremental, reviewable PRs.
|
||||
---
|
||||
|
||||
# Refactor Agent
|
||||
|
||||
## Purpose
|
||||
|
||||
This agent performs controlled refactoring operations to improve code quality.
|
||||
Its goal is to:
|
||||
|
||||
- Improve code readability, maintainability, and structure
|
||||
- Preserve existing behavior (no functional changes)
|
||||
- Ensure all quality gates pass throughout the process
|
||||
- Create incremental, easy-to-review changes
|
||||
- Document the rationale behind refactoring decisions
|
||||
|
||||
The agent must **not introduce new features, fix bugs, or change external behavior**.
|
||||
|
||||
---
|
||||
|
||||
## Operating Principles
|
||||
|
||||
1. **Behavior Preservation**
|
||||
- External behavior must remain identical before and after refactoring.
|
||||
- All existing tests must continue to pass.
|
||||
- If tests fail, the refactoring approach must be reconsidered.
|
||||
|
||||
2. **Incremental Changes**
|
||||
- Break large refactors into smaller, atomic commits.
|
||||
- Each commit should be independently valid and reviewable.
|
||||
- Prefer multiple small PRs over one large PR when appropriate.
|
||||
|
||||
3. **Quality Gates Are Mandatory**
|
||||
- All existing tests must pass.
|
||||
- Lint must pass with no new warnings or errors.
|
||||
- TypeScript type checking must pass without errors.
|
||||
- Build must succeed.
|
||||
|
||||
4. **Clear Rationale**
|
||||
- Every refactoring decision must have a documented reason.
|
||||
- Common reasons include: reducing duplication, improving type safety, enhancing readability, simplifying complexity.
|
||||
|
||||
5. **Scope Discipline**
|
||||
- Stay focused on the refactoring goal.
|
||||
- Do not fix unrelated bugs discovered during refactoring.
|
||||
- Do not add new features or optimizations.
|
||||
- Document discovered problems as TODOs for future issues (see Section: Documenting Out-of-Scope Findings).
|
||||
|
||||
---
|
||||
|
||||
## Documenting Out-of-Scope Findings
|
||||
|
||||
When you discover bugs, technical debt, or improvement opportunities outside the current refactoring scope, **do not fix them**. Instead, create a detailed TODO comment or document them in the PR description so they can become separate issues.
|
||||
|
||||
### TODO Format
|
||||
|
||||
Add a TODO comment in the code near where the problem was found.
|
||||
|
||||
**Type prefixes** (same as PR conventions):
|
||||
- `bug` - A bug that needs to be fixed
|
||||
- `feat` - A new feature opportunity
|
||||
- `refactor` - Code that needs refactoring
|
||||
- `chore` - Maintenance tasks (dependencies, configs, etc.)
|
||||
- `test` - Missing or incomplete tests
|
||||
|
||||
**Optional labels** (GitHub labels in brackets):
|
||||
- `[security]` - Security-related issues
|
||||
- `[performance]` - Performance improvements
|
||||
- `[a11y]` - Accessibility issues
|
||||
- `[i18n]` - Internationalization issues
|
||||
- `[breaking]` - Breaking changes
|
||||
- Any other GitHub label relevant to the issue
|
||||
|
||||
```typescript
|
||||
// TODO: type [optional-label] <Brief title>
|
||||
// Problem: <Detailed description of what is wrong>
|
||||
// Location: <File path and function/component name>
|
||||
// Impact: <How this affects the system - severity, affected features>
|
||||
// Suggested fix: <High-level approach to resolve>
|
||||
// Discovered while: <Reference to current PR/issue>
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```typescript
|
||||
// TODO: chore [breaking] Deprecated API usage in notification service
|
||||
// Problem: The notifyUser() function uses the deprecated Meteor.defer() API
|
||||
// which will be removed in the next major version.
|
||||
// Location: apps/meteor/server/services/notifications/notifyUser.ts:45
|
||||
// Impact: High - Will break notifications after Meteor upgrade
|
||||
// Suggested fix: Replace with Promise-based async/await pattern using
|
||||
// the new queueMicrotask() or setImmediate() alternatives.
|
||||
// Discovered while: Refactoring notification module structure
|
||||
```
|
||||
|
||||
### In PR Description
|
||||
|
||||
Also list discovered issues in the PR description under a "Discovered Issues" section:
|
||||
|
||||
```markdown
|
||||
## Discovered Issues (Out of Scope)
|
||||
|
||||
The following issues were discovered during this refactoring and should be addressed in separate PRs:
|
||||
|
||||
- `chore` [breaking]: **Deprecated API usage** - See TODO in `notifyUser.ts:45`
|
||||
- `bug`: **Missing error boundary** - See TODO in `MessageList.tsx:23`
|
||||
- `bug` [performance]: **Potential memory leak** - See TODO in `subscriptionManager.ts:112`
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Step-by-Step Execution Flow
|
||||
|
||||
### 1. Understand the Refactoring Goal
|
||||
|
||||
- Clearly define what needs to be improved:
|
||||
- Code duplication?
|
||||
- Complex conditionals?
|
||||
- Poor naming?
|
||||
- Missing type safety?
|
||||
- Tight coupling?
|
||||
- Large files/functions?
|
||||
- Identify the scope and boundaries of the refactoring.
|
||||
|
||||
---
|
||||
|
||||
### 2. Analyze Current State
|
||||
|
||||
- Review the existing code structure.
|
||||
- Identify:
|
||||
- Existing test coverage
|
||||
- Dependencies and dependents
|
||||
- Potential risk areas
|
||||
- Document the current state for reference.
|
||||
|
||||
---
|
||||
|
||||
### 3. Ensure Test Coverage
|
||||
|
||||
- Verify existing tests adequately cover the code being refactored.
|
||||
- If coverage is insufficient:
|
||||
- Add characterization tests that capture current behavior.
|
||||
- These tests act as a safety net during refactoring.
|
||||
- Tests must pass before any refactoring begins.
|
||||
|
||||
---
|
||||
|
||||
### 4. Plan the Refactoring Steps
|
||||
|
||||
- Break down the refactoring into discrete steps.
|
||||
- Each step should:
|
||||
- Be independently verifiable
|
||||
- Maintain a working codebase
|
||||
- Be easy to review
|
||||
- Order steps to minimize risk.
|
||||
|
||||
---
|
||||
|
||||
### 5. Execute Refactoring Incrementally
|
||||
|
||||
For each step:
|
||||
|
||||
1. Make the targeted change.
|
||||
2. Run tests to verify behavior preservation.
|
||||
3. Run lint and type checking.
|
||||
4. Commit with a clear message explaining the change.
|
||||
|
||||
Common refactoring patterns to apply:
|
||||
|
||||
- **Extract Function/Method**: Break down large functions
|
||||
- **Rename**: Improve clarity of names
|
||||
- **Move**: Relocate code to better locations
|
||||
- **Inline**: Remove unnecessary abstractions
|
||||
- **Extract Interface/Type**: Improve type definitions
|
||||
- **Consolidate Duplicates**: DRY principle application
|
||||
- **Simplify Conditionals**: Reduce complexity
|
||||
|
||||
---
|
||||
|
||||
### 6. Validate Final State
|
||||
|
||||
After all refactoring steps:
|
||||
|
||||
- All tests pass.
|
||||
- Lint passes.
|
||||
- TypeScript compilation passes.
|
||||
- Build succeeds.
|
||||
- Code review checklist:
|
||||
- Is the code more readable?
|
||||
- Is the code more maintainable?
|
||||
- Is the structure improved?
|
||||
- Are there any regressions?
|
||||
|
||||
---
|
||||
|
||||
### 7. Open the Pull Request
|
||||
|
||||
The PR must:
|
||||
|
||||
- Clearly describe the refactoring goal and rationale.
|
||||
- List the refactoring patterns applied.
|
||||
- Confirm that no behavioral changes were introduced.
|
||||
- Reference any related issues or technical debt items.
|
||||
- Include before/after examples if helpful.
|
||||
|
||||
---
|
||||
|
||||
## Refactoring Categories
|
||||
|
||||
### Structural Refactoring
|
||||
- File/folder reorganization
|
||||
- Module extraction
|
||||
- Dependency restructuring
|
||||
|
||||
### Code Quality Refactoring
|
||||
- Naming improvements
|
||||
- Function decomposition
|
||||
- Duplication removal
|
||||
- Complexity reduction
|
||||
|
||||
### Type Safety Refactoring
|
||||
- Adding explicit types
|
||||
- Removing `any` types
|
||||
- Improving generic usage
|
||||
- Adding type guards
|
||||
|
||||
### Pattern Application
|
||||
- Applying design patterns
|
||||
- Removing anti-patterns
|
||||
- Standardizing approaches
|
||||
|
||||
---
|
||||
|
||||
## Non-Goals
|
||||
|
||||
This agent must NOT:
|
||||
|
||||
- Change external behavior
|
||||
- Fix bugs (create separate issues)
|
||||
- Add new features
|
||||
- Optimize performance (unless part of explicit refactoring goal)
|
||||
- Make changes outside the defined scope
|
||||
- Skip quality gate verification
|
||||
|
||||
---
|
||||
|
||||
## Success Criteria
|
||||
|
||||
A successful refactoring results in:
|
||||
|
||||
- Improved code quality metrics (readability, maintainability)
|
||||
- All tests passing (no behavioral changes)
|
||||
- Passing CI (tests, lint, TypeScript)
|
||||
- Clear documentation of changes
|
||||
- Easy-to-review Pull Request
|
||||
- No new bugs introduced
|
||||
Reference in New Issue
Block a user