find-impact — impact analysis for a Dart source file
Given a path like lib/core/ssh/known_hosts.dart, report:
- Paired test file — mirror path under
test/. In this repo the rule is one test per source file (see AGENTS.md "Testing Methodology"). - Direct importers — files that
importthe target. Uses both package-relative and relative-path forms. - Symbol references — top-level class/function names defined in the target, grepped across
lib/andtest/.
Arguments
$1— absolute or repo-relative path to the Dart source file underlib/.
Steps
- Normalize path. Accept
lib/core/ssh/known_hosts.dartor/home/.../lib/core/ssh/known_hosts.dart. Strip the repo prefix; work with thelib/...form.
- Find paired test.
- Mirror path:
lib/X/Y/foo.dart→test/X/Y/foo_test.dart. - Run a
Globwith patterntest/**/foo_test.dartas a fallback in case the test lives under a slightly different path. - Report whether the test exists; if not, flag it — per AGENTS.md "Testing Methodology" (target 100% coverage).
- Find direct importers.
- Two import forms are used in this repo:
package:lets_flut_ssh/...(rare, only top-level entry points)- relative paths like
'../../core/ssh/known_hosts.dart' - Grep for both:
import '.*${basename}';— matches any relative import of the file.import 'package:.*${path_under_lib}';— matches package-form imports.- Restrict to
*.dartonly. List matching files (path + line of theimportstatement).
- Find top-level symbol references.
- Read the target file, extract top-level declarations: lines starting with
class,mixin,extension,enum,typedef, or[A-Z]\w+\s*\(for top-level functions. - For each exported symbol (non-underscore-prefixed), grep across
lib/andtest/for bare identifier usage (excluding the target file itself). - Group results by file; cap at first 5 call sites per file with
head_limit.
- Report format. Emit a single compact report:
```
Target: lib/core/ssh/known_hosts.dart
Paired test: test/core/ssh/known_hosts_test.dart (exists | MISSING)
Direct importers (N):
- lib/core/connection/connection.dart:3
- lib/features/known_hosts/known_hosts_controller.dart:5
...
Symbols referenced externally:
KnownHostsManager (12 sites)
- lib/core/connection/connection.dart:24, 53, 57
- lib/features/known_hosts/known_hosts_controller.dart:18
...
```
Constraints
- Do NOT run tests. This skill is read-only discovery — it never invokes
flutter test,dart test, ormake test. - Do NOT edit any file. Reporting only.
- Prefer
Grep+GloboverBashfor speed and permission ergonomics. - Cap total output to roughly one screen — if importers exceed 40, show the first 40 and the total count.
- Generated files (
*.g.dart,*.freezed.dart) are excluded from analysis — skip them when listing results.