Skip to content

generator: Centralize text metrics, YAML checks, and CLI exit codes - #268

Open
jwren wants to merge 2 commits into
flutter:mainfrom
jwren:gemini-4-follow-up-1
Open

jwren wants to merge 2 commits into
flutter:mainfrom
jwren:gemini-4-follow-up-1

Conversation

@jwren

@jwren jwren commented Nov 19, 2026

Copy link
Copy Markdown
Member

Skill commands duplicated RegExp word, line, and 1.3x token counts, validate-skill read and parsed YAML configs twice via JSON round-trips, and logged SEVERE errors exited 0 while exit() skipped HTTP client cleanup.

Extract shared RegExpMatchCount and StringMetrics extensions into text_metrics.dart (with documented 1.3 subword token estimation and zero-allocation line counting), validate and construct SkillParams in a single YAML pass, allow --dry-run without GEMINI_API_KEY, and set exitCode on SEVERE and UsageException paths so finally always closes httpClient.

Refs: #267 (Gemini 4 generator follow-up, part 1 of 3)
Tested: dart format, dart analyze --fatal-infos --fatal-warnings, dart test (126 passed)

Skill commands duplicated RegExp word, line, and 1.3x token counts,
validate-skill read and parsed YAML configs twice via JSON round-trips,
and logged SEVERE errors exited 0 while exit() skipped client cleanup.

Extract shared RegExpMatchCount and StringMetrics extensions into
text_metrics.dart, validate and construct SkillParams in a single YAML
pass, allow --dry-run without GEMINI_API_KEY, and set exitCode on
SEVERE and UsageException paths so finally always closes httpClient.

Refs: flutter#267 (Gemini 4 generator follow-up)
Tested: dart format, dart analyze --fatal-infos --fatal-warnings, dart test (126 passed)

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the Agent Skills CLI tool to improve YAML parsing, validation, and text metrics. It introduces a centralized text_metrics.dart utility for efficient word, line, and token count calculations, replaces direct exit() calls with exitCode assignments, and ensures proper cleanup of logging subscriptions. It also enhances YAML validation by checking types and required fields via SkillParams.fromYamlMap, refactors regular expressions into static constants, and updates command-line options to support dry runs without an API key. I have no feedback to provide on this pull request.

Duplicate skill names in YAML configuration files previously passed
validation silently, causing subsequent commands to overwrite earlier
SKILL.md files or emit duplicate README table rows.

Track seen skill names in ValidateSkillCommand.validateYamlList and log
a SEVERE error whenever a duplicate name appears.

Refs: flutter#267 (Gemini 4 generator follow-up)
Tested: dart format, dart analyze --fatal-infos --fatal-warnings, dart test (127 passed)
@jwren
jwren requested a review from johnpryan November 19, 2026 02:29
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.

1 participant