Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/types/src/global-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export const globalSettingsSchema = z.object({
// kilocode_change start: Morph fast apply
morphApiKey: z.string().optional(),
fastApplyModel: fastApplyModelSchema.optional(),
fastApplyApiProvider: z.string().optional(),
// kilocode_change end

codebaseIndexModels: codebaseIndexModelsSchema.optional(),
Expand Down
27 changes: 21 additions & 6 deletions src/core/tools/editFileTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,22 @@ function getFastApplyConfiguration(state: ClineProviderState): FastApplyConfigur
// Read the selected model from state
const selectedModel = state.fastApplyModel || "auto"

// Read fastApplyApiProvider from state when use current Api Configuration
let fastApplyApiProvider: string | undefined = state.apiConfiguration?.apiProvider

const useCurrentApiConfiguration = state.fastApplyApiProvider === "-"

if (!useCurrentApiConfiguration) {
// Read fastApplyApiProvider provider from fast apply setting
fastApplyApiProvider = state.fastApplyApiProvider
}

// Priority 1: Use direct Morph API key if available
// Allow human-relay for debugging
if (state.morphApiKey || state.apiConfiguration?.apiProvider === "human-relay") {
if (
(fastApplyApiProvider === "morph" && state.morphApiKey) ||
state.apiConfiguration?.apiProvider === "human-relay"
) {
const [org, model] = selectedModel.split("/")
return {
available: true,
Expand All @@ -355,8 +368,8 @@ function getFastApplyConfiguration(state: ClineProviderState): FastApplyConfigur
}

// Priority 2: Use KiloCode provider
if (state.apiConfiguration?.apiProvider === "kilocode") {
const token = state.apiConfiguration.kilocodeToken
if (fastApplyApiProvider === "kilocode") {
const token = useCurrentApiConfiguration ? state.apiConfiguration.kilocodeToken : state.morphApiKey
if (!token) {
return { available: false, error: "No KiloCode token available to use Fast Apply" }
}
Expand All @@ -370,15 +383,17 @@ function getFastApplyConfiguration(state: ClineProviderState): FastApplyConfigur
}

// Priority 3: Use OpenRouter provider
if (state.apiConfiguration?.apiProvider === "openrouter") {
const token = state.apiConfiguration.openRouterApiKey
if (fastApplyApiProvider === "openrouter") {
const token = useCurrentApiConfiguration ? state.apiConfiguration.openRouterApiKey : state.morphApiKey
if (!token) {
return { available: false, error: "No OpenRouter API token available to use Fast Apply" }
}
return {
available: true,
apiKey: token,
baseUrl: state.apiConfiguration.openRouterBaseUrl || "https://openrouter.ai/api/v1",
baseUrl: useCurrentApiConfiguration
? state.apiConfiguration.openRouterBaseUrl
: "https://openrouter.ai/api/v1",
model: selectedModel === "auto" ? "morph/morph-v3-large" : selectedModel, // Use selected model
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/core/webview/ClineProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1906,6 +1906,7 @@ export class ClineProvider
dismissedNotificationIds, // kilocode_change
morphApiKey, // kilocode_change
fastApplyModel, // kilocode_change: Fast Apply model selection
fastApplyApiProvider, // kilocode_change: Fast Apply model api base url
alwaysAllowFollowupQuestions,
followupAutoApproveTimeoutMs,
includeDiagnosticMessages,
Expand Down Expand Up @@ -2084,6 +2085,7 @@ export class ClineProvider
dismissedNotificationIds: dismissedNotificationIds ?? [], // kilocode_change
morphApiKey, // kilocode_change
fastApplyModel: fastApplyModel ?? "auto", // kilocode_change: Fast Apply model selection
fastApplyApiProvider: fastApplyApiProvider ?? "-", // kilocode_change: Fast Apply model api base url
alwaysAllowFollowupQuestions: alwaysAllowFollowupQuestions ?? false,
followupAutoApproveTimeoutMs: followupAutoApproveTimeoutMs ?? 60000,
includeDiagnosticMessages: includeDiagnosticMessages ?? true,
Expand Down Expand Up @@ -2297,6 +2299,7 @@ export class ClineProvider
dismissedNotificationIds: stateValues.dismissedNotificationIds ?? [], // kilocode_change
morphApiKey: stateValues.morphApiKey, // kilocode_change
fastApplyModel: stateValues.fastApplyModel ?? "auto", // kilocode_change: Fast Apply model selection
fastApplyApiProvider: stateValues.fastApplyApiProvider ?? "-", // kilocode_change: Fast Apply model api config id
historyPreviewCollapsed: stateValues.historyPreviewCollapsed ?? false,
reasoningBlockCollapsed: stateValues.reasoningBlockCollapsed ?? true,
cloudUserInfo,
Expand Down Expand Up @@ -3003,6 +3006,7 @@ export class ClineProvider
morphFastApply: Boolean(experiments.morphFastApply),
morphApiKey: Boolean(this.contextProxy.getValue("morphApiKey")),
selectedModel: this.contextProxy.getValue("fastApplyModel") || "auto",
fastApplyApiProvider: this.contextProxy.getValue("fastApplyApiProvider") || "-",
},
}
} catch (error) {
Expand Down
5 changes: 5 additions & 0 deletions src/core/webview/webviewMessageHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1457,6 +1457,11 @@ export const webviewMessageHandler = async (
await provider.postStateToWebview()
break
}
case "fastApplyApiProvider": {
await updateGlobalState("fastApplyApiProvider", message.text ?? "-")
await provider.postStateToWebview()
break
}
// kilocode_change end
case "updateVSCodeSetting": {
const { setting, value } = message
Expand Down
1 change: 1 addition & 0 deletions src/shared/ExtensionMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ export type ExtensionState = Pick<
| "fuzzyMatchThreshold"
| "morphApiKey" // kilocode_change: Morph fast apply - global setting
| "fastApplyModel" // kilocode_change: Fast Apply model selection
| "fastApplyApiProvider" // kilocode_change: Fast Apply model api base url
// | "experiments" // Optional in GlobalSettings, required here.
| "language"
// | "telemetrySetting" // Optional in GlobalSettings, required here.
Expand Down
1 change: 1 addition & 0 deletions src/shared/WebviewMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export interface WebviewMessage {
| "fuzzyMatchThreshold"
| "morphApiKey" // kilocode_change: Morph fast apply - global setting
| "fastApplyModel" // kilocode_change: Fast Apply model selection
| "fastApplyApiProvider" // kilocode_change: Fast Apply model api base url
| "writeDelayMs"
| "diagnosticsEnabled"
| "enhancePrompt"
Expand Down
5 changes: 4 additions & 1 deletion webview-ui/src/components/settings/ExperimentalSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ type ExperimentalSettingsProps = HTMLAttributes<HTMLDivElement> & {
// kilocode_change start
morphApiKey?: string
fastApplyModel?: string
setCachedStateField: SetCachedStateField<"morphApiKey" | "fastApplyModel">
fastApplyApiProvider?: string
setCachedStateField: SetCachedStateField<"morphApiKey" | "fastApplyModel" | "fastApplyApiProvider">
kiloCodeImageApiKey?: string
setKiloCodeImageApiKey?: (apiKey: string) => void
currentProfileKilocodeToken?: string
Expand All @@ -50,6 +51,7 @@ export const ExperimentalSettings = ({
// kilocode_change start
morphApiKey,
fastApplyModel, // kilocode_change: Fast Apply model selection
fastApplyApiProvider, // kilocode_change: Fast Apply model api base url
setCachedStateField,
setKiloCodeImageApiKey,
kiloCodeImageApiKey,
Expand Down Expand Up @@ -107,6 +109,7 @@ export const ExperimentalSettings = ({
setCachedStateField={setCachedStateField}
morphApiKey={morphApiKey}
fastApplyModel={fastApplyModel}
fastApplyApiProvider={fastApplyApiProvider}
/>
)}
</React.Fragment>
Expand Down
44 changes: 35 additions & 9 deletions webview-ui/src/components/settings/FastApplySettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,39 @@ import { SetCachedStateField } from "./types"
export const FastApplySettings = ({
morphApiKey,
fastApplyModel,
fastApplyApiProvider,
setCachedStateField,
}: {
morphApiKey?: string
fastApplyModel?: string
setCachedStateField: SetCachedStateField<"morphApiKey" | "fastApplyModel">
fastApplyApiProvider?: string
setCachedStateField: SetCachedStateField<"morphApiKey" | "fastApplyModel" | "fastApplyApiProvider">
}) => {
const { t } = useAppTranslation()
return (
<div className="flex flex-col gap-2">
<div>
<label className="text-xs text-vscode-descriptionForeground mb-1 block">
{t("settings:experimental.MORPH_FAST_APPLY.apiProvider")}
</label>
<VSCodeDropdown
value={fastApplyApiProvider || "-"}
onChange={(e: any) => setCachedStateField("fastApplyApiProvider", (e.target as any)?.value || "-")}
className="w-full">
<VSCodeOption className="py-2 px-3" value="kilocode">
Kilo Code
</VSCodeOption>
<VSCodeOption className="py-2 px-3" value="openrouter">
OpenRouter
</VSCodeOption>
<VSCodeOption className="py-2 px-3" value="morph">
Morph
</VSCodeOption>
<VSCodeOption className="py-2 px-3" value="-">
Use Current Configuration
</VSCodeOption>
</VSCodeDropdown>
</div>
<div>
<label className="text-xs text-vscode-descriptionForeground mb-1 block">
{t("settings:experimental.MORPH_FAST_APPLY.modelLabel")}
Expand All @@ -39,14 +63,16 @@ export const FastApplySettings = ({
</p>
</div>

<VSCodeTextField
type="password"
value={morphApiKey || ""}
placeholder={t("settings:experimental.MORPH_FAST_APPLY.placeholder")}
onChange={(e) => setCachedStateField("morphApiKey", (e.target as any)?.value || "")}
className="w-full">
{t("settings:experimental.MORPH_FAST_APPLY.apiKey")}
</VSCodeTextField>
{fastApplyApiProvider !== "-" && (
<VSCodeTextField
type="password"
value={morphApiKey || ""}
placeholder={t("settings:experimental.MORPH_FAST_APPLY.placeholder")}
onChange={(e) => setCachedStateField("morphApiKey", (e.target as any)?.value || "")}
className="w-full">
{t("settings:experimental.MORPH_FAST_APPLY.apiKey")}
</VSCodeTextField>
)}
</div>
)
}
3 changes: 3 additions & 0 deletions webview-ui/src/components/settings/SettingsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
experiments,
morphApiKey, // kilocode_change
fastApplyModel, // kilocode_change: Fast Apply model selection
fastApplyApiProvider, // kilocode_change: Fast Apply model api base url
fuzzyMatchThreshold,
maxOpenTabsContext,
maxWorkspaceFiles,
Expand Down Expand Up @@ -474,6 +475,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
vscode.postMessage({ type: "ghostServiceSettings", values: ghostServiceSettings }) // kilocode_change
vscode.postMessage({ type: "morphApiKey", text: morphApiKey }) // kilocode_change
vscode.postMessage({ type: "fastApplyModel", text: fastApplyModel }) // kilocode_change: Fast Apply model selection
vscode.postMessage({ type: "fastApplyApiProvider", text: fastApplyApiProvider }) // kilocode_change: Fast Apply model api base url
vscode.postMessage({ type: "openRouterImageApiKey", text: openRouterImageApiKey })
vscode.postMessage({ type: "kiloCodeImageApiKey", text: kiloCodeImageApiKey })
vscode.postMessage({
Expand Down Expand Up @@ -944,6 +946,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
setCachedStateField={setCachedStateField}
morphApiKey={morphApiKey}
fastApplyModel={fastApplyModel}
fastApplyApiProvider={fastApplyApiProvider}
// kilocode_change end
apiConfiguration={apiConfiguration}
setApiConfigurationField={setApiConfigurationField}
Expand Down
4 changes: 2 additions & 2 deletions webview-ui/src/i18n/locales/ar/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions webview-ui/src/i18n/locales/ca/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions webview-ui/src/i18n/locales/cs/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions webview-ui/src/i18n/locales/de/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions webview-ui/src/i18n/locales/en/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -794,8 +794,9 @@
"MORPH_FAST_APPLY": {
"name": "Enable Fast Apply",
"description": "When enabled, Kilo Code can edit files using Fast Apply with specialized models optimized for code modifications. Requires the Kilo Code API Provider, OpenRouter, or a Morph API key.",
"apiKey": "Morph API key (optional)",
"placeholder": "Enter your Morph API key (optional)",
"apiProvider": "Fast Apply Model API Provider",
"apiKey": "Fast Apply Model API key",
"placeholder": "Enter your Fast Apply Model API key",
"modelLabel": "Model Selection",
"modelDescription": "Choose which Fast Apply model to use for file edits",
"models": {
Expand Down
4 changes: 2 additions & 2 deletions webview-ui/src/i18n/locales/es/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions webview-ui/src/i18n/locales/fr/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions webview-ui/src/i18n/locales/hi/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions webview-ui/src/i18n/locales/id/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions webview-ui/src/i18n/locales/it/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions webview-ui/src/i18n/locales/ja/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions webview-ui/src/i18n/locales/ko/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions webview-ui/src/i18n/locales/nl/settings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading