Skip to content

Commit c903ca9

Browse files
authored
Merge pull request #1961 from Kilo-Org/morph
Morph FastApply updates
2 parents 0221aaa + 1a9e1c2 commit c903ca9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+726
-167
lines changed

.changeset/cruel-eggs-bet.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
"kilo-code": minor
3+
---
4+
5+
Updates to the experimental Morph FastApply support
6+
7+
- A visual indication is now included in the task view whenever Morph is used.
8+
- The traditional file editing tools are now disabled to ensure Morph is used to edit files.
9+
- Morph is now automatically disabled when the API provider does not support it and no Morph API key is configured.
10+
- The Morph API key is no longer lost when switching provider profiles.

packages/types/src/global-settings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ export const globalSettingsSchema = z.object({
133133
fuzzyMatchThreshold: z.number().optional(),
134134
experiments: experimentsSchema.optional(),
135135

136+
morphApiKey: z.string().optional(), // kilocode_change: Morph fast apply
137+
136138
codebaseIndexModels: codebaseIndexModelsSchema.optional(),
137139
codebaseIndexConfig: codebaseIndexConfigSchema.optional(),
138140

packages/types/src/provider-settings.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ const baseProviderSettingsSchema = z.object({
9595
modelMaxTokens: z.number().optional(),
9696
modelMaxThinkingTokens: z.number().optional(),
9797

98-
morphApiKey: z.string().optional(), // kilocode_change: Morph fast apply
99-
10098
// Model verbosity.
10199
verbosity: verbosityLevelsSchema.optional(),
102100
})

src/core/config/ProviderSettingsManager.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
import { TelemetryService } from "@roo-code/telemetry"
1414

1515
import { Mode, modes } from "../../shared/modes"
16+
import { migrateMorphApiKey } from "./kilocode/migrateMorphApiKey"
1617

1718
export interface SyncCloudProfilesResult {
1819
hasChanges: boolean
@@ -32,6 +33,7 @@ export const providerProfilesSchema = z.object({
3233
openAiHeadersMigrated: z.boolean().optional(),
3334
consecutiveMistakeLimitMigrated: z.boolean().optional(),
3435
todoListEnabledMigrated: z.boolean().optional(),
36+
morphApiKeyMigrated: z.boolean().optional(), // kilocode_change: Morph API key migration
3537
})
3638
.optional(),
3739
})
@@ -123,6 +125,7 @@ export class ProviderSettingsManager {
123125
openAiHeadersMigrated: false,
124126
consecutiveMistakeLimitMigrated: false,
125127
todoListEnabledMigrated: false,
128+
morphApiKeyMigrated: false, // kilocode_change: Morph API key migration
126129
} // Initialize with default values
127130
isDirty = true
128131
}
@@ -157,6 +160,14 @@ export class ProviderSettingsManager {
157160
isDirty = true
158161
}
159162

163+
// kilocode_change start
164+
if (!providerProfiles.migrations.morphApiKeyMigrated) {
165+
const result = await migrateMorphApiKey(this.context, providerProfiles)
166+
providerProfiles.migrations.morphApiKeyMigrated = true
167+
isDirty ||= result
168+
}
169+
// kilocode_change end
170+
160171
if (isDirty) {
161172
await this.store(providerProfiles)
162173
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { ExtensionContext } from "vscode"
2+
import { ProviderProfiles } from "../ProviderSettingsManager"
3+
4+
export async function migrateMorphApiKey(context: ExtensionContext, providerProfiles: ProviderProfiles) {
5+
let isDirty = false
6+
try {
7+
// Find any provider profile with morphApiKey set
8+
let morphApiKeyToMigrate: string | undefined
9+
10+
for (const [_name, apiConfig] of Object.entries(providerProfiles.apiConfigs)) {
11+
// Check if this config has morphApiKey (using type assertion since it's no longer in the schema)
12+
const configAny = apiConfig as any
13+
if (configAny.morphApiKey) {
14+
morphApiKeyToMigrate = configAny.morphApiKey
15+
// Clear it from the provider config
16+
delete configAny.morphApiKey
17+
break // Use the first one found
18+
}
19+
}
20+
21+
// If we found a morphApiKey, migrate it to global settings
22+
if (morphApiKeyToMigrate) {
23+
try {
24+
await context.globalState.update("morphApiKey", morphApiKeyToMigrate)
25+
isDirty = true
26+
console.log("[MigrateMorphApiKey] Successfully migrated morphApiKey to global settings")
27+
} catch (error) {
28+
console.error("[MigrateMorphApiKey] Error setting global morphApiKey:", error)
29+
}
30+
}
31+
} catch (error) {
32+
console.error(`[MigrateMorphApiKey] Failed to migrate morphApiKey:`, error)
33+
}
34+
return isDirty
35+
}

0 commit comments

Comments
 (0)