Преглед изворни кода

Update coding model context size and tighten coding endpoint model list

Neonsy пре 1 недеља
родитељ
комит
3ecc86c214

+ 1 - 1
pnpm-lock.yaml

@@ -26161,7 +26161,7 @@ snapshots:
       sirv: 3.0.1
       tinyglobby: 0.2.14
       tinyrainbow: 2.0.0
-      vitest: 3.2.4(@types/[email protected])(@types/node@25.0.10)(@vitest/[email protected])([email protected])([email protected](@noble/[email protected]))([email protected])([email protected])([email protected])([email protected])
+      vitest: 3.2.4(@types/[email protected])(@types/node@24.2.1)(@vitest/[email protected])([email protected])([email protected](@noble/[email protected]))([email protected])([email protected])([email protected])([email protected])
 
   '@vitest/[email protected]':
     dependencies:

+ 37 - 0
src/api/providers/__tests__/moonshot.spec.ts

@@ -285,6 +285,43 @@ describe("MoonshotHandler", () => {
 			)
 		})
 
+		it("should enforce strict thinking temperature/provider options for kimi-for-coding by default", async () => {
+			const strictHandler = new MoonshotHandler({
+				...mockOptions,
+				apiModelId: "kimi-for-coding",
+				modelTemperature: 0.1,
+			})
+
+			async function* mockFullStream() {
+				yield { type: "text-delta", text: "Test response" }
+			}
+
+			mockStreamText.mockReturnValue({
+				fullStream: mockFullStream(),
+				usage: Promise.resolve({
+					inputTokens: 1,
+					outputTokens: 1,
+					details: {},
+					raw: {},
+				}),
+			})
+
+			for await (const _chunk of strictHandler.createMessage(systemPrompt, messages)) {
+				// Drain stream
+			}
+
+			expect(mockStreamText).toHaveBeenCalledWith(
+				expect.objectContaining({
+					temperature: 1.0,
+					providerOptions: {
+						moonshot: {
+							thinking: { type: "enabled" },
+						},
+					},
+				}),
+			)
+		})
+
 		it("should enforce strict non-thinking temperature/provider options when reasoning is disabled", async () => {
 			const strictHandler = new MoonshotHandler({
 				...mockOptions,

+ 3 - 2
webview-ui/src/components/settings/ApiOptions.tsx

@@ -338,8 +338,9 @@ const ApiOptions = ({
 				? Object.fromEntries(
 						Object.entries(filteredModels).filter(
 							([modelId]) =>
-								modelId !== "kimi-for-coding" ||
-								apiConfiguration.moonshotBaseUrl === "https://api.kimi.com/coding/v1",
+								apiConfiguration.moonshotBaseUrl === "https://api.kimi.com/coding/v1"
+									? modelId === "kimi-for-coding"
+									: modelId !== "kimi-for-coding",
 						),
 					)
 				: filteredModels

+ 1 - 0
webview-ui/src/components/settings/__tests__/ApiOptions.spec.tsx

@@ -361,6 +361,7 @@ describe("ApiOptions", () => {
 		})
 
 		expect(screen.getByRole("option", { name: "kimi-for-coding" })).toBeInTheDocument()
+		expect(screen.queryByRole("option", { name: "kimi-k2-thinking" })).not.toBeInTheDocument() // kilocode_change
 	})
 
 	it("shows diff settings, temperature and rate limit controls by default", () => {

+ 15 - 0
webview-ui/src/components/ui/hooks/__tests__/useSelectedModel.spec.ts

@@ -440,6 +440,21 @@ describe("useSelectedModel", () => {
 			expect(result.current.id).toBe(firstNonCodingMoonshotModelId)
 		})
 
+		// kilocode_change start
+		it("forces kimi-for-coding when Moonshot coding endpoint is selected with a non-coding model", () => {
+			const apiConfiguration: ProviderSettings = {
+				apiProvider: "moonshot",
+				apiModelId: "kimi-k2-thinking",
+				moonshotBaseUrl: "https://api.kimi.com/coding/v1",
+			}
+
+			const wrapper = createWrapper()
+			const { result } = renderHook(() => useSelectedModel(apiConfiguration), { wrapper })
+
+			expect(result.current.id).toBe("kimi-for-coding")
+		})
+		// kilocode_change end
+
 		it("keeps kimi-for-coding when Moonshot coding endpoint is selected", () => {
 			const apiConfiguration: ProviderSettings = {
 				apiProvider: "moonshot",

+ 6 - 7
webview-ui/src/components/ui/hooks/useSelectedModel.ts

@@ -317,13 +317,12 @@ function getSelectedModel({
 			// kilocode_change start
 			const configuredId = apiConfiguration.apiModelId ?? defaultModelId
 			const isKimiCodingEndpoint = apiConfiguration.moonshotBaseUrl === "https://api.kimi.com/coding/v1"
-			const firstAllowedMoonshotModelId =
-				Object.keys(moonshotModels).find(
-					(modelId) => modelId !== "kimi-for-coding" || isKimiCodingEndpoint,
-				) ?? moonshotDefaultModelId
-			const id =
-				configuredId === "kimi-for-coding" && !isKimiCodingEndpoint
-					? firstAllowedMoonshotModelId
+			const firstNonCodingMoonshotModelId =
+				Object.keys(moonshotModels).find((modelId) => modelId !== "kimi-for-coding") ?? moonshotDefaultModelId
+			const id = isKimiCodingEndpoint
+				? "kimi-for-coding"
+				: configuredId === "kimi-for-coding"
+					? firstNonCodingMoonshotModelId
 					: configuredId
 			// kilocode_change end
 			const info = moonshotModels[id as keyof typeof moonshotModels]