mirror of
https://github.com/flutter/agent-plugins.git
synced 2026-09-14 16:19:33 +08:00
9b8106dbf0
* Add proactive Flutter hot reload rule https://github.com/dart-lang/ai/issues/498 Adds proactive Flutter hot reload rules (rules/flutter-hot-reload.md and rules/flutter-hot-reload.mdc) to automatically trigger hot reload or hot restart when Dart and Flutter files are modified during agent sessions. Problem: During AI-driven development workflows: - Out-of-Sync Execution: Agents modify source code on disk but do not update the active running session, leaving the simulator/device screen stale. - Context Switching Friction: Users must leave the chat interface to manually initiate a reload ('r'/'R') in the terminal or IDE. Solution: - Adds a glob-triggered rule on `**/*.dart` that instructs agents to discover running apps via DTD and execute hot reload (for widget/UI changes) or hot restart (for fundamental logic/state initialization). - Defines skip criteria for test files and comment/doc-only edits. * Address PR feedback: refine hot restart triggers and fix .mdc frontmatter - Remove unsupported `trigger: glob` key from `flutter-hot-reload.mdc`. - Refine reload vs. restart rules to allow hot reload on stateful widget build methods and restrict hot restart to state initialization, global state, and root lifecycle changes. * Address PR feedback: limit reload rule to lib/ and clarify Dart MCP tools - Update glob pattern to "lib/**/*.dart" and refine skip criteria to only trigger hot reload/restart for edits under lib/, ignoring edits in test/, integration_test/, benchmark/, test_driver/, example/, etc. - Explicitly state that dtd, hot_reload, and hot_restart are tools provided by the Dart MCP server. * Update reload rule glob to match nested package lib directories
21 lines
1.2 KiB
Plaintext
21 lines
1.2 KiB
Plaintext
---
|
|
description: Proactively connect to running Dart/Flutter apps and trigger hot reload or hot restart upon editing .dart files under lib/.
|
|
globs: "**/lib/**/*.dart"
|
|
alwaysApply: false
|
|
---
|
|
|
|
# Proactive Flutter Hot Reload Rule
|
|
|
|
Whenever you edit or modify any `.dart` file under `lib/` in this project:
|
|
|
|
1. **When to Skip**:
|
|
- **Files Outside `lib/`**: Only trigger hot reload or hot restart for edits under `lib/`. Do not trigger when modifying files in other directories (e.g., `test/**`, `integration_test/**`, `benchmark/**`, `test_driver/**` or `example/**`).
|
|
- **Comments & Documentation**: Do not trigger hot reload or hot restart when changes only affect comments, docstrings, or whitespace.
|
|
|
|
2. **Discover & Connect**:
|
|
- Discover active running application instances using the `dtd` MCP tool (or `list_running_apps` / `vm_service`) from the Dart MCP server.
|
|
|
|
3. **Trigger Hot Reload / Hot Restart**:
|
|
- Execute the `hot_reload` MCP tool immediately after making changes to UI widgets (including `build` methods of stateful widgets) or simple methods.
|
|
- Execute the `hot_restart` MCP tool if fundamental logic, state initialization (e.g., `initState`), global/static state, or `main()` was modified.
|