airweave / rules
Cursor rule6.6k starsChanged 8 months agoMITArchived repositoryView on GitHub
AST Extraction Process: 1. Parse decorator arguments positionally and by keyword 2. Fall back to class attributes (_auth_type, _config_class) 3. Last resort: regex pattern matching in raw source
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 1,531 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository22 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- .cursor/rules/airweave-overview.mdcCursor rule
- .cursor/rules/api-layer.mdcCursor rule
- .cursor/rules/arf.mdcCursor rule
- .cursor/rules/auth-providers.mdcCursor rule
- .cursor/rules/backend-rules.mdcCursor rule
- .cursor/rules/connector-cursors.mdcCursor rule
- .cursor/rules/connector-development-end-to-end.mdcCursor rule
- .cursor/rules/connect-widget.mdcCursor rule
- .cursor/rules/crud-layer.mdcCursor rule
- .cursor/rules/feature-flags.mdcCursor rule
- .cursor/rules/form-validation.mdcCursor rule
- .cursor/rules/frontend-rules.mdcCursor rule
- .cursor/rules/integrations-yaml.mdcCursor rule
- .cursor/rules/mcp-server.mdcCursor rule
- .cursor/rules/monke.mdcCursor rule
- .cursor/rules/monke-testing-guide.mdcCursor rule
- .cursor/rules/search-module.mdcCursor rule
- .cursor/rules/source-connector-implementation.mdcCursor rule
- .cursor/rules/stripe-billing.mdcCursor rule
- .cursor/rules/sync-architecture.mdcCursor rule
- .cursor/rules/token-provider-exceptions.mdcCursor rule
The file
We split this fern-docs-generation.mdc into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 76
Class attribute fallback: Check ast.Assign nodes
- Very specific: line 87
Check oauth_type field presence
≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
---
globs: **/fern/**
alwaysApply: false
---
# Fern Documentation Generation System - Internal Guide
## Overview
The custom internal Fern documentation generator automatically creates MDX documentation for Airweave connectors by introspecting Python source code using AST (Abstract Syntax Tree) parsing.
## Architecture Flow
### 1. Discovery Phase
**Entry:** `update_connector_docs/__main__.py:main()`
- Scans `backend/airweave/platform/sources/` directory
- Identifies all `.py` files as potential connectors
- Example: `asana.py`, `slack.py`, `google_drive.py`
### 2. Parsing Phase
#### Source Parser (`source_parser.py`)
Extracts metadata from `@source` decorator:
```python
@source(
name="Asana", # Display name
short_name="asana", # File/URL identifier
auth_methods=[...], # Auth methods list
oauth_type=OAuthType.WITH_REFRESH, # OAuth type enum
auth_config_class="AsanaConfig", # String reference to config
config_class="AsanaConfig", # Source-specific config
labels=["Project Management"] # Categories
)
```
**AST Extraction Process:**
1. Parse decorator arguments positionally and by keyword
2. Fall back to class attributes (`_auth_type`, `_config_class`)
3. Last resort: regex pattern matching in raw source
#### Entity Parser (`entity_parser.py`)
- Scans `platform/entities/{connector_name}.py`
- Extracts entity classes and their field definitions
- Builds entity hierarchy for documentation
#### Auth/Config Parsers
- `auth_parser.py`: Maps auth config class names to their field definitions
- `config_parser.py`: Maps source config classes to their field requirements
### 3. Generation Phase
#### MDX Generator (`mdx_generator.py`)
Creates structured MDX with:
- **Header**: Icon + connector name
- **Configuration**: Source docstring description
- **Authentication**:
- OAuth flows (managed vs BYOC)
- Direct auth field requirements
- **Source Config**: Additional configuration fields
- **Entity Schema**: Data structure documentation
### 4. Output Phase
- Creates/updates `fern/docs/pages/connectors/{name}/main.mdx`
- Copies icon from `frontend/public/icons/`
- Updates `docs.yml` navigation structure
## Key Components
### Decorator Metadata (`platform/decorators.py`)
The `@source` decorator sets class attributes:
- `_is_source = True` (marker)
- `_name`, `_short_name` (identification)
- `_auth_methods`, `_oauth_type` (auth config)
- `_auth_config_class`, `_config_class` (config references)
### AST Parsing Strategy
1. **Direct decorator parsing**: Extract from `ast.Call` nodes
2. **Class attribute fallback**: Check `ast.Assign` nodes
3. **Regex fallback**: Pattern match in raw source text
### MDX Special Handling
- Escapes `<` and `>` to prevent JSX interpretation
- Uses HTML entities for safe rendering
- Preserves curly braces using string concatenation
## Configuration Resolution
### OAuth Detection
- Check `oauth_type` field presence
- Determine BYOC by inheritance chain:
- Direct: `OAuth2BYOCAuthConfig`
- Inherited: Parent/grandparent check
### Field Documentation
- Primary: Field's own description
- Fallback: Parent class field description
- Default: "No description"
## File Structure
```
fern/
├── scripts/
│ └── update_connector_docs/
│ ├── __main__.py # Entry point
│ ├── constants.py # Path definitions
│ ├── parsers/
│ │ ├── source_parser.py # AST parsing
│ │ ├── entity_parser.py # Entity extraction
│ │ ├── auth_parser.py # Auth config mapping
│ │ └── config_parser.py # Source config mapping
│ ├── generators/
│ │ └── mdx_generator.py # MDX creation
│ └── utils/
│ └── file_utils.py # File operations
└── docs/
└── pages/
└── connectors/
└── {connector_name}/
├── icon.svg
└── main.mdx
```
## Execution
```bash
cd fern/scripts
python update_connector_docs.py
```
Processes all sources, generates MDX, updates navigation.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

