Skip to content

Commit e449252

Browse files
hassoncsKilo Code
andauthored
✨ feat(extension): Add the ability to run an "autoLaunch" prompt as soon as the extension activates (#581)
* ✨ feat(extension): Run an "autoLaunch" prompt as soon as the extension activates This adds the ability to automatically start a prompt right when VSCode is launched. When the extension activates, it will check for a file `.kilocode/launchPrompt.md`. If found, it will immediately start executing the prompt. This allows us to do some really cool automations– this would give the extension the ability to test itself. You could write a prompt into a dir, then launch `code` to that dir. The prompt could tell Kilo to test out it's own functionality and then write out a bug report when it's done. If there's a better way to trigger prompts automatically, please let me know! But this feature would let me continue to experiment in my own dev workflows and eventually Kilo can fully build itself! - integrate maybeRunAutoLaunchPrompt to auto launch prompt if available - create autoLaunchPrompt utility to check and execute launchPrompt.md file * ♻️ refactor(extension): update auto-launch task logic - rename maybeRunAutoLaunchPrompt to checkAndRunAutoLaunchingTask for clarity - add await to checkAndRunAutoLaunchingTask --------- Co-authored-by: Kilo Code <[email protected]>
1 parent 3d2e749 commit e449252

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/extension.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import { TerminalRegistry } from "./integrations/terminal/TerminalRegistry"
2727
import { McpServerManager } from "./services/mcp/McpServerManager"
2828
import { CodeIndexManager } from "./services/code-index/manager"
2929
import { migrateSettings } from "./utils/migrateSettings"
30+
import { checkAndRunAutoLaunchingTask as checkAndRunAutoLaunchingTask } from "./utils/autoLaunchingTask"
31+
import { registerAutocomplete } from "./services/autocomplete/AutocompleteProvider"
3032
import { API } from "./extension/api"
3133

3234
import {
@@ -37,7 +39,6 @@ import {
3739
CodeActionProvider,
3840
} from "./activate"
3941
import { initializeI18n } from "./i18n"
40-
import { registerAutocomplete } from "./services/autocomplete/AutocompleteProvider"
4142

4243
/**
4344
* Built using https://github.com/microsoft/vscode-webview-ui-toolkit
@@ -209,6 +210,8 @@ export async function activate(context: vscode.ExtensionContext) {
209210
})
210211
}
211212

213+
await checkAndRunAutoLaunchingTask(context) // kilocode_change
214+
212215
return new API(outputChannel, provider, socketPath, enableLogging)
213216
}
214217

src/utils/autoLaunchingTask.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import * as vscode from "vscode"
2+
3+
/**
4+
* Checks for a file in .kilocode/launchPrompt.md and runs it immediately if it exists.
5+
*/
6+
export async function checkAndRunAutoLaunchingTask(context: vscode.ExtensionContext): Promise<void> {
7+
if (!vscode.workspace.workspaceFolders || vscode.workspace.workspaceFolders.length === 0) {
8+
return
9+
}
10+
11+
const workspaceFolderUri = vscode.workspace.workspaceFolders[0].uri
12+
const promptFilePath = vscode.Uri.joinPath(workspaceFolderUri, ".kilocode", "launchPrompt.md")
13+
14+
try {
15+
const fileContent = await vscode.workspace.fs.readFile(promptFilePath)
16+
const prompt = Buffer.from(fileContent).toString("utf8")
17+
console.log(`🚀 Auto-launching task from '${promptFilePath}' with content:\n${prompt}`)
18+
19+
await new Promise((resolve) => setTimeout(resolve, 500))
20+
await vscode.commands.executeCommand("kilo-code.SidebarProvider.focus")
21+
22+
vscode.commands.executeCommand("kilo-code.newTask", { prompt })
23+
} catch (error) {
24+
if (error instanceof vscode.FileSystemError && error.code === "FileNotFound") {
25+
return // File not found, which is expected if no launchPrompt.md exists
26+
}
27+
console.error(`Error running .kilocode/launchPrompt.md: ${error}`)
28+
}
29+
}

0 commit comments

Comments
 (0)