Repository navigation
refactor(meta): deduplicate extension internals, pin failure paths with tests - #25
Merged
Merged
Conversation
Add characterization tests for behavior the happy-path suites did not cover: slow_down back-off, denied/expired/unknown device-login errors, default interval and expiry, request shapes and progress messages, mint failure messages, catalog refresh fallbacks (offline, no key, HTTP error, empty catalog, abort, failed persistence), the bundled model table, and the MODEL_API_KEY/META_API_KEY env mirroring. These pass against the unmodified extension. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…og fallbacks Behavior-preserving cleanup of extensions/meta.ts: - Build the five bundled models with one museFallbackModel() factory and shared cost constants instead of five near-identical literals. - Route every "<message>: <detail>" error through detailedError(). - Split loginMeta into startDeviceAuthorization and pollForIdentityToken. - Collapse the repeated cached-or-fallback tail of refreshMetaModels into cachedOrFallbackModels(); extract credentialApiKey and fetchMetaCatalog. - Build thinking-level maps in a loop, share the Muse compat/default limits, and gate a single fallback model instead of the whole list per catalog entry. - Make responseBody generic and reuse asRecord; extract mirrorApiKeyEnv(). - Remove metaFallbackCost, whose only caller (the media module) was dropped in v0.6.0. Public exports otherwise unchanged. The package still ships a single extensions/meta.ts per the branch contract. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A behavior-preserving cleanup of
extensions/meta.ts(789 → 761 lines), preceded by a new test file that pins the paths being restructured.Commit 1:
test(meta). Addstests/meta-failures.test.ts(49 tests). It covers behavior the existing suites didn't:slow_downback-off, denied/expired/unknown device-login errors, default interval and expiry, request shapes and progress messages, exact mint-failure messages, catalog refresh fallbacks (offline, no key, HTTP error, empty catalog, abort, failed persistence), the bundled model table, andMODEL_API_KEY/META_API_KEYmirroring. All of these pass against the unmodified extension.Commit 2:
refactor(meta).museFallbackModel()factory plus shared cost constants.": ${detail}"suffix was copy-pasted in five places →detailedError().loginMeta(80 lines) split intostartDeviceAuthorizationandpollForIdentityToken.refreshMetaModels→cachedOrFallbackModels();credentialApiKeyandfetchMetaCatalogextracted.toProviderModelsgates the one fallback it needs instead of the whole list per catalog entry.responseBodyis generic and reusesasRecord(duplicate removed); env mirroring extracted tomirrorApiKeyEnv().AGENTS.md: one line noting the new test file.Why
meta.tshad a lot of copy-paste (model literals, error formatting, fallback handling) that made each change touch many places. The existing tests didn't cover the failure paths being restructured, so the safety net came first.Reviewer notes
bun run typecheckis clean.bun testgives 86 pass, 3 skip, 0 fail. The skips are the optional live probes. I ran with live credentials blanked andHOMEredirected, because the live probes make real billable requests when a credential resolves.??=, which can't change behavior).metaFallbackCostis gone. Its only caller was the media module dropped in v0.6.0 and nothing here references it, but it was technically a public export.meta.tsinto modules.tests/package.test.tsand the branch contract inAGENTS.mdrequireextensions/to contain onlymeta.ts.gateMuseMaxEffort(),applyMetaResponsesCacheHints(),MUSE_USER_AGENT_MODEL_IDS, and the Pi 0.83/0.84 refresh-context handling.🤖 Generated with Claude Code