-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix(cli): harden ask and plan modes #9556
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
Changes from 7 commits
eae081a
2277e3d
2f8f6a2
b873691
3732e95
e02deb7
d15da9c
7c12e06
281bb5d
0556e68
a35905c
4b24254
00cb019
f57c65a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@kilocode/cli": patch | ||
| --- | ||
|
|
||
| Prevent Ask and Plan modes, including saved or allow-all approvals, from editing files before an explicit implementation step. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ import { Session } from "@/session" | |
| import { Flag } from "@/flag/flag" | ||
| import { PlanFollowup } from "@/kilocode/plan-followup" | ||
| import { KiloSession } from "@/kilocode/session" | ||
| import { Permission } from "@/permission" | ||
| import { environmentDetails, type EditorContext } from "@/kilocode/editor-context" | ||
| import { Identifier } from "@/id/id" | ||
| import { Filesystem } from "@/util" | ||
|
|
@@ -54,6 +55,20 @@ export namespace KiloSessionPrompt { | |
| return PlanFollowup.abort(sessionID) | ||
| } | ||
|
|
||
| export function guardPermissions(input: { | ||
| agent: { name: string; permission: Permission.Ruleset } | ||
| session: Pick<Session.Info, "permission"> | ||
| }) { | ||
| const rules = input.session.permission ?? [] | ||
| if (!["ask", "plan"].includes(input.agent.name)) return rules | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider moving this to a const at the top, and use it here and in hardPermissions()
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in f57c65a. |
||
| return Permission.merge(rules, input.agent.permission, rules.filter((rule) => rule.action === "deny")) | ||
| } | ||
|
|
||
| export function hardPermissions(input: { agent: { name: string; permission: Permission.Ruleset } }) { | ||
| if (!["ask", "plan"].includes(input.agent.name)) return | ||
| return input.agent.permission | ||
| } | ||
|
|
||
| /** | ||
| * Mutable cache for environment details, keyed by user message ID | ||
| * so it recomputes when a new user message arrives. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.