-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Add agent autonomy presets #9750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
103bef3
feat(vscode): add agent autonomy presets
marius-kilocode 5d9ed1c
Merge branch 'main' into feat-hitl-onboarding-preferences
imanolmzd-svg d13041d
feat(work-style): simplify onboarding state to use config-only persis…
imanolmzd-svg 97d5deb
chore: update kilo-vscode visual regression baselines
github-actions[bot] cfc597d
feat(work-style): refine onboarding preferences
imanolmzd-svg 6058ac5
feat(webview): re-request work style on extensionDataReady if still l…
imanolmzd-svg 105e406
Merge branch 'main' into feat-hitl-onboarding-preferences
imanolmzd-svg 1629daf
chore: update kilo-vscode visual regression baselines
github-actions[bot] ec7a5ff
feat(work-style): improve onboarding flow
imanolmzd-svg 414fb28
chore: update kilo-vscode visual regression baselines
github-actions[bot] e9f101a
refactor(onboarding): extract work style display logic into pure stat…
imanolmzd-svg a165a83
style(welcome): widen responsive breakpoint for work-style empty state
imanolmzd-svg 670777e
fix(vscode): make work style onboarding updates reliable
imanolmzd-svg 80a45bf
Merge branch 'main' into feat-hitl-onboarding-preferences
imanolmzd-svg 740155a
fix(work-style): remove duplicate payload post after apply handler
imanolmzd-svg 5004060
refactor(onboarding): relocate settings access from toast into picker…
imanolmzd-svg a99c498
chore: update kilo-vscode visual regression baselines
github-actions[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "kilo-code": minor | ||
| --- | ||
|
|
||
| Support choosing an agent autonomy preset during VS Code onboarding. |
4 changes: 2 additions & 2 deletions
4
...e/visual-regression/settings/agent-behaviour-workflows-empty-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...-vscode/visual-regression/settings/work-style-onboarding-200-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...ode/visual-regression/settings/work-style-onboarding-default-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
packages/kilo-vscode/src/kilo-provider/work-style-apply-handler.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import * as vscode from "vscode" | ||
| import type { Config } from "@kilocode/sdk/v2/client" | ||
| import type { KiloConnectionService } from "../services/cli-backend/connection-service" | ||
| import type { WorkStyle, WorkStyleConfig, WorkStyleState } from "../shared/work-style-presets" | ||
| import { applyWorkStyle, type WorkStyleSettingSnapshot } from "./work-style-apply" | ||
|
|
||
| function inspect(config: vscode.WorkspaceConfiguration, key: string): WorkStyleSettingSnapshot { | ||
| const info = config.inspect(key) | ||
| return { | ||
| global: info?.globalValue, | ||
| customized: | ||
| info?.globalValue !== undefined || info?.workspaceValue !== undefined || info?.workspaceFolderValue !== undefined, | ||
| } | ||
| } | ||
|
|
||
| async function apply(connection: KiloConnectionService, directory: string, style: WorkStyle) { | ||
| const settings = vscode.workspace.getConfiguration("kilo-code.new") | ||
| return applyWorkStyle(style, { | ||
| read: async () => { | ||
| const client = await connection.getClientAsync(directory) | ||
| const { data } = await client.config.get({ directory }, { throwOnError: true }) | ||
| return (data ?? {}) as WorkStyleConfig | ||
| }, | ||
| inspect: (key) => inspect(settings, key), | ||
| write: async (key, value) => { | ||
| await settings.update(key, value, vscode.ConfigurationTarget.Global) | ||
| }, | ||
| patch: async (config) => { | ||
| const client = await connection.getClientAsync(directory) | ||
| await client.global.config.update({ config: config as Config }, { throwOnError: true }) | ||
| }, | ||
| }) | ||
| } | ||
|
|
||
| export async function handleWorkStyleApplyMessage(input: { | ||
| message: { type?: string; style?: WorkStyleState } | ||
| connection: KiloConnectionService | ||
| directory: string | ||
| post: (message: unknown) => void | ||
| }): Promise<boolean> { | ||
| if (input.message.type !== "applyWorkStyle") return false | ||
| if (input.message.style !== "human-in-the-loop" && input.message.style !== "autonomous") { | ||
| console.error("[Kilo New] Invalid style in applyWorkStyle message") | ||
| input.post({ type: "workStyleApplyFailed", message: "Invalid work style", rollbackFailed: false }) | ||
| return true | ||
| } | ||
|
|
||
| const result = await apply(input.connection, input.directory, input.message.style) | ||
| input.post( | ||
| result.ok | ||
| ? { type: "workStyleApplied", style: input.message.style } | ||
| : { | ||
| type: "workStyleApplyFailed", | ||
| message: result.error, | ||
| rollbackFailed: result.rollback.length > 0, | ||
| }, | ||
| ) | ||
| return true | ||
| } |
63 changes: 63 additions & 0 deletions
63
packages/kilo-vscode/src/kilo-provider/work-style-apply.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import { | ||
| buildWorkStyleApplyPlan, | ||
| type WorkStyle, | ||
| type WorkStyleConfig, | ||
| type WorkStyleSettings, | ||
| } from "../shared/work-style-presets" | ||
|
|
||
| type Setting = keyof WorkStyleSettings | "agentWorkStyle" | ||
|
|
||
| export interface WorkStyleSettingSnapshot { | ||
| customized: boolean | ||
| global: unknown | ||
| } | ||
|
|
||
| export interface WorkStyleStore { | ||
| read: () => Promise<WorkStyleConfig> | ||
| inspect: (key: Setting) => WorkStyleSettingSnapshot | ||
| write: (key: Setting, value: unknown) => Promise<void> | ||
| patch: (config: WorkStyleConfig) => Promise<void> | ||
| } | ||
|
|
||
| type WorkStyleApplyResult = | ||
| | { ok: true } | ||
| | { | ||
| ok: false | ||
| error: string | ||
| rollback: Setting[] | ||
| } | ||
|
|
||
| function message(err: unknown): string { | ||
| if (err instanceof Error) return err.message | ||
| return String(err) | ||
| } | ||
|
|
||
| export async function applyWorkStyle(style: WorkStyle, store: WorkStyleStore): Promise<WorkStyleApplyResult> { | ||
| const completed: Array<{ key: Setting; value: unknown }> = [] | ||
|
|
||
| try { | ||
| const config = await store.read() | ||
| const plan = buildWorkStyleApplyPlan({ | ||
| style, | ||
| config, | ||
| settingDefault: (key) => !store.inspect(key).customized, | ||
| }) | ||
| const writes: Array<{ key: Setting; value: unknown }> = [ | ||
| ...Object.entries(plan.settings).map(([key, value]) => ({ key: key as keyof WorkStyleSettings, value })), | ||
| { key: "agentWorkStyle", value: style }, | ||
| ] | ||
|
|
||
| for (const write of writes) { | ||
| completed.push({ key: write.key, value: store.inspect(write.key).global }) | ||
| await store.write(write.key, write.value) | ||
| } | ||
| if (Object.keys(plan.config).length > 0) await store.patch(plan.config) | ||
| return { ok: true } | ||
| } catch (err) { | ||
| const rollback: Setting[] = [] | ||
| for (const write of [...completed].reverse()) { | ||
| await store.write(write.key, write.value).catch(() => rollback.push(write.key)) | ||
| } | ||
| return { ok: false, error: message(err), rollback } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| import * as vscode from "vscode" | ||
| import type { KiloConnectionService } from "../services/cli-backend/connection-service" | ||
| import { getInitialWorkStyle, type WorkStyleState } from "../shared/work-style-presets" | ||
| import { handleWorkStyleApplyMessage } from "./work-style-apply-handler" | ||
|
|
||
| export const WORK_STYLE_SETTING_KEYS = ["showTaskTimeline"] as const | ||
|
|
||
| function getConfig() { | ||
| return vscode.workspace.getConfiguration("kilo-code.new") | ||
| } | ||
|
|
||
| function isWorkStyleConfigured(): boolean { | ||
| return getConfig().inspect<WorkStyleState>("agentWorkStyle")?.globalValue !== undefined | ||
| } | ||
|
|
||
| export function getWorkStylePayload() { | ||
| return { | ||
| type: "workStyleLoaded" as const, | ||
| style: getConfig().get<WorkStyleState>("agentWorkStyle", "unset"), | ||
| } | ||
| } | ||
|
|
||
| export function isWorkStyleSetting(key: string): boolean { | ||
| return WORK_STYLE_SETTING_KEYS.includes(key as (typeof WORK_STYLE_SETTING_KEYS)[number]) || key === "agentWorkStyle" | ||
| } | ||
|
|
||
| export function watchWorkStyleConfig(post: (message: unknown) => void, next?: vscode.Disposable) { | ||
| const keys = ["agentWorkStyle", ...WORK_STYLE_SETTING_KEYS] | ||
| const watcher = vscode.workspace.onDidChangeConfiguration((event) => { | ||
| if (keys.some((key) => event.affectsConfiguration(`kilo-code.new.${key}`))) post(getWorkStylePayload()) | ||
| }) | ||
| return next ? vscode.Disposable.from(watcher, next) : watcher | ||
| } | ||
|
|
||
| export async function setWorkStyle(style: WorkStyleState) { | ||
| await getConfig().update("agentWorkStyle", style, vscode.ConfigurationTarget.Global) | ||
| } | ||
|
|
||
| async function hasAnySession(connection: KiloConnectionService, directory: string): Promise<boolean> { | ||
| const client = await connection.getClientAsync(directory) | ||
| const { data } = await client.experimental.session.list( | ||
| { | ||
| roots: true, | ||
| limit: 1, | ||
| archived: true, | ||
| }, | ||
| { throwOnError: true }, | ||
| ) | ||
| return data.length > 0 | ||
| } | ||
|
|
||
| async function initializeWorkStyle(connection: KiloConnectionService, directory: string): Promise<void> { | ||
| if (isWorkStyleConfigured()) return | ||
|
|
||
| const hasSessions = await hasAnySession(connection, directory) | ||
|
|
||
| if (isWorkStyleConfigured()) return | ||
| await setWorkStyle(getInitialWorkStyle(hasSessions)) | ||
| } | ||
|
|
||
| export async function handleWorkStyleMessage(input: { | ||
| message: { type?: string; style?: WorkStyleState } | ||
| connection: KiloConnectionService | ||
| directory: string | ||
| post: (message: unknown) => void | ||
| }): Promise<boolean> { | ||
| if (input.message.type === "requestWorkStyle") { | ||
| const initialized = await initializeWorkStyle(input.connection, input.directory) | ||
| .then(() => true) | ||
| .catch((err: unknown) => { | ||
| console.error("[Kilo New] Failed to initialize work style:", err) | ||
| return false | ||
| }) | ||
| const payload = getWorkStylePayload() | ||
| input.post(initialized ? payload : { ...payload, style: "skipped" }) | ||
| return true | ||
| } | ||
| if (await handleWorkStyleApplyMessage(input)) return true | ||
| if (input.message.type !== "setWorkStyle") return false | ||
| if (!input.message.style) { | ||
| console.error("[Kilo New] Missing style in setWorkStyle message") | ||
| return true | ||
| } | ||
| await setWorkStyle(input.message.style) | ||
| input.post(getWorkStylePayload()) | ||
| return true | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.