mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-24 16:02:55 +08:00
chore: remove debug logging from autocomplete pipeline
This commit is contained in:
@@ -47,11 +47,9 @@ export class AutocompleteModel {
|
||||
|
||||
if (this.connectionService) {
|
||||
const state = this.connectionService.getConnectionState()
|
||||
console.log(`[Kilo New] AutocompleteModel.reload(): connectionState=${state}`)
|
||||
return state === "connected"
|
||||
}
|
||||
|
||||
console.warn("[Kilo New] AutocompleteModel.reload(): No connection service available")
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -69,12 +67,6 @@ export class AutocompleteModel {
|
||||
onChunk: (text: string) => void,
|
||||
_taskId?: string,
|
||||
): Promise<ResponseMetaData> {
|
||||
console.log("[Kilo New] AutocompleteModel.generateFimResponse: ENTERED", {
|
||||
prefixLen: prefix.length,
|
||||
suffixLen: suffix.length,
|
||||
hasConnectionService: !!this.connectionService,
|
||||
})
|
||||
|
||||
if (!this.connectionService) {
|
||||
throw new Error("Connection service is not available")
|
||||
}
|
||||
@@ -86,22 +78,12 @@ export class AutocompleteModel {
|
||||
|
||||
const client = this.connectionService.getHttpClient()
|
||||
|
||||
console.log("[Kilo New] AutocompleteModel.generateFimResponse: calling FIM endpoint", {
|
||||
model: DEFAULT_MODEL,
|
||||
})
|
||||
|
||||
const result = await client.fimCompletion(prefix, suffix, onChunk, {
|
||||
model: DEFAULT_MODEL,
|
||||
maxTokens: 256,
|
||||
temperature: 0.2,
|
||||
})
|
||||
|
||||
console.log("[Kilo New] AutocompleteModel.generateFimResponse: complete", {
|
||||
cost: result.cost,
|
||||
inputTokens: result.inputTokens,
|
||||
outputTokens: result.outputTokens,
|
||||
})
|
||||
|
||||
return {
|
||||
cost: result.cost,
|
||||
inputTokens: result.inputTokens,
|
||||
|
||||
@@ -98,18 +98,13 @@ export class AutocompleteServiceManager {
|
||||
}
|
||||
|
||||
public async load() {
|
||||
console.log("[Kilo New] AutocompleteServiceManager.load(): starting initialization")
|
||||
const hasKey = await this.model.reload()
|
||||
await this.model.reload()
|
||||
this.settings = readSettings()
|
||||
console.log(
|
||||
`[Kilo New] AutocompleteServiceManager.load(): model=${this.model.getModelName()}, provider=${this.model.getProviderDisplayName()}, hasKey=${hasKey}, enableAutoTrigger=${this.settings.enableAutoTrigger}`,
|
||||
)
|
||||
|
||||
await this.updateGlobalContext()
|
||||
this.updateStatusBar()
|
||||
await this.updateInlineCompletionProviderRegistration()
|
||||
this.setupSnoozeTimerIfNeeded()
|
||||
console.log("[Kilo New] AutocompleteServiceManager.load(): initialization complete")
|
||||
}
|
||||
|
||||
private async updateInlineCompletionProviderRegistration() {
|
||||
@@ -122,9 +117,6 @@ export class AutocompleteServiceManager {
|
||||
}
|
||||
|
||||
if (!shouldBeRegistered) {
|
||||
console.log(
|
||||
`[Kilo New] Inline completion provider NOT registered (enableAutoTrigger=${this.settings?.enableAutoTrigger}, snoozed=${this.isSnoozed()})`,
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -134,7 +126,6 @@ export class AutocompleteServiceManager {
|
||||
this.inlineCompletionProvider,
|
||||
)
|
||||
this.context.subscriptions.push(this.inlineCompletionProviderDisposable)
|
||||
console.log("[Kilo New] Inline completion provider registered successfully")
|
||||
}
|
||||
|
||||
public async disable() {
|
||||
|
||||
+2
-91
@@ -439,18 +439,10 @@ export class AutocompleteInlineCompletionProvider implements vscode.InlineComple
|
||||
_context: vscode.InlineCompletionContext,
|
||||
_token: vscode.CancellationToken,
|
||||
): Promise<vscode.InlineCompletionItem[] | vscode.InlineCompletionList> {
|
||||
console.log("[Kilo New] provideInlineCompletionItems called", {
|
||||
file: document.uri.fsPath,
|
||||
line: position.line,
|
||||
char: position.character,
|
||||
triggerKind: _context.triggerKind,
|
||||
})
|
||||
|
||||
const settings = this.getSettings()
|
||||
const isAutoTriggerEnabled = settings?.enableAutoTrigger ?? false
|
||||
|
||||
if (!isAutoTriggerEnabled) {
|
||||
console.log("[Kilo New] provideInlineCompletionItems: SKIPPED - enableAutoTrigger is false")
|
||||
return []
|
||||
}
|
||||
|
||||
@@ -463,13 +455,6 @@ export class AutocompleteInlineCompletionProvider implements vscode.InlineComple
|
||||
_context: vscode.InlineCompletionContext,
|
||||
_token: vscode.CancellationToken,
|
||||
): Promise<vscode.InlineCompletionItem[] | vscode.InlineCompletionList> {
|
||||
console.log("[Kilo New] provideInlineCompletionItems_Internal called", {
|
||||
file: document.uri.fsPath,
|
||||
lang: document.languageId,
|
||||
line: position.line,
|
||||
char: position.character,
|
||||
})
|
||||
|
||||
// Build telemetry context
|
||||
const telemetryContext: AutocompleteContext = {
|
||||
languageId: document.languageId,
|
||||
@@ -482,16 +467,10 @@ export class AutocompleteInlineCompletionProvider implements vscode.InlineComple
|
||||
if (!this.model || !this.model.hasValidCredentials()) {
|
||||
// bail if no model is available or no valid API credentials configured
|
||||
// this prevents errors when autocomplete is enabled but no provider is set up
|
||||
console.log("[Kilo New] provideInlineCompletionItems_Internal: SKIPPED - no model or invalid credentials", {
|
||||
hasModel: !!this.model,
|
||||
hasValidCredentials: this.model?.hasValidCredentials(),
|
||||
loaded: this.model?.loaded,
|
||||
})
|
||||
return []
|
||||
}
|
||||
|
||||
if (!document?.uri?.fsPath) {
|
||||
console.log("[Kilo New] provideInlineCompletionItems_Internal: SKIPPED - no fsPath on document")
|
||||
return []
|
||||
}
|
||||
|
||||
@@ -508,44 +487,25 @@ export class AutocompleteInlineCompletionProvider implements vscode.InlineComple
|
||||
|
||||
if (!controller) {
|
||||
// If promise hasn't resolved yet, assume file is ignored
|
||||
console.log("[Kilo New] provideInlineCompletionItems_Internal: SKIPPED - ignoreController not ready")
|
||||
return []
|
||||
}
|
||||
|
||||
const isAccessible = controller.validateAccess(document.fileName)
|
||||
if (!isAccessible) {
|
||||
console.log(
|
||||
"[Kilo New] provideInlineCompletionItems_Internal: SKIPPED - file ignored by ignoreController",
|
||||
{
|
||||
file: document.fileName,
|
||||
},
|
||||
)
|
||||
return []
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("[Kilo New] Error checking file access:", error)
|
||||
} catch {
|
||||
// On error, assume file is ignored
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
const { prefix, suffix } = extractPrefixSuffix(document, position)
|
||||
console.log("[Kilo New] provideInlineCompletionItems_Internal: prefix/suffix extracted", {
|
||||
prefixLen: prefix.length,
|
||||
suffixLen: suffix.length,
|
||||
prefixLast50: prefix.slice(-50),
|
||||
suffixFirst50: suffix.slice(0, 50),
|
||||
})
|
||||
|
||||
// Check cache first - allow mid-word lookups from cache
|
||||
const matchingResult = applyFirstLineOnly(findMatchingSuggestion(prefix, suffix, this.suggestionsHistory), prefix)
|
||||
|
||||
if (matchingResult !== null) {
|
||||
console.log("[Kilo New] provideInlineCompletionItems_Internal: CACHE HIT", {
|
||||
matchType: matchingResult.matchType,
|
||||
textLen: matchingResult.text.length,
|
||||
textFirst50: matchingResult.text.slice(0, 50),
|
||||
})
|
||||
this.lastSuggestion = {
|
||||
...telemetryContext,
|
||||
length: matchingResult.text.length,
|
||||
@@ -560,33 +520,18 @@ export class AutocompleteInlineCompletionProvider implements vscode.InlineComple
|
||||
// Only skip new LLM requests during mid-word typing or at end of statement
|
||||
// Cache lookups above are still allowed
|
||||
if (shouldSkipAutocomplete(prefix, suffix, document.languageId)) {
|
||||
console.log(
|
||||
"[Kilo New] provideInlineCompletionItems_Internal: SKIPPED by contextualSkip (mid-word or end-of-statement)",
|
||||
)
|
||||
return []
|
||||
}
|
||||
|
||||
console.log("[Kilo New] provideInlineCompletionItems_Internal: building prompt...")
|
||||
const { prompt, prefix: promptPrefix, suffix: promptSuffix } = await this.getPrompt(document, position)
|
||||
console.log("[Kilo New] provideInlineCompletionItems_Internal: prompt built", {
|
||||
strategy: prompt.strategy,
|
||||
systemPromptLen: "systemPrompt" in prompt ? (prompt.systemPrompt as string).length : undefined,
|
||||
userPromptLen: "userPrompt" in prompt ? (prompt.userPrompt as string).length : undefined,
|
||||
})
|
||||
|
||||
// Update context with strategy now that we know it
|
||||
telemetryContext.strategy = prompt.strategy
|
||||
|
||||
console.log("[Kilo New] provideInlineCompletionItems_Internal: calling debouncedFetchAndCacheSuggestion...")
|
||||
await this.debouncedFetchAndCacheSuggestion(prompt, promptPrefix, promptSuffix, document.languageId)
|
||||
console.log("[Kilo New] provideInlineCompletionItems_Internal: debouncedFetchAndCacheSuggestion returned")
|
||||
|
||||
const cachedResult = applyFirstLineOnly(findMatchingSuggestion(prefix, suffix, this.suggestionsHistory), prefix)
|
||||
if (cachedResult) {
|
||||
console.log("[Kilo New] provideInlineCompletionItems_Internal: LLM result found in cache", {
|
||||
textLen: cachedResult.text.length,
|
||||
textFirst50: cachedResult.text.slice(0, 50),
|
||||
})
|
||||
this.lastSuggestion = {
|
||||
...telemetryContext,
|
||||
length: cachedResult.text.length,
|
||||
@@ -594,17 +539,13 @@ export class AutocompleteInlineCompletionProvider implements vscode.InlineComple
|
||||
this.telemetry?.captureLlmSuggestionReturned(telemetryContext, cachedResult.text.length)
|
||||
this.telemetry?.startVisibilityTracking(cachedResult.fillInAtCursor, "llm", telemetryContext)
|
||||
} else {
|
||||
console.log(
|
||||
"[Kilo New] provideInlineCompletionItems_Internal: NO result after LLM fetch (empty or not matching)",
|
||||
)
|
||||
this.telemetry?.cancelVisibilityTracking() // No suggestion to show - cancel any pending visibility tracking
|
||||
}
|
||||
|
||||
return stringToInlineCompletions(cachedResult?.text ?? "", position)
|
||||
} catch (error) {
|
||||
} catch {
|
||||
// only big catch at the top of the call-chain, if anything goes wrong at a lower level
|
||||
// do not catch, just let the error cascade
|
||||
console.error("[Kilo New] Error providing inline completion:", error)
|
||||
return []
|
||||
}
|
||||
}
|
||||
@@ -659,20 +600,16 @@ export class AutocompleteInlineCompletionProvider implements vscode.InlineComple
|
||||
// Check if any existing pending request covers this one
|
||||
const coveringRequest = this.findCoveringPendingRequest(prefix, suffix)
|
||||
if (coveringRequest) {
|
||||
console.log("[Kilo New] debouncedFetch: reusing covering pending request")
|
||||
// Wait for the existing request to complete - no need to start a new one
|
||||
return coveringRequest.promise
|
||||
}
|
||||
|
||||
// If this is the first call (no pending debounce), execute immediately
|
||||
if (this.isFirstCall && this.debounceTimer === null) {
|
||||
console.log("[Kilo New] debouncedFetch: first call — executing immediately")
|
||||
this.isFirstCall = false
|
||||
return this.fetchAndCacheSuggestion(prompt, prefix, suffix, languageId)
|
||||
}
|
||||
|
||||
console.log(`[Kilo New] debouncedFetch: debouncing for ${this.debounceDelayMs}ms`)
|
||||
|
||||
// Clear any existing timer (reset the debounce)
|
||||
if (this.debounceTimer !== null) {
|
||||
clearTimeout(this.debounceTimer)
|
||||
@@ -711,12 +648,6 @@ export class AutocompleteInlineCompletionProvider implements vscode.InlineComple
|
||||
suffix: string,
|
||||
languageId: string,
|
||||
): Promise<void> {
|
||||
console.log("[Kilo New] fetchAndCacheSuggestion: ENTERED", {
|
||||
strategy: prompt.strategy,
|
||||
prefixLen: prefix.length,
|
||||
suffixLen: suffix.length,
|
||||
languageId,
|
||||
})
|
||||
const startTime = performance.now()
|
||||
|
||||
// Build telemetry context for this request
|
||||
@@ -731,7 +662,6 @@ export class AutocompleteInlineCompletionProvider implements vscode.InlineComple
|
||||
// debounced execution (e.g., profile reload calling AutocompleteModel.cleanup()).
|
||||
// In that case, do not attempt an LLM call at all.
|
||||
if (!this.model || !this.model.hasValidCredentials()) {
|
||||
console.log("[Kilo New] fetchAndCacheSuggestion: ABORTED - credentials invalid at execution time")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -740,10 +670,6 @@ export class AutocompleteInlineCompletionProvider implements vscode.InlineComple
|
||||
const curriedProcessSuggestion = (text: string) =>
|
||||
this.processSuggestion(text, prefix, suffix, this.model, telemetryContext, languageId)
|
||||
|
||||
console.log(
|
||||
`[Kilo New] fetchAndCacheSuggestion: calling ${prompt.strategy === "fim" ? "fimPromptBuilder.getFromFIM" : "holeFiller.getFromChat"}...`,
|
||||
)
|
||||
|
||||
const result =
|
||||
prompt.strategy === "fim"
|
||||
? await this.fimPromptBuilder.getFromFIM(this.model, prompt, curriedProcessSuggestion)
|
||||
@@ -751,15 +677,6 @@ export class AutocompleteInlineCompletionProvider implements vscode.InlineComple
|
||||
|
||||
const latencyMs = performance.now() - startTime
|
||||
|
||||
console.log("[Kilo New] fetchAndCacheSuggestion: LLM call completed", {
|
||||
latencyMs: Math.round(latencyMs),
|
||||
suggestionTextLen: result.suggestion.text.length,
|
||||
suggestionTextFirst50: result.suggestion.text.slice(0, 50),
|
||||
cost: result.cost,
|
||||
inputTokens: result.inputTokens,
|
||||
outputTokens: result.outputTokens,
|
||||
})
|
||||
|
||||
this.telemetry?.captureLlmRequestCompleted(
|
||||
{
|
||||
latencyMs,
|
||||
@@ -779,11 +696,6 @@ export class AutocompleteInlineCompletionProvider implements vscode.InlineComple
|
||||
this.updateSuggestions(result.suggestion)
|
||||
} catch (error) {
|
||||
const latencyMs = performance.now() - startTime
|
||||
console.error("[Kilo New] fetchAndCacheSuggestion: ERROR", {
|
||||
latencyMs: Math.round(latencyMs),
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
stack: error instanceof Error ? error.stack : undefined,
|
||||
})
|
||||
this.telemetry?.captureLlmRequestFailed(
|
||||
{
|
||||
latencyMs,
|
||||
@@ -791,7 +703,6 @@ export class AutocompleteInlineCompletionProvider implements vscode.InlineComple
|
||||
},
|
||||
telemetryContext,
|
||||
)
|
||||
console.error("[Kilo New] Error getting inline completion from LLM:", error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,44 +194,17 @@ Return the COMPLETION tags`
|
||||
if (chunk.type === "text") {
|
||||
response += chunk.text
|
||||
chunkCount++
|
||||
if (chunkCount <= 3) {
|
||||
console.log(`[Kilo New] HoleFiller.getFromChat: chunk #${chunkCount}: "${chunk.text.slice(0, 50)}"`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log("[Kilo New] HoleFiller.getFromChat: ENTERED", {
|
||||
systemPromptLen: systemPrompt.length,
|
||||
userPromptLen: userPrompt.length,
|
||||
})
|
||||
console.log("[Kilo New] HoleFiller.getFromChat: userPrompt (first 200 chars):", userPrompt.slice(0, 200))
|
||||
|
||||
console.log("[Kilo New] HoleFiller.getFromChat: calling model.generateResponse()...")
|
||||
const usageInfo = await model.generateResponse(systemPrompt, userPrompt, onChunk)
|
||||
console.log("[Kilo New] HoleFiller.getFromChat: model.generateResponse() returned", {
|
||||
totalChunks: chunkCount,
|
||||
responseLen: response.length,
|
||||
responseFirst100: response.slice(0, 100),
|
||||
})
|
||||
|
||||
// Extract just the text from the response - prefix/suffix are handled by the caller
|
||||
const completionMatch = response.match(/<COMPLETION>([\s\S]*?)<\/COMPLETION>/i)
|
||||
const suggestionText = completionMatch ? (completionMatch[1] || "").replace(/<\/?COMPLETION>/gi, "") : ""
|
||||
|
||||
console.log("[Kilo New] HoleFiller.getFromChat: parsed completion", {
|
||||
hasCompletionTag: !!completionMatch,
|
||||
suggestionTextLen: suggestionText.length,
|
||||
suggestionTextFirst50: suggestionText.slice(0, 50),
|
||||
fullResponse: response,
|
||||
})
|
||||
|
||||
const fillInAtCursorSuggestion = processSuggestion(suggestionText)
|
||||
|
||||
console.log("[Kilo New] HoleFiller.getFromChat: after processSuggestion", {
|
||||
finalTextLen: fillInAtCursorSuggestion.text.length,
|
||||
finalTextFirst50: fillInAtCursorSuggestion.text.slice(0, 50),
|
||||
})
|
||||
|
||||
return {
|
||||
suggestion: fillInAtCursorSuggestion,
|
||||
cost: usageInfo.cost,
|
||||
|
||||
@@ -7,7 +7,6 @@ export const registerAutocompleteProvider = (
|
||||
context: vscode.ExtensionContext,
|
||||
connectionService: KiloConnectionService,
|
||||
) => {
|
||||
console.log("[Kilo New] registerAutocompleteProvider: creating AutocompleteServiceManager")
|
||||
const autocompleteManager = new AutocompleteServiceManager(context, connectionService)
|
||||
context.subscriptions.push(autocompleteManager)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user