feat(flutter-cursor-templates): introduce MCP integration and conventions in project brief

- Added optional MCP integration settings in project-brief.yaml, allowing for environment-based server configurations.
- Introduced conventions for strict package imports to enhance code organization and maintainability.
- Updated brief schema to validate new MCP properties and ensure correct usage.
- Implemented MCP JSON builder to generate .cursor/mcp.json based on project brief settings.
- Enhanced resolver to include MCP configuration in generated files when enabled.

This update improves integration capabilities and enforces coding standards across the project.
This commit is contained in:
2026-05-14 13:33:13 +05:30
parent 2ee257c630
commit da64f769da
109 changed files with 2076 additions and 85 deletions
@@ -0,0 +1,29 @@
---
description: CI/CD, flavours, and quality gates for {{PROJECT_NAME}}
globs: [".github/**", "codemagic.yaml", "Makefile", "pubspec.yaml", "fastlane/**"]
alwaysApply: false
---
# CI/CD & flavours — {{PROJECT_NAME}}
## Context
Pipeline and flavour setup must stay aligned with how the app is built and released.
## Flavours
- Documented in `project-brief.yaml`: **{{FLAVORS_LIST}}**
- Use `--flavor` / `-t lib/main_<flavour>.dart` (or your projects entrypoints) consistently across local, CI, and store builds
- Configuration via `--dart-define` / `--dart-define-from-file` — **never** hardcode secrets in source
## Quality gates (recommended stages)
- **Lint:** `dart format --set-exit-if-changed .` and `flutter analyze`
- **Unit + widget:** `flutter test` (with coverage if the team tracks it)
- **Goldens:** fixed device/locale; CI fails on drift unless intentionally updated
- **Smoke build:** e.g. `flutter build apk` or `flutter build ios --no-codesign` for the primary flavour
- **E2E:** when `testing.depth` includes e2e — {{E2E_TOOL}} on CI devices or Firebase Test Lab
## Cursor integration
- After substantive edits: run analyze and relevant tests before PR
- For release-oriented tasks, use the **deploy** skill at `.cursor/skills/deploy/SKILL.md` when present
## CI/CD tool
- Selected in brief: **{{CICD_TOOL}}** (`{{CICD_RAW}}`)
@@ -0,0 +1,21 @@
---
description: "Feature module {{FEATURE_MODULE}} — contracts, boundaries, and ownership (fill after design)"
globs: ["lib/**/{{FEATURE_MODULE}}/**", "test/**/{{FEATURE_MODULE}}/**"]
alwaysApply: false
---
# Feature — {{FEATURE_MODULE_TITLE}}
## Context
This stub was generated from `features.modules` in `project-brief.yaml`. Use it to capture **public contracts** (routes, DTOs, events) and **dependencies** for `{{FEATURE_MODULE}}` so agents do not invent cross-feature wiring.
## Constraints
- List external dependencies (other features, packages, backend endpoints) explicitly
- Document invariants (auth required, idempotency, offline behavior) when known
- Update or delete this file when the module is removed or renamed — run `bash tool/cursor_audit.sh` to catch drift
## Patterns
- Link to key entry points: primary screen(s), state holder(s), repository interface(s)
## Anti-patterns
- Empty file left forever — either fill it or delete the module entry from the brief
@@ -1,6 +1,7 @@
---
description: "Localization / i18n conventions for {{PROJECT_NAME}}"
alwaysApply: true
globs: ["lib/l10n/**", "lib/**/*.dart", "test/**/*.dart"]
alwaysApply: false
---
# Localization Standards — {{PROJECT_NAME}}
@@ -0,0 +1,21 @@
---
description: Push notifications and deep linking for {{PROJECT_NAME}}
globs: ["lib/**/*.dart", "android/**", "ios/**", "test/**/*.dart"]
alwaysApply: false
---
# Push & deep linking — {{PROJECT_NAME}}
## Context
Special capabilities from `project-brief.yaml`: **{{SPECIAL_FEATURES}}**. Native and server configuration must stay consistent.
## Constraints
- **Push:** request permissions through the platform flow; handle denial gracefully; no silent failures on token registration
- **Routing:** deep links and notification taps MUST go through **{{ROUTING}}** (no ad-hoc `Navigator` stacks for inbound links)
- **Payloads:** map FCM/APNs/Supabase payloads to domain models in the data layer — no JSON parsing scattered in widgets
- **iOS:** exercise push on a **physical device** when possible (simulator limitations)
- **Android:** declare required permissions explicitly; target API behaviour for POST_NOTIFICATIONS where applicable
## Testing
- Unit-test payload → domain mapping and routing targets
- Integration/E2E: cold start, background, and foreground tap-to-open flows when `testing.depth` allows
@@ -0,0 +1,19 @@
---
description: "Policy for optional local AI usage logs under .cursor/telemetry/"
globs: [".cursor/telemetry/**"]
alwaysApply: false
---
# Telemetry — {{PROJECT_NAME}}
## Context
When `telemetry_opt_in: true`, this repo may record **local-only** generation or usage notes under `.cursor/telemetry/`. This is **not** production analytics.
## Constraints
- **Never** commit secrets, tokens, or PII into JSONL or shell history
- Prefer redacted summaries over raw prompts
- Add `.cursor/telemetry/*.jsonl` to `.gitignore` unless your team explicitly version-controls sanitized samples
## Patterns
- Append one JSON object per line (JSONL) with ISO timestamps and event type
- Rotate or truncate files if they grow beyond a few MB
@@ -0,0 +1,20 @@
---
description: Semantic colours and theme extensions for {{PROJECT_NAME}}
globs: ["lib/**/*.dart", "test/**/*.dart"]
alwaysApply: false
---
# Theming — {{PROJECT_NAME}}
## Context
Theme variants from brief: **{{THEME_SUMMARY}}**.{{HIGH_CONTRAST_NOTE}}
## Constraints
- Prefer **`ThemeExtension`** (or design-system equivalents) for app-specific colours and radii — avoid raw `Color(0xFF...)` in feature code except in central token definitions
- Use **`Theme.of(context).colorScheme`** / `TextTheme` for Material-aligned roles where appropriate
- **High contrast:** when supported, verify WCAG contrast for text and controls; never rely on colour alone for state (pair with icon or label){{HIGH_CONTRAST_UX_LINE}}
- Touch targets: respect platform minimums (e.g. ~48 logical pixels) for interactive widgets
## Anti-patterns
- Hard-coded `Colors.*` scattered across feature widgets instead of theme tokens
- Ignoring `MediaQuery.of(context).platformBrightness` / high-contrast modes when the product claims support
@@ -1,6 +1,7 @@
---
description: "Core Flutter conventions for {{PROJECT_NAME}} — always applied"
alwaysApply: true
description: "Core Flutter conventions for {{PROJECT_NAME}}"
globs: ["lib/**/*.dart", "test/**/*.dart", "integration_test/**/*.dart"]
alwaysApply: false
---
# Flutter Core Standards — {{PROJECT_NAME}}
@@ -29,10 +30,7 @@ alwaysApply: true
- Private members: `_camelCase`
## Imports
- Order: dart: → package: → relative
- Use relative imports within a feature; absolute for cross-feature
- Never import a feature's internal files from outside that feature
{{IMPORT_POLICY_BLOCK}}
## Code quality
- Max function length: 40 lines. Extract widgets and helpers aggressively
- No `print()` in production code — use a logging package
@@ -1,6 +1,7 @@
---
description: "Project context for {{PROJECT_NAME}} — always applied"
alwaysApply: true
description: "Stack summary and product context for {{PROJECT_NAME}}"
globs: ["project-brief.yaml", ".cursor/**/*.md", ".cursor/**/*.mdc", "pubspec.yaml"]
alwaysApply: false
---
# Project Context — {{PROJECT_NAME}}
@@ -0,0 +1,24 @@
---
description: How Cursor rules in this repository must be written and maintained.
globs: [".cursor/rules/**/*.mdc"]
alwaysApply: true
---
# Rule authoring — {{PROJECT_NAME}}
## Context
Rules are version-controlled contracts for AI assistants. Poor rules waste context and silently steer every edit.
## Constraints
- One focused concern per file; split broad topics instead of one mega-rule
- Every rule MUST have a clear `description` in frontmatter (one sentence)
- Prefer `alwaysApply: false` with **narrow** `globs` for domain rules — reserve `alwaysApply: true` for meta and safety
- `globs` must be as specific as possible — never `["**/*"]` unless tooling requires it
- Code samples in rules MUST be valid for this project (Dart/Flutter/YAML as appropriate)
- Deprecated guidance is removed, not left commented out
- Each substantive rule includes **Context** (why), **Constraints** (must/must not), and where helpful **Patterns** / **Anti-patterns**
## Anti-patterns
- Domain rules (testing, l10n, a feature) with `alwaysApply: true` — burns context
- Rules with no concrete examples when the topic is code-facing
- Stale feature rules after modules are removed — run `tool/cursor_audit.sh` periodically
@@ -1,6 +1,7 @@
---
description: "UI/UX standards for {{PROJECT_NAME}} — always applied"
alwaysApply: true
description: "UI/UX standards for {{PROJECT_NAME}}"
globs: ["lib/**/*.dart", "test/**/*.dart", "integration_test/**/*.dart"]
alwaysApply: false
---
# UI / UX Standards — {{PROJECT_NAME}}