Repository navigation
feat(generator): upgrade to Gemini 4 Argon and align with Agent Skills standard - #267
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the skill generator tool to support the Gemini 4 Argon model as the default, introducing a --model command-line option and adjusting generation parameters such as omitting temperature for Gemini 4 models. It also adds validation warnings for SKILL.md files exceeding 500 lines or descriptions exceeding 1024 characters to align with the agentskills.io standard. The review feedback recommends optimizing the word-counting logic in the dry-run and validation commands by using RegExp.allMatches instead of splitting strings, which avoids unnecessary memory allocations for intermediate lists.
| final words = combinedMarkdown | ||
| .split(RegExp(r'\s+')) | ||
| .where((s) => s.isNotEmpty) | ||
| .length; |
There was a problem hiding this comment.
Using split(RegExp(r'\s+')) on a potentially large string creates an intermediate list of all words in memory, which can be inefficient. A more memory-efficient and elegant way to count words in Dart is to use RegExp(r'\S+').allMatches(text).length which avoids list allocation entirely.
| final words = combinedMarkdown | |
| .split(RegExp(r'\s+')) | |
| .where((s) => s.isNotEmpty) | |
| .length; | |
| final words = RegExp(r'\S+').allMatches(combinedMarkdown).length; |
| final origWords = existingContent | ||
| .split(RegExp(r'\s+')) | ||
| .where((s) => s.isNotEmpty) | ||
| .length; | ||
| final origTokens = (origWords * 1.3).round(); | ||
| final rawWords = combinedMarkdown | ||
| .split(RegExp(r'\s+')) | ||
| .where((s) => s.isNotEmpty) | ||
| .length; | ||
| final rawTokens = (rawWords * 1.3).round(); |
There was a problem hiding this comment.
Using split(RegExp(r'\s+')) on potentially large strings creates intermediate lists of all words in memory, which can be inefficient. A more memory-efficient and elegant way to count words in Dart is to use RegExp(r'\S+').allMatches(text).length which avoids list allocation entirely.
| final origWords = existingContent | |
| .split(RegExp(r'\s+')) | |
| .where((s) => s.isNotEmpty) | |
| .length; | |
| final origTokens = (origWords * 1.3).round(); | |
| final rawWords = combinedMarkdown | |
| .split(RegExp(r'\s+')) | |
| .where((s) => s.isNotEmpty) | |
| .length; | |
| final rawTokens = (rawWords * 1.3).round(); | |
| final origWords = RegExp(r'\S+').allMatches(existingContent).length;\n final origTokens = (origWords * 1.3).round();\n final rawWords = RegExp(r'\S+').allMatches(combinedMarkdown).length;\n final rawTokens = (rawWords * 1.3).round(); |
| final existWords = existingSkillFileContent | ||
| .split(RegExp(r'\s+')) | ||
| .where((s) => s.isNotEmpty) | ||
| .length; | ||
| final existTokens = (existWords * 1.3).round(); | ||
| final rawWords = markdown | ||
| .split(RegExp(r'\s+')) | ||
| .where((s) => s.isNotEmpty) | ||
| .length; | ||
| final rawTokens = (rawWords * 1.3).round(); |
There was a problem hiding this comment.
Using split(RegExp(r'\s+')) on potentially large strings creates intermediate lists of all words in memory, which can be inefficient. A more memory-efficient and elegant way to count words in Dart is to use RegExp(r'\S+').allMatches(text).length which avoids list allocation entirely.
| final existWords = existingSkillFileContent | |
| .split(RegExp(r'\s+')) | |
| .where((s) => s.isNotEmpty) | |
| .length; | |
| final existTokens = (existWords * 1.3).round(); | |
| final rawWords = markdown | |
| .split(RegExp(r'\s+')) | |
| .where((s) => s.isNotEmpty) | |
| .length; | |
| final rawTokens = (rawWords * 1.3).round(); | |
| final existWords = RegExp(r'\S+').allMatches(existingSkillFileContent).length;\n final existTokens = (existWords * 1.3).round();\n final rawWords = RegExp(r'\S+').allMatches(markdown).length;\n final rawTokens = (rawWords * 1.3).round(); |
…s standard - Set default model to `models/gemini-4-argon` with 65,536 max output token limit - Omit sampling temperature for Gemini 4 models per Google migration guidance - Add `--model` CLI option to override the Gemini model across all commands - Align documentation and prompt guidelines with the official agentskills.io standard - Enforce progressive disclosure size guidelines (< 500 lines, < 5,000 tokens) - Add static validation warnings for skills exceeding 500 lines or 1,024-character descriptions - Fix dry-run token metric calculations to report words and approximate tokens - Deduplicate guidelines in skill instructions and remove obsolete <details> tag advice - Add unit tests for Gemini 4 request payloads and validation warnings (108 passing tests)
cce0b99 to
fe312e5
Compare
Count words in GenerateSkillCommand, UpdateSkillCommand, and ValidateSkillCommand dry-run output via RegExp(r'\S+').allMatches(...) to avoid intermediate list allocations from String.split, and add dry-run word/token count assertions in unit tests. Part of: flutter#267 Tested: dart format, dart analyze, dart test (108 passed)
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)
models/gemini-4-argonwith 65,536 max output token limit--modelCLI option to override the Gemini model across all commandsDetails
tag advice