Repository navigation
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 5 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
...ilo-vscode/visual-regression/settings/agent-behaviour-agents-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.
4 changes: 2 additions & 2 deletions
4
.../visual-regression/settings/agent-behaviour-edit-custom-mode-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.
4 changes: 2 additions & 2 deletions
4
...-vscode/visual-regression/settings/agent-behaviour-workflows-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.
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.
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
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,98 @@ | ||
| import * as vscode from "vscode" | ||
| import type { KiloConnectionService } from "../services/cli-backend/connection-service" | ||
| import { getInitialWorkStyle, type WorkStyleSettings, type WorkStyleState } from "../shared/work-style-presets" | ||
|
|
||
| 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() { | ||
| const config = getConfig() | ||
| const inspect = (key: (typeof WORK_STYLE_SETTING_KEYS)[number]) => config.inspect(key) | ||
| const defaults = Object.fromEntries( | ||
| WORK_STYLE_SETTING_KEYS.map((key) => { | ||
| const info = inspect(key) | ||
| const customized = | ||
| info?.globalValue !== undefined || | ||
| info?.workspaceValue !== undefined || | ||
| info?.workspaceFolderValue !== undefined | ||
| return [key, !customized] | ||
| }), | ||
| ) as Record<keyof WorkStyleSettings, boolean> | ||
|
|
||
| return { | ||
| type: "workStyleLoaded" as const, | ||
| style: config.get<WorkStyleState>("agentWorkStyle", "unset"), | ||
| defaults, | ||
| } | ||
| } | ||
|
|
||
| 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): Promise<boolean> { | ||
| const client = await connection.getClientAsync() | ||
| const { data } = await client.experimental.session.list( | ||
| { | ||
| roots: true, | ||
| limit: 1, | ||
| archived: true, | ||
| }, | ||
| { throwOnError: true }, | ||
| ) | ||
| return data.length > 0 | ||
| } | ||
|
|
||
| async function initializeWorkStyle(connection: KiloConnectionService): Promise<void> { | ||
| if (isWorkStyleConfigured()) return | ||
|
|
||
| const hasSessions = await hasAnySession(connection) | ||
|
|
||
| if (isWorkStyleConfigured()) return | ||
| await setWorkStyle(getInitialWorkStyle(hasSessions)) | ||
| } | ||
|
|
||
| export async function handleWorkStyleMessage(input: { | ||
| message: { type?: string; style?: WorkStyleState } | ||
| connection: KiloConnectionService | ||
| post: (message: unknown) => void | ||
| }): Promise<boolean> { | ||
| if (input.message.type === "requestWorkStyle") { | ||
| const initialized = await initializeWorkStyle(input.connection) | ||
| .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 (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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,160 @@ | ||
| type PermissionLevel = "allow" | "ask" | "deny" | ||
| type PermissionRule = PermissionLevel | null | Record<string, PermissionLevel | null> | ||
| type PermissionConfig = Partial<Record<string, PermissionRule>> | ||
|
|
||
| export interface WorkStyleConfig { | ||
| permission?: PermissionConfig | ||
| terminal_command_display?: "expanded" | "collapsed" | ||
| auto_collapse_reasoning?: boolean | ||
| } | ||
|
|
||
| export type WorkStyle = "human" | "autonomous" | ||
| export type WorkStyleState = WorkStyle | "skipped" | "unset" | ||
|
|
||
| export interface WorkStyleSettings { | ||
| showTaskTimeline: boolean | ||
| } | ||
|
|
||
| export interface WorkStylePreset { | ||
| style: WorkStyle | ||
| config: WorkStyleConfig | ||
| settings: WorkStyleSettings | ||
| } | ||
|
|
||
| export interface WorkStyleApplyPlan { | ||
| config: WorkStyleConfig | ||
| settings: Partial<WorkStyleSettings> | ||
| } | ||
|
|
||
| const BASH: Record<string, PermissionLevel> = { | ||
| "*": "ask", | ||
| "cat *": "allow", | ||
| "head *": "allow", | ||
| "tail *": "allow", | ||
| "less *": "allow", | ||
| "ls *": "allow", | ||
| "tree *": "allow", | ||
| "pwd *": "allow", | ||
| "echo *": "allow", | ||
| "wc *": "allow", | ||
| "which *": "allow", | ||
| "type *": "allow", | ||
| "file *": "allow", | ||
| "diff *": "allow", | ||
| "du *": "allow", | ||
| "df *": "allow", | ||
| "date *": "allow", | ||
| "uname *": "allow", | ||
| "whoami *": "allow", | ||
| "printenv *": "allow", | ||
| "man *": "allow", | ||
| "grep *": "allow", | ||
| "rg *": "allow", | ||
| "ag *": "allow", | ||
| "uniq *": "allow", | ||
| "cut *": "allow", | ||
| "tr *": "allow", | ||
| "jq *": "allow", | ||
| "*>*": "ask", | ||
| } | ||
|
|
||
| export const WORK_STYLE_CHOICES: WorkStyle[] = ["human", "autonomous"] | ||
|
imanolmzd-svg marked this conversation as resolved.
Resolved
|
||
|
|
||
| export const WORK_STYLE_PRESETS: Record<WorkStyle, WorkStylePreset> = { | ||
| human: { | ||
| style: "human", | ||
| config: { | ||
| terminal_command_display: "expanded", | ||
| auto_collapse_reasoning: false, | ||
| permission: { | ||
| "*": "ask", | ||
| read: { | ||
| "*": "allow", | ||
| "*.env": "ask", | ||
| "*.env.*": "ask", | ||
| "*.env.example": "allow", | ||
| }, | ||
| grep: "allow", | ||
| glob: "allow", | ||
| list: "allow", | ||
| question: "allow", | ||
| webfetch: "allow", | ||
| websearch: "allow", | ||
| codesearch: "allow", | ||
| external_directory: "ask", | ||
| edit: "ask", | ||
| bash: BASH, | ||
| doom_loop: "ask", | ||
| }, | ||
| }, | ||
| settings: { | ||
| showTaskTimeline: true, | ||
| }, | ||
| }, | ||
| autonomous: { | ||
| style: "autonomous", | ||
| config: { | ||
| terminal_command_display: "collapsed", | ||
| auto_collapse_reasoning: true, | ||
| }, | ||
| settings: { | ||
| showTaskTimeline: false, | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| export function getWorkStylePreset(style: WorkStyle): WorkStylePreset { | ||
| return WORK_STYLE_PRESETS[style] | ||
| } | ||
|
|
||
| export function getInitialWorkStyle(hasSessions: boolean): WorkStyleState { | ||
| return hasSessions ? "skipped" : "unset" | ||
| } | ||
|
|
||
| export function hasPermissionConfig(config: WorkStyleConfig): boolean { | ||
| return Object.keys(config.permission ?? {}).length > 0 | ||
| } | ||
|
|
||
| function stripPermission(config: PermissionConfig): PermissionConfig { | ||
| const result: PermissionConfig = {} | ||
| for (const [key, rule] of Object.entries(config)) { | ||
| if (rule === null || rule === undefined) continue | ||
| if (typeof rule === "string") { | ||
| result[key] = rule | ||
| continue | ||
| } | ||
| const next: Record<string, PermissionLevel | null> = {} | ||
| for (const [pattern, action] of Object.entries(rule)) { | ||
| if (action !== null && action !== undefined) next[pattern] = action | ||
| } | ||
| if (Object.keys(next).length > 0) result[key] = next as PermissionRule | ||
| } | ||
| return result | ||
| } | ||
|
|
||
| export function buildWorkStyleApplyPlan(input: { | ||
| style: WorkStyle | ||
| config: WorkStyleConfig | ||
| settingDefault?: (key: keyof WorkStyleSettings) => boolean | ||
| }): WorkStyleApplyPlan { | ||
| const preset = getWorkStylePreset(input.style) | ||
| const next: WorkStyleConfig = {} | ||
|
|
||
| if (preset.config.permission && !hasPermissionConfig(input.config)) { | ||
| next.permission = stripPermission(preset.config.permission) | ||
| } | ||
| if (input.config.terminal_command_display === undefined) { | ||
| next.terminal_command_display = preset.config.terminal_command_display | ||
| } | ||
| if (input.config.auto_collapse_reasoning === undefined) { | ||
| next.auto_collapse_reasoning = preset.config.auto_collapse_reasoning | ||
| } | ||
|
|
||
| const settingDefault = input.settingDefault ?? (() => true) | ||
| return { | ||
| config: next, | ||
| settings: { | ||
| ...(settingDefault("showTaskTimeline") ? { showTaskTimeline: preset.settings.showTaskTimeline } : {}), | ||
| }, | ||
| } | ||
| } | ||
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.