feat: add model selection engine (APR-205)#53
Open
JacobSampson wants to merge 1 commit into
Open
Conversation
Implements the core complexity → model tier routing engine in @aprovan/devtools/model-selection. - `selectModel(input)` maps a 1-5 complexity score to the best available model, applying the priority order: free tier → subscription (prepaid quota) → paid (budget → mid-tier → frontier → premium). - `DEFAULT_CATALOG` defines routing options across OpenRouter free, OpenCode/Claude subscriptions, and paid models from Anthropic, OpenAI, and Google. - `ScoringPlugin` interface scaffolds MCP integration points for 3rd-party data sources (Artificial Analysis etc.) — data is collected but not yet weighted in selection decisions. - Returns `SelectionResult` with modelId, provider, tier, planType, optional subscriptionPlan, and human-readable reasoning. - 37 new tests covering all complexity scores, priority ordering, subscription quota gating, plugin scaffolding, and error paths. - All CI gates green: 53/53 tests, 0 type errors, 0 lint errors, build succeeds. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
selectModel()in@aprovan/devtools/model-selection— maps a 1-5 complexity score to the best available modelDEFAULT_CATALOGcovers OpenRouter free models, OpenCode + Claude subscription plans, and paid models from Anthropic, OpenAI, and GoogleScoringPlugininterface scaffolds MCP injection points for 3rd-party data sources (Artificial Analysis, etc.) — data collected but not yet weightedSelectionResultwithmodelId,provider,tier,planType, optionalsubscriptionPlan, and human-readablereasoning./model-selectionsubpath export added to package.json and tsupTest plan
pnpm test)pnpm typecheck)pnpm lint)model-selection.{js,cjs,d.ts}emitted (pnpm build)Notes
quotaStateis optional; omitting it means no subscription plans are considered (all pass through to paid routing)hasAvailableQuota: true— real-time quota data will be plugged in via APR-206/APR-207Closes APR-205. Unblocks APR-206 (OpenRouter integration) and APR-207 (MCP plugin scaffold).
🤖 Generated with Claude Code