upgrade-genkit
Realign the genkit_flutter_edge_ai / genkit_hybrid packages when flutter_edge_ai's core API changes or when `genkit` itself publishes a breaking version — discover changes, fix compilation, support new features, update fakes/tests, the codelab and the site, bump version. Monorepo-aware.
- License 许可
- MIT
- 最近更新
- 2026-11-12
- Stars
- ★ 660
- Forks
- 179
01 前言 Front Matter
- name
- upgrade-genkit
- description
- Realign the genkit_flutter_edge_ai / genkit_hybrid packages when flutter_edge_ai's core API changes or when `genkit` itself publishes a breaking version — discover changes, fix compilation, support new features, update fakes/tests, the codelab and the site, bump version. Monorepo-aware.
- user_invocable
- true
03 SKILL.md 正文
Upgrade Genkit packages to the current flutter_edge_ai API
The Genkit integration packages (packages/genkit_flutter_edge_ai, packages/genkit_hybrid)
wrap flutter_edge_ai's public API. When that API changes, they must be realigned or
they break. In the monorepo they consume flutter_edge_ai as an in-workspace
path dependency, so a core change can break them in the same commit — run this
whenever a PR changes the public InferenceModel / InferenceChat /
EmbeddingModel / Message / ModelResponse / enum surface.
Follow these 5 phases sequentially. Ask the user before deciding which new features to support (Phase 3).
Paths below are relative to the repo root. Core package =
packages/flutter_edge_ai; genkit package =packages/genkit_flutter_edge_ai(mirror forgenkit_hybrid).REPO_ROOT= monorepo root,PKG_DIR=packages/genkit_flutter_edge_ai,EXAMPLE_DIR=$PKG_DIR/example.
Phase 1: Reconnaissance
- Identify what changed in the core public API. In the monorepo flutter_edge_ai
is a path dep (not pub), so don't rely on
dart pub outdated— instead read the diff / CHANGELOG ofpackages/flutter_edge_ai:git log --oneline -- packages/flutter_edge_ai/lib(the public libraries atlib/*.dartplus everything underlib/src)packages/flutter_edge_ai/CHANGELOG.md(top entry)
- Summarize for the user:
- Breaking changes (removed/renamed APIs, changed signatures)
- New APIs (new parameters, methods, enums, classes)
- Bug fixes / Deprecations
melos bootstrap(ordart pub getinPKG_DIR+EXAMPLE_DIR).
Phase 2: Fix Compilation
cd packages/genkit_flutter_edge_ai && dart analyze(repeat forgenkit_hybrid).- Fix all compilation errors. Files that depend on flutter_edge_ai's API:
- [ ]
lib/src/flutter_edge_ai_runtime.dart—FlutterEdgeAi.getActiveModel(),getActiveEmbedder()signatures - [ ]
lib/src/flutter_edge_ai_model.dart—InferenceModel.openChat()signature,ModelResponsepattern matching,InferenceChatmethods - [ ]
lib/src/flutter_edge_ai_embedder.dart—EmbeddingModel.embedAll(),PreferredBackendenum - [ ]
lib/src/converters/request_converter.dart—Messageconstructors (.withImage,.withAudio,.toolCall,.toolResponse) - [ ]
lib/src/converters/response_converter.dart—ModelResponsesubtypes (TextResponse,FunctionCallResponse,ParallelFunctionCallResponse,ThinkingResponse) - [ ]
lib/src/converters/tool_converter.dart—Toolconstructor - [ ]
lib/src/flutter_edge_ai_plugin.dart—ModelType,ModelFileTypeenums - [ ]
test/src/fake_runtime.dart—FakeInferenceModel,FakeInferenceChat,FakeEmbeddingModelmust match upstream abstract-class signatures (see genkitAGENTS.md)
- [ ]
- Repeat
dart analyzeuntil clean (0 issues).
Phase 3: Support New Features
Based on Phase 1, decide with the user which new APIs to support. Typical integration points:
New parameter in openChat() / openSession()
- Add field to
$FlutterEdgeAiModelOptionsinlib/src/flutter_edge_ai_options.dart - Regenerate
lib/src/flutter_edge_ai_options.g.dart:dart pub global run build_runner build --delete-conflicting-outputsinPKG_DIR(see the packageAGENTS.md;dart pub global activate build_runneronce). Never hand-edit it. - Extract from config + pass in
lib/src/flutter_edge_ai_model.dart(_preparevalidates and converts;_generatepasses it toopenChat) - Update
FakeInferenceModel.openChat()intest/src/fake_runtime.dart(add param, store inlast*field for assertions)
New enum value (e.g. ModelFileType)
- Update comments in
lib/src/flutter_edge_ai_plugin.dart(FlutterEdgeAiModelConfig.fileType)
New method on InferenceChat / InferenceModel
- Add override in
FakeInferenceChat/FakeInferenceModelintest/src/fake_runtime.dart
Changed model capabilities
- Update
kFlutterEdgeAiModelSupportsinlib/src/flutter_edge_ai_model.dart;list()influtter_edge_ai_plugin.dartonly references it
Changed message handling
- Update converters in
lib/src/converters/; updateextractSystemInstruction()if system-message handling changed
IMPORTANT: *.g.dart here is generated by schemantic_builder (// GENERATED CODE - DO NOT MODIFY BY HAND). Regenerate it after any schema change; a hand edit drifts from the shape the generator produces.
Phase 4: Tests and Review
- Update existing tests that verify changed behavior.
- Add tests for each new feature from Phase 3.
flutter test(inPKG_DIR) — all must pass.- Run
/review-prfor comprehensive review; fix what it surfaces.
Phase 5: Finalize
- Bump version in
PKG_DIR/pubspec.yaml(minor for breaking behavior, patch for fixes/non-breaking additions). - Update
PKG_DIR/CHANGELOG.md(new section at top: breaking**Breaking**:/ new features / fixes). - Update
PKG_DIR/README.md(options table, known limitations, quick-start if usage changed). - Verify:
dart analyze && flutter test && dart pub publish --dry-run(all clean). - The release itself goes through the
releaseskill (genkit packages release in lockstep with the monorepo) — do not publish standalone.
When genkit itself releases a breaking version
The phases above assume the change came from flutter_edge_ai. Genkit 1.0.0
(2026-10-07) was the other trigger: it shipped with every Genkit Dart plugin
(genkit_google_genai, genkit_vertexai, genkit_firebase_ai, …) requiring
genkit ^1.0.0, so our packages could not be installed next to any current
cloud plugin until they moved too.
- Read the upstream CHANGELOG back to the version we pin:
dart pub cache add genkit --version <new>, then~/.pub-cache/hosted/pub.dev/genkit-<new>/CHANGELOG.md. Split it into compile breaks, which the analyzer finds, and behaviour changes, which it does not. Check every behaviour change against our code, the apps and the docs. The one 1.0 brought: a model error no longer throws out ofai.generate/generateStreambut comes back withfinishReason: FinishReason.failed(0.17, #413). It also turns tests with negative assertions (isNot(contains(...)),lessThan(n)) into tests that pass on a failed generation, so make them assertFinishReason.stopfirst. Schema instructions never reached the prompt by default, not under 0.16 either; 1.0 adds the opt-insimulateConstrainedGeneration()middleware (#519). New exports can collide withflutter_edge_ai's: 1.0'sToolChoicemakesToolChoice.noneanambiguous_importin any file importing both, so compile every snippet on the site against both imports. - Bump
genkitin both packages and ingenkit_flutter_edge_ai/example.schemanticandschemantic_buildermove with it (genkit 1.0 needs schemantic ^1.0.0). - Regenerate
lib/src/flutter_edge_ai_options.g.dartwithdart pub global run build_runner build --delete-conflicting-outputsand diff it: the option list must not change, only the generated shape. flutter analyze, fix,flutter testin both packages. Do not rundart formatover a whole package: many files predate the current formatter and would be restyled. Format only the files you edited, and only if they were formatted before.- Update what the analyzer never sees, because it sits outside the workspace:
- the codelab
codelabs/hybrid-ai-flutter-genkit/: every step's pubspec (step_00_startercarries the pins as comments) and README; the generate calls (lib/services/*_ai_service.dartin steps 01–02,lib/screens/chat_screen.dartin 03–05 andcomplete); andlib/services/ai_engine.dartin 03–05 andcomplete, which wraps a model the way genkit_hybrid calls a branch.genkit_google_genaimoves with genkit, so bump it there. Check the steps with a temporarypubspec_overrides.yamlcopied fromtool/check_codelabs.shand delete it afterwards, or runCODELAB_USE_LOCAL_PACKAGES=1 tool/check_codelabs.sh, which writes and removes them itself but checks every codelab. Codelab CI runsflutter analyzewith infos fatal and checks formatting. - the genkit example app (
example/lib/app_state.dartcallsgenerate). - the codelab page
website/codelabs/hybrid-ai-flutter-genkit/index.md, which repeats the step code,website/content/docs/genkit.md, both package READMEs (their install snippets namegenkit:) and dartdoc samples: grep them for every removed or renamed symbol.
- the codelab
- Version: a new major of a required dependency is a minor bump for a 0.x package, even when our own API is unchanged. Update AGENTS.md "Current Version".
- Ship it as one PR with the version bumps, the site and the codelab (release skill rule), and publish right after the merge: the site deploys on merge and its pins name the new versions. Each package's README must change in that PR, or the release docs guard blocks its publish after a squash merge. After publishing, dispatch the Codelabs workflow on main (release skill, step 10b): until then it resolves the old published packages and fails.
04 同仓库更多 Skills
send-email
Send an email.
query-wikipedia
Query summary from Wikipedia for a given topic.
qr-code
Generates a QR code for the given url.
kitchen-adventure
Act as a dungeon master for a text-based adventure set in a world where everyone is a sentient kitchen appliance. Trigger when user says "start kitchen adventure".
interactive-map
Show an interactive map view for the given location.
get-current-time
Get the user's current local date, time, and day of the week.