Skip to content

DRAFT: Convert dart-collect-coverage skill into a deterministic script - #20

Open
prolificcoder wants to merge 1 commit into
dart-lang:mainfrom
prolificcoder:dart-collect-coverage-deterministic
Open

prolificcoder wants to merge 1 commit into
dart-lang:mainfrom
prolificcoder:dart-collect-coverage-deterministic

Conversation

@prolificcoder

@prolificcoder prolificcoder commented May 9, 2026 •

Copy link
Copy Markdown

Summary

The dart-collect-coverage skill is currently prose that asks an LLM to re-derive project topology (Dart vs. Flutter, pub-workspace membership, whether coverage is already a dev_dependency, which test directories to pass) on every invocation. Those decisions are purely mechanical, so this PR moves them into a self-contained shell script and rewrites SKILL.md to delegate to it. Only the genuinely-judgment step — uncovered file: write a test or add an ignore directive? — is left to the LLM/human reviewer.

What's new

  • skills/dart-collect-coverage/collect_coverage.sh — pure bash + awk, no extra dependencies. Detects project type, handles pub workspaces, idempotently adds the dev dep, runs coverage:test_with_coverage (or the manual VM-service flow via --manual), always passes --check-ignore, validates outputs, and emits coverage/summary.txt with per-file line coverage sorted ascending.
  • skills/dart-collect-coverage/SKILL.md — rewritten to point at the script, explain which decisions are now deterministic, and scope the remaining LLM/human judgment to coverage-gap remediation.

Determinism gains

Decision Before After
Dart vs. Flutter LLM reads pubspec awk on pubspec.yaml for flutter: under dependencies:
Pub workspace handling Prose: "if working in a workspace, specify…" Parses workspace: list, builds the -- <dirs> arg automatically
Idempotent pub add LLM may add twice or skip Checks dev_dependencies: block first
--check-ignore flag Easy to forget Hard-coded
Output validation "Verify the directory was created" [[ -s file ]] with distinct exit codes (1/2/3)
Auto vs. manual workflow Open-ended choice Defaults to auto; --manual is opt-in
Background test process cleanup (manual mode) Not mentioned trap kills the test PID on exit

What still needs judgment (intentionally)

Deciding, per uncovered file, between write a test, add // coverage:ignore-file, or acceptable gap is a design call, not a mechanical one. The script surfaces those files in coverage/summary.txt and stderr so the reviewer operates on structured input.

Testing

  • bash -n collect_coverage.sh passes.
  • The script is idempotent: re-running on a project that already has coverage in dev_dependencies skips pub add.
  • Exit codes: 0 success, 1 not a Dart project, 2 collection failed, 3 outputs missing/empty.
  • Run this skill on pure dart project without coverage and with coverage
  • Run this skill on flutter mono repo
  • Run this script on simple flutter project
 ../skills/skills/dart-collect-coverage/collect_coverage.sh
[collect_coverage] detected Flutter project
[collect_coverage] step 1/3: Flutter project — skipping 'coverage' dev dep (built into Flutter SDK)
[collect_coverage] step 2/3: running 'flutter test --coverage'
00:01 +1: All tests passed!
[collect_coverage] step 3/3: validating outputs
[collect_coverage] wrote coverage/lcov.info, coverage/summary.txt
[collect_coverage] files reported: 1, files with 0% coverage: 0

Happy to iterate on naming, on whether the script should live next to SKILL.md or under a shared bin/, or on adding an --auto-ignore-generated flag for *.g.dart / *.freezed.dart / *.mocks.dart.

@google-cla

google-cla Bot commented May 9, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@prolificcoder prolificcoder changed the title Convert dart-collect-coverage skill into a deterministic script DRAFT: Convert dart-collect-coverage skill into a deterministic script May 9, 2026
The original skill relied on an LLM to re-derive project topology
(Dart vs. Flutter, pub workspace membership, dev-dep state) on every
run. Move those mechanical decisions into collect_coverage.sh so they
become reproducible and exit-code-checkable.

The script:
- detects Dart vs. Flutter from pubspec.yaml
- detects pub workspaces and enumerates member test/ directories
- adds 'coverage' to dev_dependencies idempotently
- runs coverage:test_with_coverage (or the manual VM-service flow
  via --manual) and always passes --check-ignore
- validates that coverage/coverage.json and coverage/lcov.info exist
  and are non-empty, with distinct exit codes per failure mode
- emits coverage/summary.txt with per-file line coverage so the
  remaining judgment step (write tests vs. add ignore directive)
  operates on structured input

SKILL.md is rewritten to delegate to the script and to scope the
remaining LLM/human judgment to coverage-gap remediation, which is
the only step that genuinely requires a design decision.
@prolificcoder
prolificcoder force-pushed the dart-collect-coverage-deterministic branch from 36f857f to 29b9b98 Compare May 9, 2026 21:56
@kevmoo

kevmoo commented May 10, 2026

Copy link
Copy Markdown
Member

Take a look at

https://github.com/kevmoo/dash_skills/tree/e56fe5d8f12561bf00f82db8d50c85667b5b57ea/.agent/skills/dart-test-coverage

I discontinued this in favor of this official one, but I liked mine more.

We don't NEED pkg:coverage AT ALL. pkg:test already gives us all the data we need! Just have to invoke it correctly.

https://github.com/kevmoo/dash_skills/blob/e56fe5d8f12561bf00f82db8d50c85667b5b57ea/.agent/skills/dart-test-coverage/scripts/interpret_coverage.dart

This is helpful for the agent to hydrate the output from pkg:test and interpret for the user.

(It's also pure dart, so it'll work on Windows 😄 )

Wanna run with these ideas @prolificcoder ??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants