@diffra-ai/cli 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/bundle/chunks/{anthropic-messages-T6QSBW2I.js → anthropic-messages-VPHYDMHB.js} +1 -1
- package/dist/bundle/chunks/{azure-openai-responses-QHACUEEL.js → azure-openai-responses-JYJ2VXQ2.js} +1 -1
- package/dist/bundle/chunks/bedrock-converse-stream.js +1 -1
- package/dist/bundle/chunks/{chunk-UVU7AFFV.js → chunk-2IABWVGX.js} +1 -1
- package/dist/bundle/chunks/{chunk-GU5QXRH2.js → chunk-6RV2XP5B.js} +10 -10
- package/dist/bundle/chunks/{chunk-ACRSTWI3.js → chunk-FCSMMPE4.js} +1 -1
- package/dist/bundle/chunks/{chunk-3OQXW6CV.js → chunk-JEYYTVUX.js} +1 -1
- package/dist/bundle/chunks/chunk-NPHITI73.js +30 -0
- package/dist/bundle/chunks/{chunk-JZ2OAQAK.js → chunk-QQYLP3HG.js} +1 -1
- package/dist/bundle/chunks/{chunk-EMYFX4WY.js → chunk-QY4GYLLA.js} +1 -1
- package/dist/bundle/chunks/{chunk-ZTDZEFOK.js → chunk-REVASUCD.js} +1 -1
- package/dist/bundle/chunks/{chunk-HGCDVLYI.js → chunk-S7OTLWTF.js} +1 -1
- package/dist/bundle/chunks/{chunk-YTFC5DOS.js → chunk-TOBZDLTR.js} +1 -1
- package/dist/bundle/chunks/{chunk-2CWIL3U7.js → chunk-Z4BBBJG4.js} +1 -1
- package/dist/bundle/chunks/{cli-B74BATSM.js → cli-I4RCHKMY.js} +1 -1
- package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-IRTLSYMY.js → cloudflare-workers-ai-system-one-OTYUASP3.js} +1 -1
- package/dist/bundle/chunks/github-copilot.js +1 -1
- package/dist/bundle/chunks/{google-generative-ai-J4JVZXHV.js → google-generative-ai-DI3FOC25.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-A36RXRWN.js → google-vertex-VBHHROPU.js} +1 -1
- package/dist/bundle/chunks/{llama-cpp-classify-WD5MJBC7.js → llama-cpp-classify-MUFWIFOW.js} +1 -1
- package/dist/bundle/chunks/{mistral-conversations-YIKS5LKW.js → mistral-conversations-Q2PGF352.js} +1 -1
- package/dist/bundle/chunks/{openai-codex-responses-UBNJIYCO.js → openai-codex-responses-WWZAXEPG.js} +1 -1
- package/dist/bundle/chunks/{openai-completions-WBIL7MLK.js → openai-completions-4C7QTL2T.js} +1 -1
- package/dist/bundle/chunks/{openai-decisions-6T6CQTOT.js → openai-decisions-NYOT2XIF.js} +1 -1
- package/dist/bundle/chunks/{openai-responses-W2CLKVKJ.js → openai-responses-R5MW34FB.js} +1 -1
- package/dist/bundle/chunks/{openrouter-images-ZP4QC3RD.js → openrouter-images-FBKW4PD4.js} +1 -1
- package/dist/bundle/chunks/{pi-messages-VHFVA66D.js → pi-messages-LJZPZBQY.js} +1 -1
- package/dist/bundle/chunks/{typesafe-system-one-GORHCFHB.js → typesafe-system-one-7MCWBLJY.js} +1 -1
- package/dist/bundle/chunks/{virtual-modules-XMXHVMFN.js → virtual-modules-J4Z2IMRZ.js} +1 -1
- package/dist/bundle/cli-runtime.js +1 -1
- package/dist/bundle/cli.js +0 -0
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/cli.js +0 -0
- package/dist/core/agent-session.d.ts +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +11 -8
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/model-resolver.js +3 -3
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/extensions/skills/bundled/find-skills/LICENSE +21 -0
- package/dist/extensions/skills/bundled/find-skills/SKILL.md +117 -0
- package/dist/extensions/skills/bundled/grill-me/LICENSE +21 -0
- package/dist/extensions/skills/bundled/grill-me/SKILL.md +44 -0
- package/dist/extensions/skills/bundled/handoff/LICENSE +21 -0
- package/dist/extensions/skills/bundled/handoff/SKILL.md +31 -0
- package/dist/extensions/skills/bundled/mcp-builder/LICENSE.txt +202 -0
- package/dist/extensions/skills/bundled/mcp-builder/SKILL.md +260 -0
- package/dist/extensions/skills/bundled/mcp-builder/reference/evaluation.md +432 -0
- package/dist/extensions/skills/bundled/mcp-builder/reference/mcp_best_practices.md +249 -0
- package/dist/extensions/skills/bundled/mcp-builder/reference/node_mcp_server.md +972 -0
- package/dist/extensions/skills/bundled/mcp-builder/reference/node_mcp_server_v2.md +747 -0
- package/dist/extensions/skills/bundled/mcp-builder/reference/python_mcp_server.md +719 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/LICENSE +21 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/SKILL.md +251 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/app-interface.csv +33 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/charts.csv +26 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/colors.csv +195 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/google-fonts.csv +1935 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/icons.csv +106 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/landing.csv +35 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/motion.csv +21 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/products.csv +195 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/angular.csv +51 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/astro.csv +54 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/avalonia.csv +57 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/html-tailwind.csv +60 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/javafx.csv +76 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/laravel.csv +51 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/nextjs.csv +62 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/nuxt-ui.csv +84 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/nuxtjs.csv +68 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/pyside6-qss.csv +103 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/react.csv +67 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/shadcn.csv +69 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/svelte.csv +56 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/threejs.csv +54 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/uno.csv +60 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/uwp.csv +56 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/winui.csv +60 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/wpf.csv +57 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/styles.csv +90 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/typography.csv +75 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/ui-reasoning.csv +195 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/data/ux-guidelines.csv +142 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/references/pro-rules.md +117 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/references/quick-reference.md +275 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/scripts/core.py +1111 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/scripts/design_system.py +1922 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/scripts/preview.py +557 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/scripts/reasoning_contract.py +123 -0
- package/dist/extensions/skills/bundled/ui-ux-pro-max/scripts/search.py +257 -0
- package/dist/extensions/skills/index.d.ts +4 -4
- package/dist/extensions/skills/index.d.ts.map +1 -1
- package/dist/extensions/skills/index.js +9 -4
- package/dist/extensions/skills/index.js.map +1 -1
- package/dist/rpc-entry.js +0 -0
- package/docs/builtin-skills.md +46 -3
- package/docs/docs.json +1 -1
- package/docs/skills.md +1 -1
- package/docs/slash-commands.md +2 -0
- package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/examples/extensions/doom-overlay/doom/build.sh +0 -0
- package/package.json +6 -6
- package/dist/bundle/chunks/chunk-TXISM6X7.js +0 -30
|
@@ -26,7 +26,7 @@ export const defaultModelPerProvider = {
|
|
|
26
26
|
cerebras: "gpt-oss-120b",
|
|
27
27
|
zai: "glm-5.3",
|
|
28
28
|
"zai-coding-cn": "glm-5.3",
|
|
29
|
-
mistral: "
|
|
29
|
+
mistral: "mistral-medium-latest",
|
|
30
30
|
minimax: "MiniMax-M3",
|
|
31
31
|
"minimax-cn": "MiniMax-M3",
|
|
32
32
|
moonshotai: "kimi-k2.7-code",
|
|
@@ -39,8 +39,8 @@ export const defaultModelPerProvider = {
|
|
|
39
39
|
"opencode-go": "kimi-k3.1-pro",
|
|
40
40
|
"kimi-coding": "kimi-for-coding",
|
|
41
41
|
meta: "muse-spark-1.3",
|
|
42
|
-
"cloudflare-workers-ai": "@cf/
|
|
43
|
-
"cloudflare-ai-gateway": "workers-ai/@cf/
|
|
42
|
+
"cloudflare-workers-ai": "@cf/zai-org/glm-5.3",
|
|
43
|
+
"cloudflare-ai-gateway": "workers-ai/@cf/zai-org/glm-5.3",
|
|
44
44
|
"qwen-token-plan": "qwen3.8-max",
|
|
45
45
|
"qwen-token-plan-cn": "qwen3.8-max",
|
|
46
46
|
"qwen-token-plan-individual": "qwen3.8-max",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-resolver.js","sourceRoot":"","sources":["../../src/core/model-resolver.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAuE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAGvD,sEAAsE;AACtE,MAAM,CAAC,MAAM,uBAAuB,GAA2C;IAC9E,gBAAgB,EAAE,8BAA8B;IAChD,UAAU,EAAE,aAAa;IACzB,SAAS,EAAE,iBAAiB;IAC5B,MAAM,EAAE,aAAa;IACrB,KAAK,EAAE,aAAa;IACpB,cAAc,EAAE,aAAa;IAC7B,MAAM,EAAE,UAAU;IAClB,MAAM,EAAE,wCAAwC;IAChD,QAAQ,EAAE,iBAAiB;IAC3B,MAAM,EAAE,gBAAgB;IACxB,eAAe,EAAE,gBAAgB;IACjC,gBAAgB,EAAE,aAAa;IAC/B,UAAU,EAAE,2BAA2B;IACvC,mBAAmB,EAAE,aAAa;IAClC,GAAG,EAAE,UAAU;IACf,IAAI,EAAE,qBAAqB;IAC3B,QAAQ,EAAE,cAAc;IACxB,GAAG,EAAE,SAAS;IACd,eAAe,EAAE,SAAS;IAC1B,OAAO,EAAE,wBAAwB;IACjC,OAAO,EAAE,YAAY;IACrB,YAAY,EAAE,YAAY;IAC1B,UAAU,EAAE,gBAAgB;IAC5B,eAAe,EAAE,gBAAgB;IACjC,WAAW,EAAE,2BAA2B;IACxC,SAAS,EAA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,EAAE,aAAa,EAAE,sBAAsB,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC;YAC5F,CAAC;QACF,CAAC;QAED,2CAA2C;QAC3C,OAAO,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,sBAAsB,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC;IACzG,CAAC;IAED,oBAAoB;IACpB,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,sBAAsB,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC;AAChG,CAAC","sourcesContent":["/**\n * Model resolution, scoping, and initial selection\n */\n\nimport type { ThinkingLevel } from \"@diffra-ai/agent-core\";\nimport { type Api, type AuthOperationOptions, type KnownProvider, type Model, modelsAreEqual } from \"@diffra-ai/ai\";\nimport { minimatch } from \"minimatch\";\nimport { isValidThinkingLevel } from \"../cli/args.ts\";\nimport { DEFAULT_THINKING_LEVEL } from \"./defaults.ts\";\nimport type { ModelRuntime } from \"./model-runtime.ts\";\n\n/** Default chat model IDs for providers with built-in chat models. */\nexport const defaultModelPerProvider: Partial<Record<KnownProvider, string>> = {\n\t\"amazon-bedrock\": \"us.anthropic.claude-opus-5-5\",\n\t\"ant-ling\": \"Ring-2.6-1T\",\n\tanthropic: \"claude-opus-5-5\",\n\topenai: \"gpt-6.2-sol\",\n\tazure: \"gpt-6.2-sol\",\n\t\"openai-codex\": \"gpt-6.2-sol\",\n\tradius: \"balanced\",\n\tnvidia: \"nvidia/nemotron-3.5-super-vl-120b-a12b\",\n\tdeepseek: \"deepseek-v4-pro\",\n\tgoogle: \"gemini-4-argon\",\n\t\"google-vertex\": \"gemini-4-argon\",\n\t\"github-copilot\": \"gpt-6.1-sol\",\n\topenrouter: \"moonshotai/kimi-k2.7-code\",\n\t\"vercel-ai-gateway\": \"zai/glm-5.3\",\n\txai: \"grok-4.7\",\n\tgroq: \"openai/gpt-oss-120b\",\n\tcerebras: \"gpt-oss-120b\",\n\tzai: \"glm-5.3\",\n\t\"zai-coding-cn\": \"glm-5.3\",\n\tmistral: \"devstral-medium-latest\",\n\tminimax: \"MiniMax-M3\",\n\t\"minimax-cn\": \"MiniMax-M3\",\n\tmoonshotai: \"kimi-k2.7-code\",\n\t\"moonshotai-cn\": \"kimi-k2.7-code\",\n\thuggingface: \"moonshotai/Kimi-K2.7-Code\",\n\tfireworks: \"accounts/fireworks/models/kimi-k3\",\n\ttogether: \"moonshotai/Kimi-K3\",\n\tbaseten: \"zai-org/GLM-5.3\",\n\topencode: \"kimi-k2.7-code\",\n\t\"opencode-go\": \"kimi-k3.1-pro\",\n\t\"kimi-coding\": \"kimi-for-coding\",\n\tmeta: \"muse-spark-1.3\",\n\t\"cloudflare-workers-ai\": \"@cf/moonshotai/kimi-k2.7-code\",\n\t\"cloudflare-ai-gateway\": \"workers-ai/@cf/moonshotai/kimi-k2.7-code\",\n\t\"qwen-token-plan\": \"qwen3.8-max\",\n\t\"qwen-token-plan-cn\": \"qwen3.8-max\",\n\t\"qwen-token-plan-individual\": \"qwen3.8-max\",\n\t\"qwen-token-plan-individual-cn\": \"qwen3.8-max\",\n\txiaomi: \"mimo-v2.6-pro\",\n\t\"xiaomi-token-plan-cn\": \"mimo-v2.6-pro\",\n\t\"xiaomi-token-plan-ams\": \"mimo-v2.6-pro\",\n\t\"xiaomi-token-plan-sgp\": \"mimo-v2.6-pro\",\n};\n\nexport interface ScopedModel {\n\tmodel: Model<Api>;\n\t/** Thinking level if explicitly specified in pattern (e.g., \"model:high\"), undefined otherwise */\n\tthinkingLevel?: ThinkingLevel;\n}\n\n/*\n * Model reference resolution. Candidates are collected before a provider is chosen, so catalog order\n * never decides the provider and an ambiguous match is reported instead of falling through to a\n * weaker one.\n */\n\nexport interface ModelReferenceRequest {\n\t/** Bare model id or `provider/id`, optionally followed by `:<thinking>`. */\n\ttext: string;\n\t/** Only consider models from this provider. */\n\tprovider?: string;\n\t/**\n\t * A trailing `:<suffix>` is only considered when the full text matches no model, since ids such as\n\t * OpenRouter's `qwen/qwen3-coder:exacto` contain colons.\n\t * - `none`: the suffix stays part of the id\n\t * - `strict`: a valid thinking level is parsed; any other suffix stays part of the id\n\t * - `lenient`: like `strict`, but an invalid suffix is dropped with a warning\n\t */\n\tthinkingSuffix: \"none\" | \"strict\" | \"lenient\";\n\t/** Match id and name substrings when no exact match exists. */\n\tfuzzy: boolean;\n}\n\nexport type ModelReferenceResult =\n\t| { status: \"resolved\"; model: Model<Api>; thinkingLevel?: ThinkingLevel; warning?: string }\n\t| {\n\t\t\tstatus: \"ambiguous\";\n\t\t\tcandidates: Model<Api>[];\n\t\t\tusableCount: number;\n\t\t\tthinkingLevel?: ThinkingLevel;\n\t\t\twarning?: string;\n\t }\n\t| {\n\t\t\tstatus: \"not-found\";\n\t\t\t/** Set when a provider is explicit or named by a `provider/` prefix, for building a custom model id. */\n\t\t\ttarget?: ModelReferenceTarget;\n\t };\n\nexport interface ModelReferenceTarget {\n\tprovider: string;\n\tproviderModels: [Model<Api>, ...Model<Api>[]];\n\t/** Text after the provider prefix as typed, including any `:<suffix>`. */\n\tmodelText: string;\n\t/** `modelText` without a valid thinking suffix (unless `thinkingSuffix` is `none`). */\n\tmodelId: string;\n\tthinkingLevel?: ThinkingLevel;\n}\n\ntype ResolvedOrAmbiguous = Exclude<ModelReferenceResult, { status: \"not-found\" }>;\n\nfunction splitThinkingSuffix(text: string): { base: string; thinkingLevel: ThinkingLevel } | undefined {\n\tconst colonIndex = text.lastIndexOf(\":\");\n\tconst suffix = text.substring(colonIndex + 1);\n\tif (colonIndex === -1 || !isValidThinkingLevel(suffix)) return undefined;\n\treturn { base: text.substring(0, colonIndex), thinkingLevel: suffix };\n}\n\nfunction splitProviderPrefix(\n\ttext: string,\n\tmodels: readonly Model<Api>[],\n): { provider: string; modelText: string } | undefined {\n\t// Provider ids may contain \"/\" themselves (e.g. URL-derived ids), so match known ids, longest first\n\tconst lowerText = text.toLowerCase();\n\tlet best: { provider: string; modelText: string } | undefined;\n\tfor (const { provider } of models) {\n\t\tconst prefix = provider.trim().toLowerCase();\n\t\tif (!prefix || (best && best.provider.length >= provider.length)) continue;\n\t\tconst slashIndex = lowerText.indexOf(\"/\", prefix.length);\n\t\tif (slashIndex === -1 || lowerText.substring(0, slashIndex).trim() !== prefix) continue;\n\t\tconst modelText = text.substring(slashIndex + 1).trim();\n\t\tif (modelText) best = { provider, modelText };\n\t}\n\treturn best;\n}\n\n/**\n * `usable` only breaks ties between providers, so a unique match resolves even without credentials\n * (`--api-key` first-time setup).\n */\nexport function resolveModelReference(\n\trequest: ModelReferenceRequest,\n\tmodels: readonly Model<Api>[],\n\tusable: (provider: string) => boolean,\n): ModelReferenceResult {\n\tconst text = request.text.trim();\n\tif (!text) return { status: \"not-found\" };\n\tconst constraint = request.provider?.toLowerCase();\n\tconst pool = constraint ? models.filter((model) => model.provider.toLowerCase() === constraint) : models;\n\tconst result = resolveText(text, request, pool, usable);\n\tif (result.status !== \"not-found\") return result;\n\n\tconst split = splitProviderPrefix(text, pool);\n\tconst anchor = constraint ? pool[0] : pool.find((model) => model.provider === split?.provider);\n\tif (!anchor) return result;\n\tconst modelText = split?.modelText ?? text;\n\tconst suffix = request.thinkingSuffix === \"none\" ? undefined : splitThinkingSuffix(modelText);\n\treturn {\n\t\tstatus: \"not-found\",\n\t\ttarget: {\n\t\t\tprovider: anchor.provider,\n\t\t\tproviderModels: [anchor, ...pool.filter((model) => model.provider === anchor.provider && model !== anchor)],\n\t\t\tmodelText,\n\t\t\tmodelId: suffix?.base ?? modelText,\n\t\t\tthinkingLevel: suffix?.thinkingLevel,\n\t\t},\n\t};\n}\n\n/** Exact `provider/id` or bare id lookup without thinking suffixes or fuzzy matching. */\nexport function findExactModelReferenceMatch(\n\tmodelReference: string,\n\tmodels: readonly Model<Api>[],\n): Model<Api> | undefined {\n\tconst result = resolveModelReference(\n\t\t{ text: modelReference, thinkingSuffix: \"none\", fuzzy: false },\n\t\tmodels,\n\t\t() => true,\n\t);\n\treturn result.status === \"resolved\" ? result.model : undefined;\n}\n\nfunction resolveText(\n\ttext: string,\n\trequest: ModelReferenceRequest,\n\tpool: readonly Model<Api>[],\n\tusable: (provider: string) => boolean,\n): ModelReferenceResult {\n\tconst reference = selectReference(text, pool, request.fuzzy, usable);\n\tif (reference) return reference;\n\n\tif (request.fuzzy) {\n\t\tconst fuzzy = selectFuzzy(fuzzyMatches(text, pool), usable);\n\t\tif (fuzzy) return fuzzy;\n\t}\n\n\tif (request.thinkingSuffix === \"none\") return { status: \"not-found\" };\n\tconst thinking = splitThinkingSuffix(text);\n\tif (thinking) {\n\t\tconst inner = resolveText(thinking.base, request, pool, usable);\n\t\tif (inner.status === \"not-found\") return inner;\n\t\t// Only use this thinking level if no warning from inner recursion\n\t\treturn { ...inner, thinkingLevel: inner.warning ? undefined : thinking.thinkingLevel };\n\t}\n\t// Keep an invalid suffix as part of the id and fail, rather than resolve a different model\n\tif (request.thinkingSuffix === \"strict\") return { status: \"not-found\" };\n\tconst colonIndex = text.lastIndexOf(\":\");\n\tif (colonIndex === -1) return { status: \"not-found\" };\n\n\tconst suffix = text.substring(colonIndex + 1);\n\tconst inner = resolveText(text.substring(0, colonIndex), request, pool, usable);\n\tif (inner.status === \"not-found\") return inner;\n\treturn {\n\t\t...inner,\n\t\tthinkingLevel: undefined,\n\t\twarning: `Invalid thinking level \"${suffix}\" in pattern \"${text}\". Using default instead.`,\n\t};\n}\n\n/**\n * `provider/rest` is only a hint: the whole text may also be a model id on another provider, such as\n * gateway id `zai/glm-5` or commandcode id `xiaomi/mimo-v2.6-pro`. The named provider wins when usable,\n * since that is what the syntax usually means; otherwise a sole usable raw match wins, since the named\n * provider could not serve the request. An unusable named match is still preferred over unusable raw\n * matches, so `--api-key` can set up the named provider.\n */\nfunction selectReference(\n\ttext: string,\n\tpool: readonly Model<Api>[],\n\tfuzzy: boolean,\n\tusable: (provider: string) => boolean,\n): ResolvedOrAmbiguous | undefined {\n\tconst lowerText = text.toLowerCase();\n\tconst raw = pool.filter((model) => model.id.toLowerCase() === lowerText);\n\tconst split = splitProviderPrefix(text, pool);\n\tlet named: Model<Api> | undefined;\n\tif (split) {\n\t\tconst providerModels = pool.filter((model) => model.provider === split.provider);\n\t\tconst lowerModelText = split.modelText.toLowerCase();\n\t\t// The provider's own literal id (OpenRouter's `openrouter/free`) beats its fuzzy matches\n\t\tnamed =\n\t\t\tproviderModels.find((model) => model.id.toLowerCase() === lowerModelText) ??\n\t\t\traw.find((model) => model.provider === split.provider) ??\n\t\t\t(fuzzy ? bestFuzzyMatch(fuzzyMatches(split.modelText, providerModels)) : undefined);\n\t}\n\n\tconst others = raw.filter((model) => model !== named);\n\tconst candidates = named ? [named, ...others] : others;\n\tif (candidates.length === 0) return undefined;\n\tif (new Set(candidates.map((model) => model.provider)).size === 1)\n\t\treturn { status: \"resolved\", model: candidates[0] };\n\tif (named && usable(named.provider)) return { status: \"resolved\", model: named };\n\tconst usableOthers = others.filter((model) => usable(model.provider));\n\tif (usableOthers.length === 1) return { status: \"resolved\", model: usableOthers[0] };\n\tif (usableOthers.length === 0 && named) return { status: \"resolved\", model: named };\n\treturn { status: \"ambiguous\", candidates, usableCount: usableOthers.length };\n}\n\nfunction fuzzyMatches(text: string, models: readonly Model<Api>[]): Model<Api>[] {\n\tconst lowerText = text.toLowerCase();\n\treturn models.filter(\n\t\t(model) => model.id.toLowerCase().includes(lowerText) || model.name?.toLowerCase().includes(lowerText),\n\t);\n}\n\nfunction selectFuzzy(matches: Model<Api>[], usable: (provider: string) => boolean): ResolvedOrAmbiguous | undefined {\n\tif (matches.length === 0) return undefined;\n\tconst multipleProviders = new Set(matches.map((model) => model.provider)).size > 1;\n\tconst usableMatches = multipleProviders ? matches.filter((model) => usable(model.provider)) : [];\n\tconst pool = usableMatches.length > 0 ? usableMatches : matches;\n\tconst best = bestFuzzyMatch(pool);\n\tif (!best) return undefined;\n\t// The same id on several providers would otherwise be decided by catalog order\n\tconst tied = pool.filter((model) => model.id === best.id);\n\tif (new Set(tied.map((model) => model.provider)).size === 1) return { status: \"resolved\", model: best };\n\treturn {\n\t\tstatus: \"ambiguous\",\n\t\tcandidates: tied,\n\t\tusableCount: usableMatches.length > 0 ? tied.length : 0,\n\t};\n}\n\n/** Prefer aliases (`claude-sonnet-4-5`) over dated versions (`claude-sonnet-4-5-20250929`), then the latest. */\nfunction bestFuzzyMatch(matches: readonly Model<Api>[]): Model<Api> | undefined {\n\tconst aliases = matches.filter((model) => isAlias(model.id));\n\treturn [...(aliases.length > 0 ? aliases : matches)].sort((a, b) => b.id.localeCompare(a.id))[0];\n}\n\nfunction isAlias(id: string): boolean {\n\treturn id.endsWith(\"-latest\") || !/-\\d{8}$/.test(id);\n}\n\nfunction buildFallbackModel(providerModels: [Model<Api>, ...Model<Api>[]], modelId: string): Model<Api> {\n\tconst defaultId = defaultModelPerProvider[providerModels[0].provider as KnownProvider];\n\tconst baseModel = defaultId\n\t\t? (providerModels.find((m) => m.id === defaultId) ?? providerModels[0])\n\t\t: providerModels[0];\n\n\treturn {\n\t\t...baseModel,\n\t\tid: modelId,\n\t\tname: modelId,\n\t};\n}\n\nexport interface ModelScopeDiagnostic {\n\ttype: \"warning\";\n\tcode: \"no-match\" | \"invalid-thinking-level\" | \"ambiguous\";\n\tmessage: string;\n\tpattern: string;\n}\n\nexport interface ResolveModelScopeResult {\n\tscopedModels: ScopedModel[];\n\tdiagnostics: ModelScopeDiagnostic[];\n}\n\n/**\n * Resolve scope patterns (`--models`, `enabledModels`) to models with optional thinking levels.\n *\n * Every model in `models` is usable, so credentials cannot choose between providers offering the same\n * id. All of them are added, with a warning so the user can pick one with `provider/id`.\n */\nexport function resolveModelScopeFromModels(\n\tpatterns: string[],\n\tmodels: readonly Model<Api>[],\n): ResolveModelScopeResult {\n\tconst scopedModels: ScopedModel[] = [];\n\tconst diagnostics: ModelScopeDiagnostic[] = [];\n\tconst add = (model: Model<Api>, thinkingLevel: ThinkingLevel | undefined) => {\n\t\tif (!scopedModels.some((scoped) => modelsAreEqual(scoped.model, model))) {\n\t\t\tscopedModels.push({ model, thinkingLevel });\n\t\t}\n\t};\n\tconst noMatch = (pattern: string) =>\n\t\tdiagnostics.push({ type: \"warning\", code: \"no-match\", message: `No models match pattern \"${pattern}\"`, pattern });\n\tconst ambiguous = (pattern: string, candidates: readonly Model<Api>[]) => {\n\t\tconst providers = [...new Set(candidates.map((m) => m.provider))].sort((a, b) => a.localeCompare(b));\n\t\tdiagnostics.push({\n\t\t\ttype: \"warning\",\n\t\t\tcode: \"ambiguous\",\n\t\t\tmessage: `Pattern \"${pattern}\" matches several providers: ${providers.join(\", \")}. Use provider/id to choose one.`,\n\t\t\tpattern,\n\t\t});\n\t};\n\n\tfor (const pattern of patterns) {\n\t\t// Check if pattern contains glob characters\n\t\tif (pattern.includes(\"*\") || pattern.includes(\"?\") || pattern.includes(\"[\")) {\n\t\t\t// Extract optional thinking level suffix (e.g., \"provider/*:high\")\n\t\t\tconst thinking = splitThinkingSuffix(pattern);\n\t\t\tconst globPattern = thinking?.base ?? pattern;\n\t\t\tconst thinkingLevel = thinking?.thinkingLevel;\n\n\t\t\t// Ids such as `bracketed-model[1m]` are not globs\n\t\t\tconst exact = resolveModelReference(\n\t\t\t\t{ text: globPattern, thinkingSuffix: \"none\", fuzzy: false },\n\t\t\t\tmodels,\n\t\t\t\t() => true,\n\t\t\t);\n\t\t\tlet matches: readonly Model<Api>[] = [];\n\t\t\tif (exact.status === \"resolved\") matches = [exact.model];\n\t\t\telse if (exact.status === \"ambiguous\") {\n\t\t\t\tmatches = exact.candidates;\n\t\t\t\tambiguous(pattern, matches);\n\t\t\t} else {\n\t\t\t\t// Match against \"provider/modelId\" format OR just model ID\n\t\t\t\t// This allows \"*sonnet*\" to match without requiring \"anthropic/*sonnet*\"\n\t\t\t\tmatches = models.filter(\n\t\t\t\t\t(m) =>\n\t\t\t\t\t\tminimatch(`${m.provider}/${m.id}`, globPattern, { nocase: true }) ||\n\t\t\t\t\t\tminimatch(m.id, globPattern, { nocase: true }),\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (matches.length === 0) noMatch(pattern);\n\t\t\tfor (const model of matches) add(model, thinkingLevel);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst result = resolveModelReference(\n\t\t\t{ text: pattern, thinkingSuffix: \"lenient\", fuzzy: true },\n\t\t\tmodels,\n\t\t\t() => true,\n\t\t);\n\t\tif (result.status === \"not-found\") {\n\t\t\tnoMatch(pattern);\n\t\t\tcontinue;\n\t\t}\n\t\tif (result.warning) {\n\t\t\tdiagnostics.push({ type: \"warning\", code: \"invalid-thinking-level\", message: result.warning, pattern });\n\t\t}\n\t\tif (result.status === \"ambiguous\") ambiguous(pattern, result.candidates);\n\t\tconst matches = result.status === \"resolved\" ? [result.model] : result.candidates;\n\t\tfor (const model of matches) add(model, result.thinkingLevel);\n\t}\n\n\treturn { scopedModels, diagnostics };\n}\n\nexport async function resolveModelScopeWithDiagnostics(\n\tpatterns: string[],\n\tmodelRuntime: ModelRuntime,\n\toptions?: AuthOperationOptions,\n): Promise<ResolveModelScopeResult> {\n\treturn resolveModelScopeFromModels(patterns, await modelRuntime.getAvailable(undefined, options));\n}\n\nexport interface ResolveCliModelResult {\n\tmodel: Model<Api> | undefined;\n\tthinkingLevel?: ThinkingLevel;\n\twarning: string | undefined;\n\t/**\n\t * Error message suitable for CLI display.\n\t * When set, model will be undefined.\n\t */\n\terror: string | undefined;\n}\n\n/**\n * Resolve a single model from CLI flags.\n *\n * Supports:\n * - --provider <provider> --model <pattern>\n * - --model <provider>/<pattern>\n * - Fuzzy matching (same rules as model scoping: exact id, then partial id/name)\n *\n * Note: This does not apply the thinking level by itself, but it may *parse* and\n * return a thinking level from \"<pattern>:<thinking>\" so the caller can apply it.\n */\nexport function resolveCliModel(options: {\n\tcliProvider?: string;\n\tcliModel?: string;\n\tcliThinking?: ThinkingLevel;\n\t/** `--api-key` was supplied for the selected provider. */\n\tinlineApiKey?: boolean;\n\tmodelRuntime: ModelRuntime;\n}): ResolveCliModelResult {\n\tconst { cliProvider, cliModel, cliThinking, inlineApiKey, modelRuntime } = options;\n\n\tif (!cliModel) {\n\t\treturn { model: undefined, warning: undefined, error: undefined };\n\t}\n\n\t// Important: use *all* models here, not just models with pre-configured auth.\n\t// This allows \"--api-key\" to be used for first-time setup.\n\tconst models = [...modelRuntime.getModels()];\n\tif (models.length === 0) {\n\t\treturn {\n\t\t\tmodel: undefined,\n\t\t\twarning: undefined,\n\t\t\terror: \"No models available. Check your installation or add models to models.json.\",\n\t\t};\n\t}\n\n\tconst provider = cliProvider\n\t\t? models.find((m) => m.provider.toLowerCase() === cliProvider.toLowerCase())?.provider\n\t\t: undefined;\n\tif (cliProvider && !provider) {\n\t\treturn {\n\t\t\tmodel: undefined,\n\t\t\twarning: undefined,\n\t\t\terror: `Unknown provider \"${cliProvider}\". Use --list-models to see available providers/models.`,\n\t\t};\n\t}\n\n\tconst result = resolveModelReference(\n\t\t{ text: cliModel, provider, thinkingSuffix: \"strict\", fuzzy: true },\n\t\tmodels,\n\t\t// An inline key goes to whichever provider is selected, so stored credentials must not choose it\n\t\tinlineApiKey ? () => false : (providerId) => modelRuntime.hasConfiguredAuth(providerId),\n\t);\n\tif (result.status === \"resolved\") {\n\t\treturn { model: result.model, thinkingLevel: result.thinkingLevel, warning: result.warning, error: undefined };\n\t}\n\tif (result.status === \"ambiguous\") {\n\t\tconst matches = result.candidates\n\t\t\t.map((m) => `${m.provider}/${m.id}`)\n\t\t\t.sort((a, b) => a.localeCompare(b))\n\t\t\t.join(\", \");\n\t\tconst authHint = inlineApiKey\n\t\t\t? \"--api-key does not choose a provider.\"\n\t\t\t: result.usableCount === 0\n\t\t\t\t? \"No matching provider is authenticated.\"\n\t\t\t\t: \"More than one matching provider is authenticated.\";\n\t\treturn {\n\t\t\tmodel: undefined,\n\t\t\twarning: undefined,\n\t\t\terror: `Model \"${cliModel}\" is ambiguous across providers: ${matches}. ${authHint} Use --provider or provider/model.`,\n\t\t};\n\t}\n\n\tconst { target } = result;\n\tif (!target) {\n\t\treturn {\n\t\t\tmodel: undefined,\n\t\t\twarning: undefined,\n\t\t\terror: `Model \"${cliModel}\" not found. Use --list-models to see available models.`,\n\t\t};\n\t}\n\n\t// Use the thinking level suffix only when --thinking is not explicitly provided; otherwise it\n\t// stays part of the custom model id.\n\t// e.g. \"zai-org/GLM-5.1-FP8:high\" → modelId=\"zai-org/GLM-5.1-FP8\", fallbackThinking=\"high\"\n\tconst modelId = cliThinking ? target.modelText : target.modelId;\n\tconst fallbackThinking = cliThinking ? undefined : target.thinkingLevel;\n\tconst fallbackModel = buildFallbackModel(target.providerModels, modelId);\n\tconst requestedThinking = cliThinking ?? fallbackThinking;\n\treturn {\n\t\tmodel: requestedThinking && requestedThinking !== \"off\" ? { ...fallbackModel, reasoning: true } : fallbackModel,\n\t\tthinkingLevel: fallbackThinking,\n\t\twarning: `Model \"${modelId}\" not found for provider \"${target.provider}\". Using custom model id.`,\n\t\terror: undefined,\n\t};\n}\n\nexport interface InitialModelResult {\n\tmodel: Model<Api> | undefined;\n\tthinkingLevel: ThinkingLevel;\n\tfallbackMessage: string | undefined;\n}\n\n/**\n * Find the initial model to use based on priority:\n * 1. First model from scoped models (if not continuing/resuming)\n * 2. Saved default from settings\n * 3. First available model with valid API key\n */\nexport async function findInitialModel(options: {\n\tscopedModels: ScopedModel[];\n\tisContinuing: boolean;\n\tdefaultProvider?: string;\n\tdefaultModelId?: string;\n\tdefaultThinkingLevel?: ThinkingLevel;\n\tmodelThinkingLevels?: Record<string, ThinkingLevel>;\n\tmodelRuntime: ModelRuntime;\n}): Promise<InitialModelResult> {\n\tconst {\n\t\tscopedModels,\n\t\tisContinuing,\n\t\tdefaultProvider,\n\t\tdefaultModelId,\n\t\tdefaultThinkingLevel,\n\t\tmodelThinkingLevels,\n\t\tmodelRuntime,\n\t} = options;\n\n\tlet model: Model<Api> | undefined;\n\tlet thinkingLevel: ThinkingLevel = DEFAULT_THINKING_LEVEL;\n\n\t// 1. Use first model from scoped models (skip if continuing/resuming)\n\tif (scopedModels.length > 0 && !isContinuing) {\n\t\tconst scopedModel = scopedModels[0];\n\t\tconst perModel = modelThinkingLevels?.[`${scopedModel.model.provider}/${scopedModel.model.id}`];\n\t\treturn {\n\t\t\tmodel: scopedModel.model,\n\t\t\tthinkingLevel: scopedModel.thinkingLevel ?? perModel ?? defaultThinkingLevel ?? DEFAULT_THINKING_LEVEL,\n\t\t\tfallbackMessage: undefined,\n\t\t};\n\t}\n\n\t// 2. Try saved default from settings if auth is configured.\n\tif (defaultProvider && defaultModelId) {\n\t\tconst found = modelRuntime.getModel(defaultProvider, defaultModelId);\n\t\tif (found && modelRuntime.hasConfiguredAuth(found.provider)) {\n\t\t\tmodel = found;\n\t\t\tconst perModel = modelThinkingLevels?.[`${defaultProvider}/${defaultModelId}`];\n\t\t\tif (perModel) {\n\t\t\t\tthinkingLevel = perModel;\n\t\t\t} else if (defaultThinkingLevel) {\n\t\t\t\tthinkingLevel = defaultThinkingLevel;\n\t\t\t}\n\t\t\treturn { model, thinkingLevel, fallbackMessage: undefined };\n\t\t}\n\t}\n\n\t// 3. Try first available model with valid API key\n\tconst availableModels = [...modelRuntime.getAvailableSnapshot()];\n\n\tif (availableModels.length > 0) {\n\t\t// Try to find a default model from known providers\n\t\tfor (const provider of Object.keys(defaultModelPerProvider) as KnownProvider[]) {\n\t\t\tconst defaultId = defaultModelPerProvider[provider];\n\t\t\tconst match = availableModels.find((m) => m.provider === provider && m.id === defaultId);\n\t\t\tif (match) {\n\t\t\t\treturn { model: match, thinkingLevel: DEFAULT_THINKING_LEVEL, fallbackMessage: undefined };\n\t\t\t}\n\t\t}\n\n\t\t// If no default found, use first available\n\t\treturn { model: availableModels[0], thinkingLevel: DEFAULT_THINKING_LEVEL, fallbackMessage: undefined };\n\t}\n\n\t// 4. No model found\n\treturn { model: undefined, thinkingLevel: DEFAULT_THINKING_LEVEL, fallbackMessage: undefined };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"model-resolver.js","sourceRoot":"","s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,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,sBAAsB,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC;AAChG,CAAC","sourcesContent":["/**\n * Model resolution, scoping, and initial selection\n */\n\nimport type { ThinkingLevel } from \"@diffra-ai/agent-core\";\nimport { type Api, type AuthOperationOptions, type KnownProvider, type Model, modelsAreEqual } from \"@diffra-ai/ai\";\nimport { minimatch } from \"minimatch\";\nimport { isValidThinkingLevel } from \"../cli/args.ts\";\nimport { DEFAULT_THINKING_LEVEL } from \"./defaults.ts\";\nimport type { ModelRuntime } from \"./model-runtime.ts\";\n\n/** Default chat model IDs for providers with built-in chat models. */\nexport const defaultModelPerProvider: Partial<Record<KnownProvider, string>> = {\n\t\"amazon-bedrock\": \"us.anthropic.claude-opus-5-5\",\n\t\"ant-ling\": \"Ring-2.6-1T\",\n\tanthropic: \"claude-opus-5-5\",\n\topenai: \"gpt-6.2-sol\",\n\tazure: \"gpt-6.2-sol\",\n\t\"openai-codex\": \"gpt-6.2-sol\",\n\tradius: \"balanced\",\n\tnvidia: \"nvidia/nemotron-3.5-super-vl-120b-a12b\",\n\tdeepseek: \"deepseek-v4-pro\",\n\tgoogle: \"gemini-4-argon\",\n\t\"google-vertex\": \"gemini-4-argon\",\n\t\"github-copilot\": \"gpt-6.1-sol\",\n\topenrouter: \"moonshotai/kimi-k2.7-code\",\n\t\"vercel-ai-gateway\": \"zai/glm-5.3\",\n\txai: \"grok-4.7\",\n\tgroq: \"openai/gpt-oss-120b\",\n\tcerebras: \"gpt-oss-120b\",\n\tzai: \"glm-5.3\",\n\t\"zai-coding-cn\": \"glm-5.3\",\n\tmistral: \"mistral-medium-latest\",\n\tminimax: \"MiniMax-M3\",\n\t\"minimax-cn\": \"MiniMax-M3\",\n\tmoonshotai: \"kimi-k2.7-code\",\n\t\"moonshotai-cn\": \"kimi-k2.7-code\",\n\thuggingface: \"moonshotai/Kimi-K2.7-Code\",\n\tfireworks: \"accounts/fireworks/models/kimi-k3\",\n\ttogether: \"moonshotai/Kimi-K3\",\n\tbaseten: \"zai-org/GLM-5.3\",\n\topencode: \"kimi-k2.7-code\",\n\t\"opencode-go\": \"kimi-k3.1-pro\",\n\t\"kimi-coding\": \"kimi-for-coding\",\n\tmeta: \"muse-spark-1.3\",\n\t\"cloudflare-workers-ai\": \"@cf/zai-org/glm-5.3\",\n\t\"cloudflare-ai-gateway\": \"workers-ai/@cf/zai-org/glm-5.3\",\n\t\"qwen-token-plan\": \"qwen3.8-max\",\n\t\"qwen-token-plan-cn\": \"qwen3.8-max\",\n\t\"qwen-token-plan-individual\": \"qwen3.8-max\",\n\t\"qwen-token-plan-individual-cn\": \"qwen3.8-max\",\n\txiaomi: \"mimo-v2.6-pro\",\n\t\"xiaomi-token-plan-cn\": \"mimo-v2.6-pro\",\n\t\"xiaomi-token-plan-ams\": \"mimo-v2.6-pro\",\n\t\"xiaomi-token-plan-sgp\": \"mimo-v2.6-pro\",\n};\n\nexport interface ScopedModel {\n\tmodel: Model<Api>;\n\t/** Thinking level if explicitly specified in pattern (e.g., \"model:high\"), undefined otherwise */\n\tthinkingLevel?: ThinkingLevel;\n}\n\n/*\n * Model reference resolution. Candidates are collected before a provider is chosen, so catalog order\n * never decides the provider and an ambiguous match is reported instead of falling through to a\n * weaker one.\n */\n\nexport interface ModelReferenceRequest {\n\t/** Bare model id or `provider/id`, optionally followed by `:<thinking>`. */\n\ttext: string;\n\t/** Only consider models from this provider. */\n\tprovider?: string;\n\t/**\n\t * A trailing `:<suffix>` is only considered when the full text matches no model, since ids such as\n\t * OpenRouter's `qwen/qwen3-coder:exacto` contain colons.\n\t * - `none`: the suffix stays part of the id\n\t * - `strict`: a valid thinking level is parsed; any other suffix stays part of the id\n\t * - `lenient`: like `strict`, but an invalid suffix is dropped with a warning\n\t */\n\tthinkingSuffix: \"none\" | \"strict\" | \"lenient\";\n\t/** Match id and name substrings when no exact match exists. */\n\tfuzzy: boolean;\n}\n\nexport type ModelReferenceResult =\n\t| { status: \"resolved\"; model: Model<Api>; thinkingLevel?: ThinkingLevel; warning?: string }\n\t| {\n\t\t\tstatus: \"ambiguous\";\n\t\t\tcandidates: Model<Api>[];\n\t\t\tusableCount: number;\n\t\t\tthinkingLevel?: ThinkingLevel;\n\t\t\twarning?: string;\n\t }\n\t| {\n\t\t\tstatus: \"not-found\";\n\t\t\t/** Set when a provider is explicit or named by a `provider/` prefix, for building a custom model id. */\n\t\t\ttarget?: ModelReferenceTarget;\n\t };\n\nexport interface ModelReferenceTarget {\n\tprovider: string;\n\tproviderModels: [Model<Api>, ...Model<Api>[]];\n\t/** Text after the provider prefix as typed, including any `:<suffix>`. */\n\tmodelText: string;\n\t/** `modelText` without a valid thinking suffix (unless `thinkingSuffix` is `none`). */\n\tmodelId: string;\n\tthinkingLevel?: ThinkingLevel;\n}\n\ntype ResolvedOrAmbiguous = Exclude<ModelReferenceResult, { status: \"not-found\" }>;\n\nfunction splitThinkingSuffix(text: string): { base: string; thinkingLevel: ThinkingLevel } | undefined {\n\tconst colonIndex = text.lastIndexOf(\":\");\n\tconst suffix = text.substring(colonIndex + 1);\n\tif (colonIndex === -1 || !isValidThinkingLevel(suffix)) return undefined;\n\treturn { base: text.substring(0, colonIndex), thinkingLevel: suffix };\n}\n\nfunction splitProviderPrefix(\n\ttext: string,\n\tmodels: readonly Model<Api>[],\n): { provider: string; modelText: string } | undefined {\n\t// Provider ids may contain \"/\" themselves (e.g. URL-derived ids), so match known ids, longest first\n\tconst lowerText = text.toLowerCase();\n\tlet best: { provider: string; modelText: string } | undefined;\n\tfor (const { provider } of models) {\n\t\tconst prefix = provider.trim().toLowerCase();\n\t\tif (!prefix || (best && best.provider.length >= provider.length)) continue;\n\t\tconst slashIndex = lowerText.indexOf(\"/\", prefix.length);\n\t\tif (slashIndex === -1 || lowerText.substring(0, slashIndex).trim() !== prefix) continue;\n\t\tconst modelText = text.substring(slashIndex + 1).trim();\n\t\tif (modelText) best = { provider, modelText };\n\t}\n\treturn best;\n}\n\n/**\n * `usable` only breaks ties between providers, so a unique match resolves even without credentials\n * (`--api-key` first-time setup).\n */\nexport function resolveModelReference(\n\trequest: ModelReferenceRequest,\n\tmodels: readonly Model<Api>[],\n\tusable: (provider: string) => boolean,\n): ModelReferenceResult {\n\tconst text = request.text.trim();\n\tif (!text) return { status: \"not-found\" };\n\tconst constraint = request.provider?.toLowerCase();\n\tconst pool = constraint ? models.filter((model) => model.provider.toLowerCase() === constraint) : models;\n\tconst result = resolveText(text, request, pool, usable);\n\tif (result.status !== \"not-found\") return result;\n\n\tconst split = splitProviderPrefix(text, pool);\n\tconst anchor = constraint ? pool[0] : pool.find((model) => model.provider === split?.provider);\n\tif (!anchor) return result;\n\tconst modelText = split?.modelText ?? text;\n\tconst suffix = request.thinkingSuffix === \"none\" ? undefined : splitThinkingSuffix(modelText);\n\treturn {\n\t\tstatus: \"not-found\",\n\t\ttarget: {\n\t\t\tprovider: anchor.provider,\n\t\t\tproviderModels: [anchor, ...pool.filter((model) => model.provider === anchor.provider && model !== anchor)],\n\t\t\tmodelText,\n\t\t\tmodelId: suffix?.base ?? modelText,\n\t\t\tthinkingLevel: suffix?.thinkingLevel,\n\t\t},\n\t};\n}\n\n/** Exact `provider/id` or bare id lookup without thinking suffixes or fuzzy matching. */\nexport function findExactModelReferenceMatch(\n\tmodelReference: string,\n\tmodels: readonly Model<Api>[],\n): Model<Api> | undefined {\n\tconst result = resolveModelReference(\n\t\t{ text: modelReference, thinkingSuffix: \"none\", fuzzy: false },\n\t\tmodels,\n\t\t() => true,\n\t);\n\treturn result.status === \"resolved\" ? result.model : undefined;\n}\n\nfunction resolveText(\n\ttext: string,\n\trequest: ModelReferenceRequest,\n\tpool: readonly Model<Api>[],\n\tusable: (provider: string) => boolean,\n): ModelReferenceResult {\n\tconst reference = selectReference(text, pool, request.fuzzy, usable);\n\tif (reference) return reference;\n\n\tif (request.fuzzy) {\n\t\tconst fuzzy = selectFuzzy(fuzzyMatches(text, pool), usable);\n\t\tif (fuzzy) return fuzzy;\n\t}\n\n\tif (request.thinkingSuffix === \"none\") return { status: \"not-found\" };\n\tconst thinking = splitThinkingSuffix(text);\n\tif (thinking) {\n\t\tconst inner = resolveText(thinking.base, request, pool, usable);\n\t\tif (inner.status === \"not-found\") return inner;\n\t\t// Only use this thinking level if no warning from inner recursion\n\t\treturn { ...inner, thinkingLevel: inner.warning ? undefined : thinking.thinkingLevel };\n\t}\n\t// Keep an invalid suffix as part of the id and fail, rather than resolve a different model\n\tif (request.thinkingSuffix === \"strict\") return { status: \"not-found\" };\n\tconst colonIndex = text.lastIndexOf(\":\");\n\tif (colonIndex === -1) return { status: \"not-found\" };\n\n\tconst suffix = text.substring(colonIndex + 1);\n\tconst inner = resolveText(text.substring(0, colonIndex), request, pool, usable);\n\tif (inner.status === \"not-found\") return inner;\n\treturn {\n\t\t...inner,\n\t\tthinkingLevel: undefined,\n\t\twarning: `Invalid thinking level \"${suffix}\" in pattern \"${text}\". Using default instead.`,\n\t};\n}\n\n/**\n * `provider/rest` is only a hint: the whole text may also be a model id on another provider, such as\n * gateway id `zai/glm-5` or commandcode id `xiaomi/mimo-v2.6-pro`. The named provider wins when usable,\n * since that is what the syntax usually means; otherwise a sole usable raw match wins, since the named\n * provider could not serve the request. An unusable named match is still preferred over unusable raw\n * matches, so `--api-key` can set up the named provider.\n */\nfunction selectReference(\n\ttext: string,\n\tpool: readonly Model<Api>[],\n\tfuzzy: boolean,\n\tusable: (provider: string) => boolean,\n): ResolvedOrAmbiguous | undefined {\n\tconst lowerText = text.toLowerCase();\n\tconst raw = pool.filter((model) => model.id.toLowerCase() === lowerText);\n\tconst split = splitProviderPrefix(text, pool);\n\tlet named: Model<Api> | undefined;\n\tif (split) {\n\t\tconst providerModels = pool.filter((model) => model.provider === split.provider);\n\t\tconst lowerModelText = split.modelText.toLowerCase();\n\t\t// The provider's own literal id (OpenRouter's `openrouter/free`) beats its fuzzy matches\n\t\tnamed =\n\t\t\tproviderModels.find((model) => model.id.toLowerCase() === lowerModelText) ??\n\t\t\traw.find((model) => model.provider === split.provider) ??\n\t\t\t(fuzzy ? bestFuzzyMatch(fuzzyMatches(split.modelText, providerModels)) : undefined);\n\t}\n\n\tconst others = raw.filter((model) => model !== named);\n\tconst candidates = named ? [named, ...others] : others;\n\tif (candidates.length === 0) return undefined;\n\tif (new Set(candidates.map((model) => model.provider)).size === 1)\n\t\treturn { status: \"resolved\", model: candidates[0] };\n\tif (named && usable(named.provider)) return { status: \"resolved\", model: named };\n\tconst usableOthers = others.filter((model) => usable(model.provider));\n\tif (usableOthers.length === 1) return { status: \"resolved\", model: usableOthers[0] };\n\tif (usableOthers.length === 0 && named) return { status: \"resolved\", model: named };\n\treturn { status: \"ambiguous\", candidates, usableCount: usableOthers.length };\n}\n\nfunction fuzzyMatches(text: string, models: readonly Model<Api>[]): Model<Api>[] {\n\tconst lowerText = text.toLowerCase();\n\treturn models.filter(\n\t\t(model) => model.id.toLowerCase().includes(lowerText) || model.name?.toLowerCase().includes(lowerText),\n\t);\n}\n\nfunction selectFuzzy(matches: Model<Api>[], usable: (provider: string) => boolean): ResolvedOrAmbiguous | undefined {\n\tif (matches.length === 0) return undefined;\n\tconst multipleProviders = new Set(matches.map((model) => model.provider)).size > 1;\n\tconst usableMatches = multipleProviders ? matches.filter((model) => usable(model.provider)) : [];\n\tconst pool = usableMatches.length > 0 ? usableMatches : matches;\n\tconst best = bestFuzzyMatch(pool);\n\tif (!best) return undefined;\n\t// The same id on several providers would otherwise be decided by catalog order\n\tconst tied = pool.filter((model) => model.id === best.id);\n\tif (new Set(tied.map((model) => model.provider)).size === 1) return { status: \"resolved\", model: best };\n\treturn {\n\t\tstatus: \"ambiguous\",\n\t\tcandidates: tied,\n\t\tusableCount: usableMatches.length > 0 ? tied.length : 0,\n\t};\n}\n\n/** Prefer aliases (`claude-sonnet-4-5`) over dated versions (`claude-sonnet-4-5-20250929`), then the latest. */\nfunction bestFuzzyMatch(matches: readonly Model<Api>[]): Model<Api> | undefined {\n\tconst aliases = matches.filter((model) => isAlias(model.id));\n\treturn [...(aliases.length > 0 ? aliases : matches)].sort((a, b) => b.id.localeCompare(a.id))[0];\n}\n\nfunction isAlias(id: string): boolean {\n\treturn id.endsWith(\"-latest\") || !/-\\d{8}$/.test(id);\n}\n\nfunction buildFallbackModel(providerModels: [Model<Api>, ...Model<Api>[]], modelId: string): Model<Api> {\n\tconst defaultId = defaultModelPerProvider[providerModels[0].provider as KnownProvider];\n\tconst baseModel = defaultId\n\t\t? (providerModels.find((m) => m.id === defaultId) ?? providerModels[0])\n\t\t: providerModels[0];\n\n\treturn {\n\t\t...baseModel,\n\t\tid: modelId,\n\t\tname: modelId,\n\t};\n}\n\nexport interface ModelScopeDiagnostic {\n\ttype: \"warning\";\n\tcode: \"no-match\" | \"invalid-thinking-level\" | \"ambiguous\";\n\tmessage: string;\n\tpattern: string;\n}\n\nexport interface ResolveModelScopeResult {\n\tscopedModels: ScopedModel[];\n\tdiagnostics: ModelScopeDiagnostic[];\n}\n\n/**\n * Resolve scope patterns (`--models`, `enabledModels`) to models with optional thinking levels.\n *\n * Every model in `models` is usable, so credentials cannot choose between providers offering the same\n * id. All of them are added, with a warning so the user can pick one with `provider/id`.\n */\nexport function resolveModelScopeFromModels(\n\tpatterns: string[],\n\tmodels: readonly Model<Api>[],\n): ResolveModelScopeResult {\n\tconst scopedModels: ScopedModel[] = [];\n\tconst diagnostics: ModelScopeDiagnostic[] = [];\n\tconst add = (model: Model<Api>, thinkingLevel: ThinkingLevel | undefined) => {\n\t\tif (!scopedModels.some((scoped) => modelsAreEqual(scoped.model, model))) {\n\t\t\tscopedModels.push({ model, thinkingLevel });\n\t\t}\n\t};\n\tconst noMatch = (pattern: string) =>\n\t\tdiagnostics.push({ type: \"warning\", code: \"no-match\", message: `No models match pattern \"${pattern}\"`, pattern });\n\tconst ambiguous = (pattern: string, candidates: readonly Model<Api>[]) => {\n\t\tconst providers = [...new Set(candidates.map((m) => m.provider))].sort((a, b) => a.localeCompare(b));\n\t\tdiagnostics.push({\n\t\t\ttype: \"warning\",\n\t\t\tcode: \"ambiguous\",\n\t\t\tmessage: `Pattern \"${pattern}\" matches several providers: ${providers.join(\", \")}. Use provider/id to choose one.`,\n\t\t\tpattern,\n\t\t});\n\t};\n\n\tfor (const pattern of patterns) {\n\t\t// Check if pattern contains glob characters\n\t\tif (pattern.includes(\"*\") || pattern.includes(\"?\") || pattern.includes(\"[\")) {\n\t\t\t// Extract optional thinking level suffix (e.g., \"provider/*:high\")\n\t\t\tconst thinking = splitThinkingSuffix(pattern);\n\t\t\tconst globPattern = thinking?.base ?? pattern;\n\t\t\tconst thinkingLevel = thinking?.thinkingLevel;\n\n\t\t\t// Ids such as `bracketed-model[1m]` are not globs\n\t\t\tconst exact = resolveModelReference(\n\t\t\t\t{ text: globPattern, thinkingSuffix: \"none\", fuzzy: false },\n\t\t\t\tmodels,\n\t\t\t\t() => true,\n\t\t\t);\n\t\t\tlet matches: readonly Model<Api>[] = [];\n\t\t\tif (exact.status === \"resolved\") matches = [exact.model];\n\t\t\telse if (exact.status === \"ambiguous\") {\n\t\t\t\tmatches = exact.candidates;\n\t\t\t\tambiguous(pattern, matches);\n\t\t\t} else {\n\t\t\t\t// Match against \"provider/modelId\" format OR just model ID\n\t\t\t\t// This allows \"*sonnet*\" to match without requiring \"anthropic/*sonnet*\"\n\t\t\t\tmatches = models.filter(\n\t\t\t\t\t(m) =>\n\t\t\t\t\t\tminimatch(`${m.provider}/${m.id}`, globPattern, { nocase: true }) ||\n\t\t\t\t\t\tminimatch(m.id, globPattern, { nocase: true }),\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (matches.length === 0) noMatch(pattern);\n\t\t\tfor (const model of matches) add(model, thinkingLevel);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst result = resolveModelReference(\n\t\t\t{ text: pattern, thinkingSuffix: \"lenient\", fuzzy: true },\n\t\t\tmodels,\n\t\t\t() => true,\n\t\t);\n\t\tif (result.status === \"not-found\") {\n\t\t\tnoMatch(pattern);\n\t\t\tcontinue;\n\t\t}\n\t\tif (result.warning) {\n\t\t\tdiagnostics.push({ type: \"warning\", code: \"invalid-thinking-level\", message: result.warning, pattern });\n\t\t}\n\t\tif (result.status === \"ambiguous\") ambiguous(pattern, result.candidates);\n\t\tconst matches = result.status === \"resolved\" ? [result.model] : result.candidates;\n\t\tfor (const model of matches) add(model, result.thinkingLevel);\n\t}\n\n\treturn { scopedModels, diagnostics };\n}\n\nexport async function resolveModelScopeWithDiagnostics(\n\tpatterns: string[],\n\tmodelRuntime: ModelRuntime,\n\toptions?: AuthOperationOptions,\n): Promise<ResolveModelScopeResult> {\n\treturn resolveModelScopeFromModels(patterns, await modelRuntime.getAvailable(undefined, options));\n}\n\nexport interface ResolveCliModelResult {\n\tmodel: Model<Api> | undefined;\n\tthinkingLevel?: ThinkingLevel;\n\twarning: string | undefined;\n\t/**\n\t * Error message suitable for CLI display.\n\t * When set, model will be undefined.\n\t */\n\terror: string | undefined;\n}\n\n/**\n * Resolve a single model from CLI flags.\n *\n * Supports:\n * - --provider <provider> --model <pattern>\n * - --model <provider>/<pattern>\n * - Fuzzy matching (same rules as model scoping: exact id, then partial id/name)\n *\n * Note: This does not apply the thinking level by itself, but it may *parse* and\n * return a thinking level from \"<pattern>:<thinking>\" so the caller can apply it.\n */\nexport function resolveCliModel(options: {\n\tcliProvider?: string;\n\tcliModel?: string;\n\tcliThinking?: ThinkingLevel;\n\t/** `--api-key` was supplied for the selected provider. */\n\tinlineApiKey?: boolean;\n\tmodelRuntime: ModelRuntime;\n}): ResolveCliModelResult {\n\tconst { cliProvider, cliModel, cliThinking, inlineApiKey, modelRuntime } = options;\n\n\tif (!cliModel) {\n\t\treturn { model: undefined, warning: undefined, error: undefined };\n\t}\n\n\t// Important: use *all* models here, not just models with pre-configured auth.\n\t// This allows \"--api-key\" to be used for first-time setup.\n\tconst models = [...modelRuntime.getModels()];\n\tif (models.length === 0) {\n\t\treturn {\n\t\t\tmodel: undefined,\n\t\t\twarning: undefined,\n\t\t\terror: \"No models available. Check your installation or add models to models.json.\",\n\t\t};\n\t}\n\n\tconst provider = cliProvider\n\t\t? models.find((m) => m.provider.toLowerCase() === cliProvider.toLowerCase())?.provider\n\t\t: undefined;\n\tif (cliProvider && !provider) {\n\t\treturn {\n\t\t\tmodel: undefined,\n\t\t\twarning: undefined,\n\t\t\terror: `Unknown provider \"${cliProvider}\". Use --list-models to see available providers/models.`,\n\t\t};\n\t}\n\n\tconst result = resolveModelReference(\n\t\t{ text: cliModel, provider, thinkingSuffix: \"strict\", fuzzy: true },\n\t\tmodels,\n\t\t// An inline key goes to whichever provider is selected, so stored credentials must not choose it\n\t\tinlineApiKey ? () => false : (providerId) => modelRuntime.hasConfiguredAuth(providerId),\n\t);\n\tif (result.status === \"resolved\") {\n\t\treturn { model: result.model, thinkingLevel: result.thinkingLevel, warning: result.warning, error: undefined };\n\t}\n\tif (result.status === \"ambiguous\") {\n\t\tconst matches = result.candidates\n\t\t\t.map((m) => `${m.provider}/${m.id}`)\n\t\t\t.sort((a, b) => a.localeCompare(b))\n\t\t\t.join(\", \");\n\t\tconst authHint = inlineApiKey\n\t\t\t? \"--api-key does not choose a provider.\"\n\t\t\t: result.usableCount === 0\n\t\t\t\t? \"No matching provider is authenticated.\"\n\t\t\t\t: \"More than one matching provider is authenticated.\";\n\t\treturn {\n\t\t\tmodel: undefined,\n\t\t\twarning: undefined,\n\t\t\terror: `Model \"${cliModel}\" is ambiguous across providers: ${matches}. ${authHint} Use --provider or provider/model.`,\n\t\t};\n\t}\n\n\tconst { target } = result;\n\tif (!target) {\n\t\treturn {\n\t\t\tmodel: undefined,\n\t\t\twarning: undefined,\n\t\t\terror: `Model \"${cliModel}\" not found. Use --list-models to see available models.`,\n\t\t};\n\t}\n\n\t// Use the thinking level suffix only when --thinking is not explicitly provided; otherwise it\n\t// stays part of the custom model id.\n\t// e.g. \"zai-org/GLM-5.1-FP8:high\" → modelId=\"zai-org/GLM-5.1-FP8\", fallbackThinking=\"high\"\n\tconst modelId = cliThinking ? target.modelText : target.modelId;\n\tconst fallbackThinking = cliThinking ? undefined : target.thinkingLevel;\n\tconst fallbackModel = buildFallbackModel(target.providerModels, modelId);\n\tconst requestedThinking = cliThinking ?? fallbackThinking;\n\treturn {\n\t\tmodel: requestedThinking && requestedThinking !== \"off\" ? { ...fallbackModel, reasoning: true } : fallbackModel,\n\t\tthinkingLevel: fallbackThinking,\n\t\twarning: `Model \"${modelId}\" not found for provider \"${target.provider}\". Using custom model id.`,\n\t\terror: undefined,\n\t};\n}\n\nexport interface InitialModelResult {\n\tmodel: Model<Api> | undefined;\n\tthinkingLevel: ThinkingLevel;\n\tfallbackMessage: string | undefined;\n}\n\n/**\n * Find the initial model to use based on priority:\n * 1. First model from scoped models (if not continuing/resuming)\n * 2. Saved default from settings\n * 3. First available model with valid API key\n */\nexport async function findInitialModel(options: {\n\tscopedModels: ScopedModel[];\n\tisContinuing: boolean;\n\tdefaultProvider?: string;\n\tdefaultModelId?: string;\n\tdefaultThinkingLevel?: ThinkingLevel;\n\tmodelThinkingLevels?: Record<string, ThinkingLevel>;\n\tmodelRuntime: ModelRuntime;\n}): Promise<InitialModelResult> {\n\tconst {\n\t\tscopedModels,\n\t\tisContinuing,\n\t\tdefaultProvider,\n\t\tdefaultModelId,\n\t\tdefaultThinkingLevel,\n\t\tmodelThinkingLevels,\n\t\tmodelRuntime,\n\t} = options;\n\n\tlet model: Model<Api> | undefined;\n\tlet thinkingLevel: ThinkingLevel = DEFAULT_THINKING_LEVEL;\n\n\t// 1. Use first model from scoped models (skip if continuing/resuming)\n\tif (scopedModels.length > 0 && !isContinuing) {\n\t\tconst scopedModel = scopedModels[0];\n\t\tconst perModel = modelThinkingLevels?.[`${scopedModel.model.provider}/${scopedModel.model.id}`];\n\t\treturn {\n\t\t\tmodel: scopedModel.model,\n\t\t\tthinkingLevel: scopedModel.thinkingLevel ?? perModel ?? defaultThinkingLevel ?? DEFAULT_THINKING_LEVEL,\n\t\t\tfallbackMessage: undefined,\n\t\t};\n\t}\n\n\t// 2. Try saved default from settings if auth is configured.\n\tif (defaultProvider && defaultModelId) {\n\t\tconst found = modelRuntime.getModel(defaultProvider, defaultModelId);\n\t\tif (found && modelRuntime.hasConfiguredAuth(found.provider)) {\n\t\t\tmodel = found;\n\t\t\tconst perModel = modelThinkingLevels?.[`${defaultProvider}/${defaultModelId}`];\n\t\t\tif (perModel) {\n\t\t\t\tthinkingLevel = perModel;\n\t\t\t} else if (defaultThinkingLevel) {\n\t\t\t\tthinkingLevel = defaultThinkingLevel;\n\t\t\t}\n\t\t\treturn { model, thinkingLevel, fallbackMessage: undefined };\n\t\t}\n\t}\n\n\t// 3. Try first available model with valid API key\n\tconst availableModels = [...modelRuntime.getAvailableSnapshot()];\n\n\tif (availableModels.length > 0) {\n\t\t// Try to find a default model from known providers\n\t\tfor (const provider of Object.keys(defaultModelPerProvider) as KnownProvider[]) {\n\t\t\tconst defaultId = defaultModelPerProvider[provider];\n\t\t\tconst match = availableModels.find((m) => m.provider === provider && m.id === defaultId);\n\t\t\tif (match) {\n\t\t\t\treturn { model: match, thinkingLevel: DEFAULT_THINKING_LEVEL, fallbackMessage: undefined };\n\t\t\t}\n\t\t}\n\n\t\t// If no default found, use first available\n\t\treturn { model: availableModels[0], thinkingLevel: DEFAULT_THINKING_LEVEL, fallbackMessage: undefined };\n\t}\n\n\t// 4. No model found\n\treturn { model: undefined, thinkingLevel: DEFAULT_THINKING_LEVEL, fallbackMessage: undefined };\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vercel, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: find-skills
|
|
3
|
+
description: Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. Use when the user is looking for functionality that might exist as an installable skill.
|
|
4
|
+
license: MIT (see LICENSE). Adapted for Diffra from vercel-labs/skills.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Find Skills
|
|
8
|
+
|
|
9
|
+
Discover and install skills from the open agent skills ecosystem.
|
|
10
|
+
|
|
11
|
+
## When to use
|
|
12
|
+
|
|
13
|
+
Use this skill when the user:
|
|
14
|
+
|
|
15
|
+
- Asks "how do I do X" where X might be a common task with an existing skill
|
|
16
|
+
- Says "find a skill for X" or "is there a skill for X"
|
|
17
|
+
- Asks "can you do X" where X is a specialized capability
|
|
18
|
+
- Wants to extend what the agent can do, or search for tools, templates, or workflows
|
|
19
|
+
- Wishes they had help with a specific domain (design, testing, deployment, etc.)
|
|
20
|
+
|
|
21
|
+
## The Skills CLI
|
|
22
|
+
|
|
23
|
+
The Skills CLI (`npx skills`, from vercel-labs/skills) is a package manager for agent skills. It needs Node.js and network access.
|
|
24
|
+
|
|
25
|
+
- `npx skills find <query>` searches for skills by keyword. Pass a query: without one it opens an interactive prompt that a non-interactive shell cannot answer.
|
|
26
|
+
- `npx skills add <owner/repo@skill>` installs a skill.
|
|
27
|
+
- `npx skills update` updates installed skills.
|
|
28
|
+
|
|
29
|
+
Browse skills at https://skills.sh/.
|
|
30
|
+
|
|
31
|
+
## Where Diffra loads skills from
|
|
32
|
+
|
|
33
|
+
Diffra loads skills from these folders, among others:
|
|
34
|
+
|
|
35
|
+
| Scope | Folder |
|
|
36
|
+
|---|---|
|
|
37
|
+
| User (every project) | `~/.agents/skills/` and `~/.diffra/agent/skills/` |
|
|
38
|
+
| Project | `.agents/skills/` from the working directory up to the repository root, and `.diffra/skills/` |
|
|
39
|
+
|
|
40
|
+
The Skills CLI does not know Diffra by name. Install with `-a pi`: that target writes to `.agents/skills/` in the project, or `~/.agents/skills/` with `-g`, both of which Diffra reads. Without `-a`, the CLI asks which agents to install for or picks the ones it detects, which may not include a folder Diffra reads.
|
|
41
|
+
|
|
42
|
+
Project skills load only in a trusted project. A new skill is available after `/reload` or in a new session, as `/skill:<name>`.
|
|
43
|
+
|
|
44
|
+
## How to help
|
|
45
|
+
|
|
46
|
+
### 1. Understand the need
|
|
47
|
+
|
|
48
|
+
Identify the domain (React, testing, design, deployment), the specific task (writing tests, creating animations, reviewing PRs), and whether the task is common enough that a skill likely exists.
|
|
49
|
+
|
|
50
|
+
### 2. Check the leaderboard
|
|
51
|
+
|
|
52
|
+
Before searching, check the [skills.sh leaderboard](https://skills.sh/) for a well-known skill in the domain. It ranks skills by total installs. For example:
|
|
53
|
+
|
|
54
|
+
- `vercel-labs/agent-skills`: React, Next.js, web design
|
|
55
|
+
- `anthropics/skills`: frontend design, document processing
|
|
56
|
+
|
|
57
|
+
### 3. Search
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
npx skills find react performance
|
|
61
|
+
npx skills find pr review
|
|
62
|
+
npx skills find changelog
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 4. Verify quality before recommending
|
|
66
|
+
|
|
67
|
+
Do not recommend a skill on search results alone. Check:
|
|
68
|
+
|
|
69
|
+
1. **Install count**: prefer skills with 1K+ installs; be cautious below 100.
|
|
70
|
+
2. **Source reputation**: official sources (`vercel-labs`, `anthropics`, `microsoft`) are more trustworthy than unknown authors.
|
|
71
|
+
3. **Repository**: look at the source repository. Treat a repository with fewer than 100 stars with skepticism.
|
|
72
|
+
4. **Contents**: skills run with the agent's permissions and can tell it to run scripts. Read the skill's `SKILL.md` and look at any scripts it bundles before installing, and tell the user what the scripts do.
|
|
73
|
+
|
|
74
|
+
Diffra already ships some skills (`review`, `batch`, `grill-me`, `handoff`, `mcp-builder`, `ui-ux-pro-max`, and this one). Do not suggest installing a copy of one of them; an installed skill with the same name replaces the built-in one.
|
|
75
|
+
|
|
76
|
+
### 5. Present options
|
|
77
|
+
|
|
78
|
+
For each skill you recommend, give its name and what it does, its install count and source, the install command, and its page on skills.sh:
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
The "react-best-practices" skill has React and Next.js performance guidelines
|
|
82
|
+
from Vercel Engineering (185K installs).
|
|
83
|
+
|
|
84
|
+
Install it for all your projects:
|
|
85
|
+
npx skills add vercel-labs/agent-skills@react-best-practices -g -a pi -y
|
|
86
|
+
|
|
87
|
+
More: https://skills.sh/vercel-labs/agent-skills/react-best-practices
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 6. Install only when asked
|
|
91
|
+
|
|
92
|
+
Installing writes files the agent will follow later, so install only after the user says which skill and which scope:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
npx skills add <owner/repo@skill> -g -a pi -y # user scope: ~/.agents/skills/
|
|
96
|
+
npx skills add <owner/repo@skill> -a pi -y # this project: .agents/skills/
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
`-y` skips the CLI's confirmation prompts, so the user's go-ahead in the conversation is the confirmation. After installing, tell the user to run `/reload`, or that the skill is there in their next session.
|
|
100
|
+
|
|
101
|
+
## Common categories
|
|
102
|
+
|
|
103
|
+
| Category | Example queries |
|
|
104
|
+
|---|---|
|
|
105
|
+
| Web development | react, nextjs, typescript, css, tailwind |
|
|
106
|
+
| Testing | testing, jest, playwright, e2e |
|
|
107
|
+
| DevOps | deploy, docker, kubernetes, ci-cd |
|
|
108
|
+
| Documentation | docs, readme, changelog, api-docs |
|
|
109
|
+
| Code quality | review, lint, refactor, best-practices |
|
|
110
|
+
| Design | ui, ux, design-system, accessibility |
|
|
111
|
+
| Productivity | workflow, automation, git |
|
|
112
|
+
|
|
113
|
+
Search with specific keywords ("react testing" rather than "testing"), and try other terms when one finds nothing ("deployment" or "ci-cd" for "deploy").
|
|
114
|
+
|
|
115
|
+
## When nothing is found
|
|
116
|
+
|
|
117
|
+
Say that no existing skill was found and offer to help with the task directly. If the user does this kind of task often, suggest turning it into a skill of their own with `/learn <path|URL|text>`, which writes a project skill under `.diffra/skills/`.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Matt Pocock
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: grill-me
|
|
3
|
+
description: A relentless interview to sharpen a plan or design. Use when the user wants to stress-test a plan, a decision, or an idea before acting on it.
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
license: MIT (see LICENSE). Adapted for Diffra from mattpocock/skills (grill-me and grilling).
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Grill me
|
|
9
|
+
|
|
10
|
+
Interview the user relentlessly until you reach a shared understanding of the plan. Map it as a **design tree**: every decision branches into the decisions that hang off it. If the user named a plan, a file, or an idea with the command, start from that; otherwise ask what they want to be grilled on.
|
|
11
|
+
|
|
12
|
+
## Rounds
|
|
13
|
+
|
|
14
|
+
Work the tree in **rounds**. The **frontier** is every decision whose prerequisites are already settled: the questions you can ask now without guessing at answers you have not heard yet. Ask the whole frontier in one round: number each question and give your recommended answer. Then wait for the user's answers before the next round.
|
|
15
|
+
|
|
16
|
+
Format a round like this:
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
**Q1. <question title>**: <question body, which may be several paragraphs and list the choices>
|
|
20
|
+
|
|
21
|
+
Recommended: <your recommended answer>
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
**Q2. <question title>**: <question body>
|
|
26
|
+
|
|
27
|
+
Recommended: <your recommended answer>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Word each question so that "yes" accepts your recommended answer.
|
|
31
|
+
|
|
32
|
+
When a round has at most four questions and each has a few distinct choices, you may ask it with the `ask_user_question` tool instead: one question per entry, your recommendation marked as recommended. Use the written format when a question needs a long explanation or has open-ended answers.
|
|
33
|
+
|
|
34
|
+
Each round's answers reshape the tree: settled decisions push the frontier outward and unblock the questions that depended on them. Recompute the frontier and ask the next round. A question whose answer depends on another question still open in this round belongs to a later round.
|
|
35
|
+
|
|
36
|
+
## Facts and decisions
|
|
37
|
+
|
|
38
|
+
Finding facts is your job, never the user's. When a frontier question needs a fact from the environment (files, git history, a tool's output, a web page), look it up yourself; for a broad search, start an `Explore` subagent with the `agent` tool so its reading stays out of this conversation's context. Do not block on it: a running exploration is an unsettled prerequisite, so only the questions that depend on it wait for its answer; ask the rest of the frontier now. Never ask the user for something you could look up.
|
|
39
|
+
|
|
40
|
+
The decisions are the user's: put each one to them and wait.
|
|
41
|
+
|
|
42
|
+
## Done
|
|
43
|
+
|
|
44
|
+
The session is done when the frontier is empty: every branch of the design tree visited, nothing left silently assumed. Then summarize the decisions in one list. Do not act on the plan until the user confirms you have reached a shared understanding.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Matt Pocock
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: handoff
|
|
3
|
+
description: Compact the current conversation into a handoff document for another agent to pick up. Takes an optional description of what the next session will be used for.
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
license: MIT (see LICENSE). Adapted for Diffra from mattpocock/skills.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Handoff
|
|
9
|
+
|
|
10
|
+
Write a handoff document summarizing the current conversation so a fresh agent, in a new Diffra session or another tool, can continue the work without reading this conversation.
|
|
11
|
+
|
|
12
|
+
## Where to save it
|
|
13
|
+
|
|
14
|
+
Save it in the operating system's temporary directory, not the workspace: `$TMPDIR`, else `/tmp`; `%TEMP%` on Windows. Name it `handoff-<short-topic>-<YYYYMMDD-HHMM>.md`. Tell the user the full path when you are done, so they can attach it with `@<path>` or point the next agent at it.
|
|
15
|
+
|
|
16
|
+
## What it contains
|
|
17
|
+
|
|
18
|
+
- **Goal**: what the user is trying to achieve, in their words where possible.
|
|
19
|
+
- **State**: what is done, what is in progress, and what is left, with the files, branches, and commands involved.
|
|
20
|
+
- **Decisions**: what was decided and why, and the alternatives that were rejected.
|
|
21
|
+
- **Open questions and risks**: what is still undecided or unverified, and anything that failed and how.
|
|
22
|
+
- **Next steps**: the first concrete things the next agent should do.
|
|
23
|
+
- **Suggested skills**: the skills the next agent should load, named as `/skill:<name>`, for example `/skill:review` before committing.
|
|
24
|
+
|
|
25
|
+
Do not duplicate what other artifacts already hold (specs, plans in `.diffra/plans/`, ADRs, issues, commits, diffs). Reference them by path or URL instead.
|
|
26
|
+
|
|
27
|
+
Redact secrets and personal data: API keys, tokens, passwords, and personally identifiable information. Write `<REDACTED>` in their place.
|
|
28
|
+
|
|
29
|
+
## Arguments
|
|
30
|
+
|
|
31
|
+
If the user passed arguments, treat them as a description of what the next session will focus on, and tailor the document to it: keep what that work needs and leave out the rest.
|