Skip to content

generator: Default to Gemini 4 Carbon and add --thinking-level - #270

Draft
jwren wants to merge 4 commits into
flutter:mainfrom
jwren:gemini-4-follow-up-3
Draft

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

Conversation

@jwren

@jwren jwren commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Note

Stacked on #268 and #269 — once both land on main, rebasing drops the base commits so only the Gemini 4 Carbon / --thinking-level commit (59349e0) remains.

Gemini 4 Carbon succeeds Argon as Google's strongest reasoning model at the same token cost, while bare --model IDs 404ed against v1beta and incompatible thinking parameters failed only after 3 HTTP retries.

Set defaultModel to models/gemini-4-carbon alongside Neon, Argon, and Hydrogen constants, normalize bare model IDs, omit temperature on Gemini 3/4, and add --thinking-level with upfront model-compatibility validation across Gemini 4, Gemini 3, legacy, and tuned models.

Refs: #267 (Gemini 4 generator follow-up, part 3 of 3)
Tested: dart format, dart analyze --fatal-infos --fatal-warnings, dart test (150 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 enhances the Agent Skills generator tool by adding support for Gemini 3 and Gemini 4 models, introducing a new --thinking-level option, and refactoring thinking budget configuration and validation. It also improves YAML configuration parsing and validation, refactors text metrics calculations into a dedicated utility file, and refines content cleaning to safely strip code fences and frontmatter. The review feedback suggests further improving configuration validation by checking for duplicate skill names.

Comment on lines +43 to 50
bool validateYamlList(YamlList yamlList, String fileName) {
if (yamlList.isEmpty) {
logger.severe('Configuration list must not be empty.');
return false;
}

var isValid = true;
final kabobCase = RegExp(r'^[a-z0-9]+(-[a-z0-9]+)*$');

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.

medium

Consider validating that there are no duplicate skill names in the configuration file. We can define a Set<String> seenNames at the start of validateYamlList and track the names as we iterate through the list.

Suggested change
bool validateYamlList(YamlList yamlList, String fileName) {
if (yamlList.isEmpty) {
logger.severe('Configuration list must not be empty.');
return false;
}
var isValid = true;
final kabobCase = RegExp(r'^[a-z0-9]+(-[a-z0-9]+)*$');
bool validateYamlList(YamlList yamlList, String fileName) {
if (yamlList.isEmpty) {
logger.severe('Configuration list must not be empty.');
return false;
}
var isValid = true;
final seenNames = <String>{};

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good catch. Added duplicate skill name detection via seenNames in ValidateSkillCommand.validateYamlList along with a unit test in validate_skills_input_test.dart in d32e75a (applied in #268 and rebased onto 59349e0 here).

(AI assisted -- human reviewed -- jwren)

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)
Naive indexOf('---') stripping truncated Markdown horizontal rules,
while MAX_TOKENS or frontmatter-only responses bypassed retry checks
and overwrote SKILL.md with incomplete or body-less output.

Parse leading YAML frontmatter via package:yaml (including camelCase
keys and block scalars), strip 3+/4-backtick outer fences, reject
non-STOP finishReason and empty cleaned bodies inside retry loops,
and add close() to release internally owned HTTP clients.

Refs: flutter#267 (Gemini 4 generator follow-up)
Tested: dart format, dart analyze --fatal-infos --fatal-warnings, dart test (125 passed)
Gemini 4 Carbon succeeds Argon as Google's strongest reasoning model
at the same token cost, while bare --model IDs 404ed against v1beta
and incompatible thinking parameters failed only after 3 HTTP retries.

Set defaultModel to models/gemini-4-carbon alongside Neon, Argon, and
Hydrogen constants, normalize bare model IDs, omit temperature on
Gemini 3/4, and add --thinking-level with upfront model-compatibility
validation across Gemini 4, Gemini 3, legacy, and tuned models.

Refs: flutter#267 (Gemini 4 generator follow-up)
Tested: dart format, dart analyze --fatal-infos --fatal-warnings, dart test (149 passed)
@jwren
jwren force-pushed the gemini-4-follow-up-3 branch from 715d80c to 59349e0 Compare November 19, 2026 02:12
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