mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-24 16:02:55 +08:00
fix(cli): add kilocode_change annotation markers
This commit is contained in:
@@ -21,9 +21,9 @@ import { PermissionNext } from "@/permission/next"
|
||||
import { NamedError } from "@opencode-ai/util/error" // kilocode_change
|
||||
import { Glob } from "../util/glob" // kilocode_change
|
||||
import { mergeDeep, pipe, sortBy, values } from "remeda"
|
||||
import { Global } from "@/global"
|
||||
import { KilocodePaths } from "@/kilocode/paths"
|
||||
import path from "path"
|
||||
import { Global } from "@/global" // kilocode_change
|
||||
import { KilocodePaths } from "@/kilocode/paths" // kilocode_change
|
||||
import path from "path" // kilocode_change
|
||||
import { Plugin } from "@/plugin"
|
||||
import { Skill } from "../skill"
|
||||
|
||||
@@ -64,10 +64,12 @@ export namespace Agent {
|
||||
|
||||
const skillDirs = await Skill.dirs()
|
||||
const whitelistedDirs = [Truncate.GLOB, ...skillDirs.map((dir) => path.join(dir, "*"))]
|
||||
// kilocode_change start — allow reading global config dirs without prompts
|
||||
const readableDirs = [
|
||||
path.join(Global.Path.config, "*"),
|
||||
...KilocodePaths.globalDirs().map((dir) => path.join(dir, "*")),
|
||||
]
|
||||
// kilocode_change end
|
||||
// kilocode_change start — safe bash commands that don't need user approval.
|
||||
// only commands that cannot execute arbitrary code or subprocesses.
|
||||
const bash: Record<string, "allow" | "ask" | "deny"> = {
|
||||
|
||||
@@ -7,6 +7,7 @@ import { Ripgrep } from "../file/ripgrep"
|
||||
import { Instance } from "../project/instance"
|
||||
import { assertExternalDirectory } from "./external-directory"
|
||||
|
||||
// kilocode_change start — support absolute glob patterns (e.g. ~/.config/kilo/command/*.md)
|
||||
function normalize(p: string) {
|
||||
return p.replaceAll("\\", "/")
|
||||
}
|
||||
@@ -22,6 +23,7 @@ function split(pattern: string) {
|
||||
const next = normalized.slice(cut + 1)
|
||||
return { dir, pattern: next || "*" }
|
||||
}
|
||||
// kilocode_change end
|
||||
|
||||
export const GlobTool = Tool.define("glob", {
|
||||
description: DESCRIPTION,
|
||||
@@ -35,7 +37,7 @@ export const GlobTool = Tool.define("glob", {
|
||||
),
|
||||
}),
|
||||
async execute(params, ctx) {
|
||||
const absolute = split(params.pattern)
|
||||
const absolute = split(params.pattern) // kilocode_change
|
||||
await ctx.ask({
|
||||
permission: "glob",
|
||||
patterns: [params.pattern],
|
||||
@@ -46,7 +48,7 @@ export const GlobTool = Tool.define("glob", {
|
||||
},
|
||||
})
|
||||
|
||||
let search = absolute?.dir ?? params.path ?? Instance.directory
|
||||
let search = absolute?.dir ?? params.path ?? Instance.directory // kilocode_change
|
||||
search = path.isAbsolute(search) ? search : path.resolve(Instance.directory, search)
|
||||
await assertExternalDirectory(ctx, search, { kind: "directory" })
|
||||
|
||||
@@ -55,7 +57,7 @@ export const GlobTool = Tool.define("glob", {
|
||||
let truncated = false
|
||||
for await (const file of Ripgrep.files({
|
||||
cwd: search,
|
||||
glob: [absolute?.pattern ?? params.pattern],
|
||||
glob: [absolute?.pattern ?? params.pattern], // kilocode_change
|
||||
signal: ctx.abort,
|
||||
})) {
|
||||
if (files.length >= limit) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { tmpdir } from "../fixture/fixture"
|
||||
import { Instance } from "../../src/project/instance"
|
||||
import { Agent } from "../../src/agent/agent"
|
||||
import { PermissionNext } from "../../src/permission/next"
|
||||
import { Global } from "../../src/global"
|
||||
import { Global } from "../../src/global" // kilocode_change
|
||||
|
||||
// Helper to evaluate permission for a tool with wildcard pattern
|
||||
function evalPerm(agent: Agent.Info | undefined, permission: string): PermissionNext.Action | undefined {
|
||||
@@ -159,6 +159,7 @@ test("explore agent asks for external directories and allows Truncate.GLOB", asy
|
||||
})
|
||||
})
|
||||
|
||||
// kilocode_change start
|
||||
test("code agent allows global config directory reads by default", async () => {
|
||||
await using tmp = await tmpdir()
|
||||
await Instance.provide({
|
||||
@@ -172,6 +173,7 @@ test("code agent allows global config directory reads by default", async () => {
|
||||
},
|
||||
})
|
||||
})
|
||||
// kilocode_change end
|
||||
|
||||
test("general agent denies todo tools", async () => {
|
||||
await using tmp = await tmpdir()
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// kilocode_change - new file
|
||||
import { describe, expect, test } from "bun:test"
|
||||
import path from "path"
|
||||
import { GlobTool } from "../../src/tool/glob"
|
||||
|
||||
Reference in New Issue
Block a user