blun-king-cli 9.1.654 → 9.1.655
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LIESMICH.txt +1 -1
- package/README.md +1 -1
- package/blun.mjs +712 -29
- package/package.json +1 -1
- package/telegram-plugin/dist/bridge.mjs +33 -0
- package/telegram-plugin/dist/console-control.mjs +388 -0
- package/telegram-plugin/dist/mcp-server.mjs +1 -0
- package/worker-host.mjs +579 -8
package/worker-host.mjs
CHANGED
|
@@ -5411,6 +5411,31 @@ function parsePattern(pattern) {
|
|
|
5411
5411
|
argPattern
|
|
5412
5412
|
};
|
|
5413
5413
|
}
|
|
5414
|
+
function wave3NamesFileTool(pattern, target) {
|
|
5415
|
+
const group = /^\^?\((?:\?:)?([^()]+)\)\$?$/u.exec(pattern);
|
|
5416
|
+
const names = (group?.[1] ?? pattern).split('|');
|
|
5417
|
+
return names.every((name)=>/^\^?[A-Za-z][\w]*\$?$/u.test(name)) && names.some((name)=>name.replace(/^\^|\$$/gu, '') === target);
|
|
5418
|
+
}
|
|
5419
|
+
const RESTRICTED_FILE_BATCH_SUBJECTS = new Map([
|
|
5420
|
+
[
|
|
5421
|
+
'ApplyPatch',
|
|
5422
|
+
[
|
|
5423
|
+
'Write',
|
|
5424
|
+
'Edit'
|
|
5425
|
+
]
|
|
5426
|
+
],
|
|
5427
|
+
[
|
|
5428
|
+
'EditBatch',
|
|
5429
|
+
[
|
|
5430
|
+
'Write',
|
|
5431
|
+
'Edit',
|
|
5432
|
+
'ApplyPatch'
|
|
5433
|
+
]
|
|
5434
|
+
]
|
|
5435
|
+
]);
|
|
5436
|
+
function inheritedFileRestrictions(tool) {
|
|
5437
|
+
return RESTRICTED_FILE_BATCH_SUBJECTS.get(tool) ?? [];
|
|
5438
|
+
}
|
|
5414
5439
|
function matchPermissionRule({ rule, toolName, execution }) {
|
|
5415
5440
|
let parsed;
|
|
5416
5441
|
try {
|
|
@@ -20969,6 +20994,8 @@ function isRecord$7(value) {
|
|
|
20969
20994
|
* not equal the master switch 'BLUN_EXPERIMENTAL_FLAG'; `id` must not be 'flag'.
|
|
20970
20995
|
*/
|
|
20971
20996
|
const FLAG_DEFINITIONS = [
|
|
20997
|
+
{"id":"telegram_session_control","title":"Telegram session controls","description":"Allow explicitly granted private Telegram session commands.","env":"BLUN_EXPERIMENTAL_TELEGRAM_SESSION_CONTROL","default":false,"surface":"tui"},
|
|
20998
|
+
{"id":"edit_batch","title":"Multi-file text edits","description":"Validate and apply exact text replacements across local workspace files.","env":"BLUN_EXPERIMENTAL_EDIT_BATCH","default":false,"surface":"core"},
|
|
20972
20999
|
{
|
|
20973
21000
|
id: "local_auth",
|
|
20974
21001
|
title: "Local authentication",
|
|
@@ -28962,8 +28989,8 @@ function readRequiredSource(sources, path) {
|
|
|
28962
28989
|
function normalizeSourcePath(path) {
|
|
28963
28990
|
return normalize$3(path.replaceAll("\\", "/")).replace(/^\.\//, "");
|
|
28964
28991
|
}
|
|
28965
|
-
var agent_default$1 = "name: agent\ndescription: Default BLUN King agent\n\nsystemPromptPath: ./system.md\npromptVars:\n roleAdditional: ''\n\ntools:\n - Read\n - ReadBatch\n - ProgrammaticTool\n - Write\n - Edit\n - ApplyPatch\n - Grep\n - Glob\n - Bash\n - TaskList\n - TaskOutput\n - TaskStop\n - TaskUpdate\n - TaskResume\n - CronCreate\n - CronList\n - CronRunList\n - CronRunOutput\n - CronDelete\n - ReadMediaFile\n - TodoList\n - CompactConversation\n - Skill\n - WebSearch\n - Agent\n - AgentSwarm\n - FetchURL\n - GenerateImage\n - GenerateVideo\n - GenerateSpeech\n - GetMedia\n - AskUserQuestion\n - MistakeRecord\n - CodebaseSearch\n - EnterPlanMode\n - ExitPlanMode\n - CreateGoal\n - GetGoal\n - SetGoalBudget\n - UpdateGoal\n - mcp__*\n\nsubagents:\n coder:\n description: General software engineering agent — the only subagent type with file-editing tools; use it for any delegated task that must modify code.\n explore:\n description: Fast codebase exploration with prompt-enforced read-only behavior.\n plan:\n description: Read-only implementation planning and architecture design.\n";
|
|
28966
|
-
var coder_default = "extends: agent\nname: coder\npromptVars:\n roleAdditional: |\n You are now running as a subagent. All the `user` messages are sent by the main agent. The main agent cannot see your context, it can only see your last message when you finish the task. You must treat the parent agent as your caller. Do not directly ask the end user questions. If something is unclear, explain the ambiguity in your final summary to the parent agent.\n\n Your final message is the entire handoff — the parent sees nothing else from your run. Make it technically complete: what you changed and why, the path of every file you touched, how you verified the change (tests or commands run, with results), and anything left undone or worth follow-up. A final message of only a sentence or two is treated as too brief and sent back to you for expansion, costing an extra turn.\nwhenToUse: |\n Use this agent for non-trivial software engineering work that may require reading files, editing code, running commands, and returning a compact but technically complete summary to the parent agent.\ntools:\n - Bash\n - Read\n - ReadBatch\n - ProgrammaticTool\n - ReadMediaFile\n - Glob\n - Grep\n - Write\n - Edit\n - ApplyPatch\n - MistakeRecord\n - WebSearch\n - FetchURL\n - mcp__*\n";
|
|
28992
|
+
var agent_default$1 = "name: agent\ndescription: Default BLUN King agent\n\nsystemPromptPath: ./system.md\npromptVars:\n roleAdditional: ''\n\ntools:\n - Read\n - ReadBatch\n - ProgrammaticTool\n - Write\n - Edit\n - ApplyPatch\n - EditBatch\n - Grep\n - Glob\n - Bash\n - TaskList\n - TaskOutput\n - TaskStop\n - TaskUpdate\n - TaskResume\n - CronCreate\n - CronList\n - CronRunList\n - CronRunOutput\n - CronDelete\n - ReadMediaFile\n - TodoList\n - CompactConversation\n - Skill\n - WebSearch\n - Agent\n - AgentSwarm\n - FetchURL\n - GenerateImage\n - GenerateVideo\n - GenerateSpeech\n - GetMedia\n - AskUserQuestion\n - MistakeRecord\n - CodebaseSearch\n - EnterPlanMode\n - ExitPlanMode\n - CreateGoal\n - GetGoal\n - SetGoalBudget\n - UpdateGoal\n - mcp__*\n\nsubagents:\n coder:\n description: General software engineering agent — the only subagent type with file-editing tools; use it for any delegated task that must modify code.\n explore:\n description: Fast codebase exploration with prompt-enforced read-only behavior.\n plan:\n description: Read-only implementation planning and architecture design.\n";
|
|
28993
|
+
var coder_default = "extends: agent\nname: coder\npromptVars:\n roleAdditional: |\n You are now running as a subagent. All the `user` messages are sent by the main agent. The main agent cannot see your context, it can only see your last message when you finish the task. You must treat the parent agent as your caller. Do not directly ask the end user questions. If something is unclear, explain the ambiguity in your final summary to the parent agent.\n\n Your final message is the entire handoff — the parent sees nothing else from your run. Make it technically complete: what you changed and why, the path of every file you touched, how you verified the change (tests or commands run, with results), and anything left undone or worth follow-up. A final message of only a sentence or two is treated as too brief and sent back to you for expansion, costing an extra turn.\nwhenToUse: |\n Use this agent for non-trivial software engineering work that may require reading files, editing code, running commands, and returning a compact but technically complete summary to the parent agent.\ntools:\n - Bash\n - Read\n - ReadBatch\n - ProgrammaticTool\n - ReadMediaFile\n - Glob\n - Grep\n - Write\n - Edit\n - ApplyPatch\n - EditBatch\n - MistakeRecord\n - WebSearch\n - FetchURL\n - mcp__*\n";
|
|
28967
28994
|
var explore_default = "extends: agent\nname: explore\npromptVars:\n roleAdditional: |\n You are now running as a subagent. All the `user` messages are sent by the main agent. The main agent cannot see your context, it can only see your last message when you finish the task. You must treat the parent agent as your caller. Do not directly ask the end user questions. If something is unclear, explain the ambiguity in your final summary to the parent agent.\n\n You are a codebase exploration specialist. Your role is EXCLUSIVELY to search, read, and analyze existing code and resources. You do NOT have access to project file editing tools. MistakeRecord is the sole write-capable exception: it may record a concrete refutation in shared BLUN learning memory, never modify project files.\n\n Your strengths:\n - Rapidly finding files using glob patterns\n - Searching code and text with powerful regex patterns\n - Reading and analyzing file contents\n - Running read-only shell commands (git log, git diff, ls, find, etc.)\n\n Guidelines:\n - Use Glob for broad file pattern matching. Prefer patterns with a literal anchor (extension or subdirectory); pure wildcards like `*` or `**/*` are allowed but usually truncate at the match cap.\n - Use Grep for searching file contents with regex\n - Use Read when you know the specific file path\n - Use Bash ONLY for read-only operations (ls, git status, git log, git diff, find)\n - NEVER use Bash for any file creation or modification commands\n - Use WebSearch or FetchURL when a question needs external context (library documentation, error messages, upstream APIs); the local codebase remains your primary domain\n - Adapt your search depth based on the thoroughness level specified by the caller\n - Wherever possible, spawn multiple parallel tool calls for grepping and reading files to maximize speed\n\n If the prompt includes a <git-context> block, use it to orient yourself about the repository state before starting your investigation.\n\n You are meant to be a fast agent. Complete the search request efficiently and report your findings clearly in a structured format.\nwhenToUse: |\n Fast agent specialized for exploring codebases. Use this when you need to quickly find files by patterns (e.g. \"src/**/*.yaml\"), search code for keywords (e.g. \"database connection\"), or answer questions about the codebase (e.g. \"how does the auth module work?\"). When calling this agent, specify the desired thoroughness level: \"quick\" for basic searches, \"medium\" for moderate exploration, or \"thorough\" for comprehensive analysis across multiple locations and naming conventions. Use this agent for any read-only exploration that will clearly require more than 3 search queries. Prefer launching multiple explore agents concurrently when investigating independent questions.\ntools:\n - Bash\n - Read\n - ReadBatch\n - ProgrammaticTool\n - ReadMediaFile\n - Glob\n - Grep\n - MistakeRecord\n - WebSearch\n - FetchURL\n";
|
|
28968
28995
|
var init_default = "You are a software engineering expert with many years of programming experience. Please explore the current project directory to understand the project's architecture and main details.\n\nTask requirements:\n1. Analyze the project structure and identify key configuration files (such as pyproject.toml, package.json, Cargo.toml, etc.).\n2. Understand the project's technology stack, build process and runtime architecture.\n3. Identify how the code is organized and main module divisions.\n4. Discover project-specific development conventions, testing strategies, and deployment processes.\n\nAfter the exploration, do a thorough summary of your findings and write it to the `AGENTS.md` file in the project root, replacing the file's previous content. If the file already exists, read it first and carry forward whatever is still accurate — the result should be one coherent, up-to-date file, not an append.\n\nFor your information, `AGENTS.md` is a file intended to be read by AI coding agents. Expect the reader of this file to know nothing about the project.\n\nYou should compose this file according to the actual project content. Do not make any assumptions or generalizations. Ensure the information is accurate and useful. You must use the natural language that is mainly used in the project's comments and documentation.\n\nPopular sections that people usually write in `AGENTS.md` are:\n\n- Project overview\n- Build and test commands\n- Code style guidelines\n- Testing instructions\n- Security considerations\n";
|
|
28969
28996
|
const PROFILE_SOURCES = {
|
|
@@ -234994,7 +235021,7 @@ var HookEngine = class {
|
|
|
234994
235021
|
return results;
|
|
234995
235022
|
}
|
|
234996
235023
|
hasUncoveredMatcher(event, target, previousTargets) {
|
|
234997
|
-
const covered = new Set(this.matchingHooks(event, target));
|
|
235024
|
+
const covered = new Set(this.matchingHooks(event, target).filter(hook => wave3NamesFileTool(hook.matcher ?? "", target)));
|
|
234998
235025
|
return previousTargets.some(previous => this.matchingHooks(event, previous).some(hook => !covered.has(hook)));
|
|
234999
235026
|
}
|
|
235000
235027
|
matchingHooks(event, matcherValue) {
|
|
@@ -239164,7 +239191,7 @@ var PlanModeGuardDenyPermissionPolicy = class {
|
|
|
239164
239191
|
evaluate(context) {
|
|
239165
239192
|
if (!this.agent.planMode.isActive) return;
|
|
239166
239193
|
const toolName = context.toolCall.name;
|
|
239167
|
-
if (toolName === "ApplyPatch") return { kind: "deny", message:
|
|
239194
|
+
if (toolName === "ApplyPatch" || toolName === "EditBatch") return { kind: "deny", message: `${toolName} is not available in plan mode. Call ExitPlanMode before patching files.` };
|
|
239168
239195
|
if (toolName === "Write" || toolName === "Edit") {
|
|
239169
239196
|
const planFilePath = this.agent.planMode.planFilePath;
|
|
239170
239197
|
if (planFilePath === null) return {
|
|
@@ -239287,7 +239314,7 @@ var UserConfiguredPermissionPolicy = class {
|
|
|
239287
239314
|
firstMatchingRule(context, decision) {
|
|
239288
239315
|
const rules = this.agent.permission.data().rules.filter((rule) => USER_CONFIGURED_SCOPES.has(rule.scope));
|
|
239289
239316
|
const name = context.toolCall.name;
|
|
239290
|
-
const subjects =
|
|
239317
|
+
const subjects = decision !== "allow" ? [name, ...inheritedFileRestrictions(name)] : [name];
|
|
239291
239318
|
for (const rule of rules) {
|
|
239292
239319
|
if (rule.decision !== decision) continue;
|
|
239293
239320
|
for (const toolName of subjects) {
|
|
@@ -239436,10 +239463,12 @@ var PermissionManager = class {
|
|
|
239436
239463
|
}
|
|
239437
239464
|
async prepareToolCall(context) {
|
|
239438
239465
|
context.signal.throwIfAborted();
|
|
239439
|
-
|
|
239466
|
+
const batchName = context.toolCall.name;
|
|
239467
|
+
const inherited = inheritedFileRestrictions(batchName);
|
|
239468
|
+
if (inherited.length > 0 && this.agent.hooks !== void 0) {
|
|
239440
239469
|
for (const event of ["PreToolUse", "PermissionRequest"]) {
|
|
239441
|
-
if (this.agent.hooks.hasUncoveredMatcher(event,
|
|
239442
|
-
block: true, reason:
|
|
239470
|
+
if (this.agent.hooks.hasUncoveredMatcher(event, batchName, inherited)) return {
|
|
239471
|
+
block: true, reason: `${batchName} is not covered by an existing ${event} hook for ${inherited.join(" or ")}. Use Write or Edit, or review the hook configuration.`
|
|
239443
239472
|
};
|
|
239444
239473
|
}
|
|
239445
239474
|
}
|
|
@@ -258965,6 +258994,546 @@ const ApplyPatchTool = (() => {
|
|
|
258965
258994
|
return ApplyPatchTool;
|
|
258966
258995
|
})();
|
|
258967
258996
|
// END WAVE 1 APPLY PATCH
|
|
258997
|
+
import { constants as batchConstants } from "node:fs";
|
|
258998
|
+
import { createHash as batchHash } from "node:crypto";
|
|
258999
|
+
let editBatchToolClass;
|
|
259000
|
+
function createEditBatchTool(kaos, workspace) {
|
|
259001
|
+
editBatchToolClass ??= (() => {
|
|
259002
|
+
const constants = batchConstants, createHash = batchHash;
|
|
259003
|
+
const { link, lstat, mkdir, mkdtemp, open, realpath, rename, rmdir, unlink } = wavePatchFs;
|
|
259004
|
+
const { dirname, isAbsolute, join, parse, relative } = wavePatchPath;
|
|
259005
|
+
const z = { array, string, boolean: boolean$1, strictObject: (shape) => object(shape).strict() };
|
|
259006
|
+
class ExactEditError extends Error {
|
|
259007
|
+
editNumber;
|
|
259008
|
+
constructor(editNumber, message){
|
|
259009
|
+
super(message), this.editNumber = editNumber;
|
|
259010
|
+
}
|
|
259011
|
+
}
|
|
259012
|
+
function planReplacements(content, path, edits) {
|
|
259013
|
+
const matches = [];
|
|
259014
|
+
for (const [index, { old_string: before, new_string: replacement, replace_all: all }] of edits.entries()){
|
|
259015
|
+
const editNumber = index + 1;
|
|
259016
|
+
if (!before) throw new ExactEditError(editNumber, 'old_string must not be empty.');
|
|
259017
|
+
let count = 0;
|
|
259018
|
+
for(let start = content.indexOf(before); start !== -1; start = content.indexOf(before, start + before.length)){
|
|
259019
|
+
count++;
|
|
259020
|
+
if (all || count === 1) matches.push({
|
|
259021
|
+
start,
|
|
259022
|
+
end: start + before.length,
|
|
259023
|
+
replacement,
|
|
259024
|
+
editNumber
|
|
259025
|
+
});
|
|
259026
|
+
}
|
|
259027
|
+
if (count === 0) {
|
|
259028
|
+
throw new ExactEditError(editNumber, `old_string not found in ${path}, the file contents may be out of date. Please use the Read Tool to reload the content.`);
|
|
259029
|
+
}
|
|
259030
|
+
if (!all && count > 1) {
|
|
259031
|
+
throw new ExactEditError(editNumber, `old_string is not unique in ${path} (found ${String(count)} occurrences). ` + 'To replace every occurrence, set replace_all=true. To replace only one occurrence, include more surrounding context in old_string.');
|
|
259032
|
+
}
|
|
259033
|
+
}
|
|
259034
|
+
matches.sort((a, b)=>a.start - b.start);
|
|
259035
|
+
let previousEnd = 0;
|
|
259036
|
+
for (const match of matches){
|
|
259037
|
+
if (match.start < previousEnd) throw new ExactEditError(match.editNumber, `Multiple edits overlap in ${path}. No file was changed.`);
|
|
259038
|
+
previousEnd = match.end;
|
|
259039
|
+
}
|
|
259040
|
+
return matches;
|
|
259041
|
+
}
|
|
259042
|
+
function applyReplacements(content, matches) {
|
|
259043
|
+
const output = [];
|
|
259044
|
+
let position = 0;
|
|
259045
|
+
for (const { start, end, replacement } of matches){
|
|
259046
|
+
output.push(content.slice(position, start), replacement);
|
|
259047
|
+
position = end;
|
|
259048
|
+
}
|
|
259049
|
+
output.push(content.slice(position));
|
|
259050
|
+
return output.join('');
|
|
259051
|
+
}
|
|
259052
|
+
function replaceExactText(raw, path, edits) {
|
|
259053
|
+
const modelView = toModelTextView(raw);
|
|
259054
|
+
const matches = planReplacements(modelView.text, path, edits);
|
|
259055
|
+
const text = materializeModelText(applyReplacements(modelView.text, matches), modelView.lineEndingStyle);
|
|
259056
|
+
return {
|
|
259057
|
+
text,
|
|
259058
|
+
count: matches.length
|
|
259059
|
+
};
|
|
259060
|
+
}
|
|
259061
|
+
function assertUniqueBatchPaths(paths) {
|
|
259062
|
+
const seen = new Set();
|
|
259063
|
+
const keys = paths.map((path)=>path.replaceAll('\\', '/').toLowerCase());
|
|
259064
|
+
for (const key of keys){
|
|
259065
|
+
if (seen.has(key)) throw new Error('Patch names the same file more than once.');
|
|
259066
|
+
seen.add(key);
|
|
259067
|
+
}
|
|
259068
|
+
for (const key of keys){
|
|
259069
|
+
for(let at = key.lastIndexOf('/'); at > 0; at = key.lastIndexOf('/', at - 1)){
|
|
259070
|
+
if (seen.has(key.slice(0, at))) throw new Error('Patch file targets overlap.');
|
|
259071
|
+
}
|
|
259072
|
+
}
|
|
259073
|
+
}
|
|
259074
|
+
async function commitPatchPlan(changes, apply, signal) {
|
|
259075
|
+
const undoStack = [];
|
|
259076
|
+
try {
|
|
259077
|
+
for (const change of changes){
|
|
259078
|
+
signal.throwIfAborted();
|
|
259079
|
+
await apply(change, (undo)=>undoStack.push(undo));
|
|
259080
|
+
}
|
|
259081
|
+
signal.throwIfAborted();
|
|
259082
|
+
} catch (cause) {
|
|
259083
|
+
const failures = [];
|
|
259084
|
+
for (const undo of undoStack.reverse()){
|
|
259085
|
+
try {
|
|
259086
|
+
await undo();
|
|
259087
|
+
} catch (error) {
|
|
259088
|
+
failures.push(error);
|
|
259089
|
+
}
|
|
259090
|
+
}
|
|
259091
|
+
if (failures.length !== 0) {
|
|
259092
|
+
throw new AggregateError(failures, 'Patch failed and could not be fully rolled back.', {
|
|
259093
|
+
cause
|
|
259094
|
+
});
|
|
259095
|
+
}
|
|
259096
|
+
throw cause;
|
|
259097
|
+
}
|
|
259098
|
+
}
|
|
259099
|
+
function unsafeDirectory() {
|
|
259100
|
+
return new Error('Patch parent must be a regular directory without path aliases.');
|
|
259101
|
+
}
|
|
259102
|
+
function changedFile() {
|
|
259103
|
+
return new Error('A patch target changed during validation. Retry with the current file.');
|
|
259104
|
+
}
|
|
259105
|
+
function assertPatchPathSpelling(path) {
|
|
259106
|
+
if (process.platform !== 'win32') return;
|
|
259107
|
+
const verbatim = /^(?:[/\\]{2}[?.][/\\]|[a-z]:[^/\\])/i;
|
|
259108
|
+
const reserved = /^(?:CON|PRN|AUX|NUL|CONIN\$|CONOUT\$|COM[0-9\u00b9\u00b2\u00b3]|LPT[0-9\u00b9\u00b2\u00b3])(?:\.|$)/i;
|
|
259109
|
+
if (verbatim.test(path) || path.slice(parse(path).root.length).split(/[/\\]+/).some((part)=>part !== '' && part !== '.' && part !== '..' && (/[<>:"|?*\x00-\x1f]/.test(part) || /[. ]$/.test(part) || reserved.test(part)))) throw new Error('Unsupported Windows path spelling for a patch target.');
|
|
259110
|
+
}
|
|
259111
|
+
async function statPatchPath(path) {
|
|
259112
|
+
try {
|
|
259113
|
+
return await lstat(path, {
|
|
259114
|
+
bigint: true
|
|
259115
|
+
});
|
|
259116
|
+
} catch (error) {
|
|
259117
|
+
if (error.code !== 'ENOENT') throw error;
|
|
259118
|
+
return undefined;
|
|
259119
|
+
}
|
|
259120
|
+
}
|
|
259121
|
+
async function inspectPatchDirectory(path) {
|
|
259122
|
+
const missing = [];
|
|
259123
|
+
for(let directory = path;; directory = dirname(directory)){
|
|
259124
|
+
const stat = await statPatchPath(directory);
|
|
259125
|
+
if (stat !== undefined) {
|
|
259126
|
+
if (!stat.isDirectory() || relative(directory, await realpath(directory)) !== '') throw unsafeDirectory();
|
|
259127
|
+
return {
|
|
259128
|
+
path: directory,
|
|
259129
|
+
stat,
|
|
259130
|
+
missing: missing.reverse()
|
|
259131
|
+
};
|
|
259132
|
+
}
|
|
259133
|
+
if (dirname(directory) === directory) throw unsafeDirectory();
|
|
259134
|
+
missing.push(directory);
|
|
259135
|
+
}
|
|
259136
|
+
}
|
|
259137
|
+
async function assertPatchDirectory(directory) {
|
|
259138
|
+
const current = await statPatchPath(directory.path);
|
|
259139
|
+
if (current === undefined || !current.isDirectory() || !samePatchFile(directory.stat, current) || relative(directory.path, await realpath(directory.path)) !== '') throw unsafeDirectory();
|
|
259140
|
+
}
|
|
259141
|
+
function samePatchFile(left, right) {
|
|
259142
|
+
return left.ino === right.ino && left.dev === right.dev;
|
|
259143
|
+
}
|
|
259144
|
+
function samePatchFileVersion(left, right) {
|
|
259145
|
+
return samePatchFile(left, right) && left.nlink === right.nlink && left.mode === right.mode && left.ctimeNs === right.ctimeNs && left.mtimeNs === right.mtimeNs && left.size === right.size;
|
|
259146
|
+
}
|
|
259147
|
+
async function inspectLocalPatchFile(path, signal) {
|
|
259148
|
+
signal.throwIfAborted();
|
|
259149
|
+
if (!isAbsolute(path)) throw new Error('Patch validation requires a resolved file path.');
|
|
259150
|
+
assertPatchPathSpelling(path);
|
|
259151
|
+
const directory = await inspectPatchDirectory(dirname(path));
|
|
259152
|
+
if (directory.missing.length !== 0) return undefined;
|
|
259153
|
+
const expected = await statPatchPath(path);
|
|
259154
|
+
if (expected === undefined) return undefined;
|
|
259155
|
+
if (!expected.isFile() || expected.nlink !== 1n || relative(path, await realpath(path)) !== '') {
|
|
259156
|
+
throw new Error('Patch target must be an unlinked regular file without path aliases.');
|
|
259157
|
+
}
|
|
259158
|
+
signal.throwIfAborted();
|
|
259159
|
+
const handle = await open(path, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0));
|
|
259160
|
+
try {
|
|
259161
|
+
const opened = await handle.stat({
|
|
259162
|
+
bigint: true
|
|
259163
|
+
});
|
|
259164
|
+
await assertPatchDirectory(directory);
|
|
259165
|
+
if (!opened.isFile() || !samePatchFileVersion(opened, expected)) throw changedFile();
|
|
259166
|
+
const bytes = Buffer.allocUnsafe(Number(expected.size));
|
|
259167
|
+
let length = 0;
|
|
259168
|
+
while(length < bytes.length){
|
|
259169
|
+
signal.throwIfAborted();
|
|
259170
|
+
const { bytesRead } = await handle.read(bytes, length, bytes.length - length, length);
|
|
259171
|
+
if (bytesRead === 0) break;
|
|
259172
|
+
length += bytesRead;
|
|
259173
|
+
}
|
|
259174
|
+
const finished = await handle.stat({
|
|
259175
|
+
bigint: true
|
|
259176
|
+
});
|
|
259177
|
+
const current = await statPatchPath(path);
|
|
259178
|
+
await assertPatchDirectory(directory);
|
|
259179
|
+
signal.throwIfAborted();
|
|
259180
|
+
if (length !== bytes.length || current === undefined || !samePatchFileVersion(finished, expected) || !samePatchFileVersion(current, expected)) throw changedFile();
|
|
259181
|
+
let text;
|
|
259182
|
+
try {
|
|
259183
|
+
text = new TextDecoder('utf-8', {
|
|
259184
|
+
fatal: true,
|
|
259185
|
+
ignoreBOM: true
|
|
259186
|
+
}).decode(bytes);
|
|
259187
|
+
} catch {
|
|
259188
|
+
throw new Error('Patch target must contain UTF-8 text.');
|
|
259189
|
+
}
|
|
259190
|
+
if (text.includes('\0')) throw new Error('Patch target must contain UTF-8 text.');
|
|
259191
|
+
return {
|
|
259192
|
+
text,
|
|
259193
|
+
stat: expected
|
|
259194
|
+
};
|
|
259195
|
+
} finally{
|
|
259196
|
+
await handle.close();
|
|
259197
|
+
}
|
|
259198
|
+
}
|
|
259199
|
+
function changed() {
|
|
259200
|
+
return new Error('A patch target changed or became unavailable.');
|
|
259201
|
+
}
|
|
259202
|
+
async function requireFile(path, expected, links) {
|
|
259203
|
+
const stat = await statPatchPath(path);
|
|
259204
|
+
if (stat === undefined || !stat.isFile() || stat.nlink !== links || !samePatchFile(expected, stat)) {
|
|
259205
|
+
throw changed();
|
|
259206
|
+
}
|
|
259207
|
+
return stat;
|
|
259208
|
+
}
|
|
259209
|
+
async function requireVersion(path, expected) {
|
|
259210
|
+
if (!samePatchFileVersion(await requireFile(path, expected, 1n), expected)) throw changed();
|
|
259211
|
+
}
|
|
259212
|
+
async function parentFor(path, onRollback) {
|
|
259213
|
+
let parent = await inspectPatchDirectory(dirname(path));
|
|
259214
|
+
const missing = parent.missing;
|
|
259215
|
+
if (onRollback === undefined && missing.length !== 0) throw changed();
|
|
259216
|
+
for (const child of missing){
|
|
259217
|
+
await assertPatchDirectory(parent);
|
|
259218
|
+
await mkdir(child);
|
|
259219
|
+
const created = await inspectPatchDirectory(child);
|
|
259220
|
+
onRollback(()=>removeDirectory(created));
|
|
259221
|
+
parent = created;
|
|
259222
|
+
}
|
|
259223
|
+
await assertPatchDirectory(parent);
|
|
259224
|
+
return parent;
|
|
259225
|
+
}
|
|
259226
|
+
async function removeDirectory(directory) {
|
|
259227
|
+
await assertPatchDirectory(directory);
|
|
259228
|
+
await rmdir(directory.path);
|
|
259229
|
+
}
|
|
259230
|
+
async function writeThroughHandle(file, text) {
|
|
259231
|
+
const bytes = Buffer.from(text, 'utf8');
|
|
259232
|
+
let offset = 0;
|
|
259233
|
+
while(offset < bytes.length){
|
|
259234
|
+
const { bytesWritten } = await file.write(bytes, offset, bytes.length - offset, offset);
|
|
259235
|
+
if (bytesWritten === 0) throw new Error('Patch file write did not advance.');
|
|
259236
|
+
offset += bytesWritten;
|
|
259237
|
+
}
|
|
259238
|
+
await file.truncate(bytes.length);
|
|
259239
|
+
await file.sync();
|
|
259240
|
+
}
|
|
259241
|
+
async function createFile(path, text, onRollback, signal) {
|
|
259242
|
+
const parent = await parentFor(path, onRollback);
|
|
259243
|
+
signal.throwIfAborted();
|
|
259244
|
+
const file = await open(path, 'wx', 0o666);
|
|
259245
|
+
let created;
|
|
259246
|
+
onRollback(async ()=>{
|
|
259247
|
+
if (created === undefined) throw changed();
|
|
259248
|
+
await assertPatchDirectory(parent);
|
|
259249
|
+
await requireVersion(path, created);
|
|
259250
|
+
await unlink(path);
|
|
259251
|
+
});
|
|
259252
|
+
try {
|
|
259253
|
+
created = await file.stat({
|
|
259254
|
+
bigint: true
|
|
259255
|
+
});
|
|
259256
|
+
await assertPatchDirectory(parent);
|
|
259257
|
+
await requireVersion(path, created);
|
|
259258
|
+
signal.throwIfAborted();
|
|
259259
|
+
try {
|
|
259260
|
+
await writeThroughHandle(file, text);
|
|
259261
|
+
} finally{
|
|
259262
|
+
created = await file.stat({
|
|
259263
|
+
bigint: true
|
|
259264
|
+
});
|
|
259265
|
+
}
|
|
259266
|
+
} finally{
|
|
259267
|
+
await file.close();
|
|
259268
|
+
}
|
|
259269
|
+
}
|
|
259270
|
+
async function updateFile(path, parent, original, text, onRollback, signal) {
|
|
259271
|
+
const flags = constants.O_WRONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0);
|
|
259272
|
+
const withFile = async (expected, write)=>{
|
|
259273
|
+
await assertPatchDirectory(parent);
|
|
259274
|
+
await requireVersion(path, expected);
|
|
259275
|
+
const file = await open(path, flags);
|
|
259276
|
+
try {
|
|
259277
|
+
if (!samePatchFileVersion(expected, await file.stat({
|
|
259278
|
+
bigint: true
|
|
259279
|
+
}))) throw changed();
|
|
259280
|
+
await assertPatchDirectory(parent);
|
|
259281
|
+
await requireVersion(path, expected);
|
|
259282
|
+
await write(file);
|
|
259283
|
+
} finally{
|
|
259284
|
+
await file.close();
|
|
259285
|
+
}
|
|
259286
|
+
};
|
|
259287
|
+
await withFile(original.stat, async (file)=>{
|
|
259288
|
+
signal.throwIfAborted();
|
|
259289
|
+
let writtenVersion;
|
|
259290
|
+
onRollback(async ()=>{
|
|
259291
|
+
if (writtenVersion === undefined) throw changed();
|
|
259292
|
+
await withFile(writtenVersion, (restored)=>writeThroughHandle(restored, original.text));
|
|
259293
|
+
});
|
|
259294
|
+
try {
|
|
259295
|
+
await writeThroughHandle(file, text);
|
|
259296
|
+
} finally{
|
|
259297
|
+
writtenVersion = await file.stat({
|
|
259298
|
+
bigint: true
|
|
259299
|
+
});
|
|
259300
|
+
}
|
|
259301
|
+
});
|
|
259302
|
+
}
|
|
259303
|
+
async function moveFile(change, parent, onRollback, signal) {
|
|
259304
|
+
const { path, to, original } = change;
|
|
259305
|
+
const destination = await parentFor(to, onRollback);
|
|
259306
|
+
await assertPatchDirectory(parent);
|
|
259307
|
+
await requireVersion(path, original.stat);
|
|
259308
|
+
signal.throwIfAborted();
|
|
259309
|
+
await link(path, to);
|
|
259310
|
+
let moved = false;
|
|
259311
|
+
onRollback(async ()=>{
|
|
259312
|
+
await assertPatchDirectory(parent);
|
|
259313
|
+
await assertPatchDirectory(destination);
|
|
259314
|
+
const links = moved ? 1n : 2n;
|
|
259315
|
+
await requireFile(to, original.stat, links);
|
|
259316
|
+
if (moved) await link(to, path);
|
|
259317
|
+
await requireFile(path, original.stat, 2n);
|
|
259318
|
+
await requireFile(to, original.stat, 2n);
|
|
259319
|
+
await unlink(to);
|
|
259320
|
+
});
|
|
259321
|
+
await requireFile(to, original.stat, 2n);
|
|
259322
|
+
await assertPatchDirectory(parent);
|
|
259323
|
+
await requireFile(path, original.stat, 2n);
|
|
259324
|
+
signal.throwIfAborted();
|
|
259325
|
+
await unlink(path);
|
|
259326
|
+
moved = true;
|
|
259327
|
+
if (change.text !== original.text) {
|
|
259328
|
+
const stat = await requireFile(to, original.stat, 1n);
|
|
259329
|
+
if (stat.mtimeNs !== original.stat.mtimeNs || stat.size !== original.stat.size) throw changed();
|
|
259330
|
+
await updateFile(to, destination, {
|
|
259331
|
+
...original,
|
|
259332
|
+
stat
|
|
259333
|
+
}, change.text, onRollback, signal);
|
|
259334
|
+
}
|
|
259335
|
+
}
|
|
259336
|
+
async function stageDeletion(path, parent, original, onRollback, onSuccess, signal) {
|
|
259337
|
+
await requireVersion(path, original.stat);
|
|
259338
|
+
signal.throwIfAborted();
|
|
259339
|
+
const stage = await inspectPatchDirectory(await mkdtemp(join(parent.path, '.blun-patch-')));
|
|
259340
|
+
onRollback(()=>removeDirectory(stage));
|
|
259341
|
+
const saved = join(stage.path, 'original');
|
|
259342
|
+
await assertPatchDirectory(parent);
|
|
259343
|
+
await assertPatchDirectory(stage);
|
|
259344
|
+
await requireVersion(path, original.stat);
|
|
259345
|
+
signal.throwIfAborted();
|
|
259346
|
+
await rename(path, saved);
|
|
259347
|
+
onRollback(async ()=>{
|
|
259348
|
+
await assertPatchDirectory(parent);
|
|
259349
|
+
await assertPatchDirectory(stage);
|
|
259350
|
+
await requireFile(saved, original.stat, 1n);
|
|
259351
|
+
await link(saved, path);
|
|
259352
|
+
await requireFile(path, original.stat, 2n);
|
|
259353
|
+
await requireFile(saved, original.stat, 2n);
|
|
259354
|
+
await unlink(saved);
|
|
259355
|
+
});
|
|
259356
|
+
const stored = await requireFile(saved, original.stat, 1n);
|
|
259357
|
+
onSuccess(async ()=>{
|
|
259358
|
+
await assertPatchDirectory(stage);
|
|
259359
|
+
await requireVersion(saved, stored);
|
|
259360
|
+
await unlink(saved);
|
|
259361
|
+
await removeDirectory(stage);
|
|
259362
|
+
});
|
|
259363
|
+
}
|
|
259364
|
+
async function commitLocalPatch(changes, signal) {
|
|
259365
|
+
if (changes.some((change)=>'text' in change && change.text.includes('\0'))) {
|
|
259366
|
+
throw new Error('Patch content must be UTF-8 text.');
|
|
259367
|
+
}
|
|
259368
|
+
const cleanups = [];
|
|
259369
|
+
await commitPatchPlan(changes, async (change, onRollback)=>{
|
|
259370
|
+
if (change.kind === 'add') return createFile(change.path, change.text, onRollback, signal);
|
|
259371
|
+
const parent = await parentFor(change.path);
|
|
259372
|
+
if (change.kind === 'move') return moveFile(change, parent, onRollback, signal);
|
|
259373
|
+
if (change.kind === 'delete') {
|
|
259374
|
+
return stageDeletion(change.path, parent, change.original, onRollback, (cleanup)=>cleanups.push(cleanup), signal);
|
|
259375
|
+
}
|
|
259376
|
+
return updateFile(change.path, parent, change.original, change.text, onRollback, signal);
|
|
259377
|
+
}, signal);
|
|
259378
|
+
const results = await Promise.allSettled(cleanups.map((cleanup)=>cleanup()));
|
|
259379
|
+
return {
|
|
259380
|
+
cleanupFailed: results.some((result)=>result.status === 'rejected')
|
|
259381
|
+
};
|
|
259382
|
+
}
|
|
259383
|
+
function resolveLocalBatchPath(raw, kaos, workspace) {
|
|
259384
|
+
if (/[\x00-\x1f\x7f\u202a-\u202e\u2066-\u2069]/.test(raw)) {
|
|
259385
|
+
throw new Error('A patch path contains unsupported control characters.');
|
|
259386
|
+
}
|
|
259387
|
+
assertPatchPathSpelling(raw);
|
|
259388
|
+
const path = resolvePathAccessPath(raw, {
|
|
259389
|
+
kaos,
|
|
259390
|
+
workspace,
|
|
259391
|
+
operation: 'write'
|
|
259392
|
+
});
|
|
259393
|
+
assertPatchPathSpelling(path);
|
|
259394
|
+
if (!isWithinWorkspace(path, workspace, kaos.pathClass())) {
|
|
259395
|
+
throw new Error('Every patch target must be inside the workspace.');
|
|
259396
|
+
}
|
|
259397
|
+
return path;
|
|
259398
|
+
}
|
|
259399
|
+
function localBatchAccess(name, targets, subject, kaos, workspace) {
|
|
259400
|
+
const options = {
|
|
259401
|
+
cwd: workspace.workspaceDir,
|
|
259402
|
+
pathClass: kaos.pathClass(),
|
|
259403
|
+
homeDir: kaos.gethome()
|
|
259404
|
+
};
|
|
259405
|
+
const matchesTargets = (pattern, any)=>{
|
|
259406
|
+
if (pattern.startsWith('batch:')) return pattern === subject;
|
|
259407
|
+
const matches = (path)=>matchesPathRuleSubject(pattern, path, options);
|
|
259408
|
+
return any ? targets.some(matches) : targets.every(matches);
|
|
259409
|
+
};
|
|
259410
|
+
return {
|
|
259411
|
+
accesses: targets.flatMap(ToolAccesses.readWriteFile),
|
|
259412
|
+
approvalRule: literalRulePattern(name, subject),
|
|
259413
|
+
matchesRule: (pattern, decision)=>matchesTargets(pattern, decision !== "allow")
|
|
259414
|
+
};
|
|
259415
|
+
}
|
|
259416
|
+
const InputSchema = z.strictObject({
|
|
259417
|
+
edits: z.array(z.strictObject({
|
|
259418
|
+
path: z.string().min(1).describe('An existing UTF-8 file inside the local workspace.'),
|
|
259419
|
+
edits: z.array(z.strictObject({
|
|
259420
|
+
oldText: z.string().min(1).describe('Exact text from Read, without the line numbers.'),
|
|
259421
|
+
newText: z.string().describe('Replacement text. Use LF for files shown with normalized CRLF endings.'),
|
|
259422
|
+
replaceAll: z.boolean().optional().describe('Replace all occurrences. Otherwise the match must be unique.')
|
|
259423
|
+
})).min(1).describe('Non-overlapping matches against the original contents of this file.')
|
|
259424
|
+
})).min(1).max(25).describe('Group replacements by file and name each target once.')
|
|
259425
|
+
});
|
|
259426
|
+
function fileFailure(error) {
|
|
259427
|
+
if (error instanceof PathSecurityError) {
|
|
259428
|
+
if (error.code === 'PATH_SENSITIVE') return 'Sensitive file access is blocked.';
|
|
259429
|
+
if (error.code === 'PATH_OUTSIDE_WORKSPACE') return 'Every target must be inside the workspace.';
|
|
259430
|
+
return 'Invalid file path.';
|
|
259431
|
+
}
|
|
259432
|
+
const code = error?.code;
|
|
259433
|
+
if (typeof code === 'string' && /^E[A-Z0-9_]+$/.test(code)) return `Could not access or modify a file (${code}).`;
|
|
259434
|
+
return error instanceof Error ? error.message : 'Could not edit the file.';
|
|
259435
|
+
}
|
|
259436
|
+
function quotePath(path) {
|
|
259437
|
+
return JSON.stringify(path).replace(/[\u007f-\u009f\u202a-\u202e\u2066-\u2069]/g, (character)=>'\\u' + character.charCodeAt(0).toString(16).padStart(4, '0'));
|
|
259438
|
+
}
|
|
259439
|
+
function exceedsLineHint(text) {
|
|
259440
|
+
let lines = text.length > 0 && !/[\r\n]$/.test(text) ? 1 : 0;
|
|
259441
|
+
for (const _ of text.matchAll(/\r\n|[\r\n]/g)){
|
|
259442
|
+
if (++lines > 500) return true;
|
|
259443
|
+
}
|
|
259444
|
+
return false;
|
|
259445
|
+
}
|
|
259446
|
+
class EditBatchTool {
|
|
259447
|
+
kaos;
|
|
259448
|
+
workspace;
|
|
259449
|
+
name = 'EditBatch';
|
|
259450
|
+
description = 'Make exact text replacements across up to 25 existing local workspace files in one operation. ' + 'Read the files first. Every match is checked against the original contents before writing anything. ' + 'Failures or stops roll back applied changes; incomplete rollback is reported. Use Edit for one file, or ApplyPatch to add, move, or delete files.';
|
|
259451
|
+
parameters = toInputJsonSchema(InputSchema);
|
|
259452
|
+
constructor(kaos, workspace){
|
|
259453
|
+
this.kaos = kaos;
|
|
259454
|
+
this.workspace = workspace;
|
|
259455
|
+
}
|
|
259456
|
+
resolveExecution(args) {
|
|
259457
|
+
const files = args.edits.map((file)=>{
|
|
259458
|
+
const displayPath = quotePath(file.path);
|
|
259459
|
+
try {
|
|
259460
|
+
return {
|
|
259461
|
+
...file,
|
|
259462
|
+
path: resolveLocalBatchPath(file.path, this.kaos, this.workspace),
|
|
259463
|
+
displayPath
|
|
259464
|
+
};
|
|
259465
|
+
} catch (error) {
|
|
259466
|
+
throw new Error(`${displayPath}: ${fileFailure(error)}`, {
|
|
259467
|
+
cause: error
|
|
259468
|
+
});
|
|
259469
|
+
}
|
|
259470
|
+
});
|
|
259471
|
+
const targets = files.map((file)=>file.path);
|
|
259472
|
+
assertUniqueBatchPaths(targets);
|
|
259473
|
+
const subject = 'batch:' + createHash('sha256').update(JSON.stringify(targets)).digest('hex');
|
|
259474
|
+
const summary = `Edit text in ${files.length} file(s)`;
|
|
259475
|
+
return {
|
|
259476
|
+
...localBatchAccess(this.name, targets, subject, this.kaos, this.workspace),
|
|
259477
|
+
description: summary,
|
|
259478
|
+
display: {
|
|
259479
|
+
kind: 'generic',
|
|
259480
|
+
summary,
|
|
259481
|
+
detail: files.map(({ path, edits })=>`${quotePath(path)} (${edits.length} edit(s))`).join('\n')
|
|
259482
|
+
},
|
|
259483
|
+
execute: ({ signal })=>this.executeBatch(files, signal)
|
|
259484
|
+
};
|
|
259485
|
+
}
|
|
259486
|
+
async executeBatch(files, signal) {
|
|
259487
|
+
try {
|
|
259488
|
+
const changes = [];
|
|
259489
|
+
const longFiles = [];
|
|
259490
|
+
let replacements = 0;
|
|
259491
|
+
for (const { path, displayPath, edits } of files){
|
|
259492
|
+
try {
|
|
259493
|
+
signal.throwIfAborted();
|
|
259494
|
+
const original = await inspectLocalPatchFile(path, signal);
|
|
259495
|
+
if (original === undefined) throw new Error('File does not exist.');
|
|
259496
|
+
const noChange = edits.findIndex((edit)=>edit.oldText === edit.newText);
|
|
259497
|
+
if (noChange !== -1) throw new ExactEditError(noChange + 1, 'oldText and newText are identical.');
|
|
259498
|
+
const { text, count } = replaceExactText(original.text, displayPath, edits.map((edit)=>({
|
|
259499
|
+
old_string: edit.oldText,
|
|
259500
|
+
new_string: edit.newText,
|
|
259501
|
+
replace_all: edit.replaceAll
|
|
259502
|
+
})));
|
|
259503
|
+
if (text !== original.text) {
|
|
259504
|
+
changes.push({
|
|
259505
|
+
kind: 'update',
|
|
259506
|
+
path,
|
|
259507
|
+
original,
|
|
259508
|
+
text
|
|
259509
|
+
});
|
|
259510
|
+
replacements += count;
|
|
259511
|
+
if (exceedsLineHint(text)) longFiles.push(displayPath);
|
|
259512
|
+
}
|
|
259513
|
+
} catch (error) {
|
|
259514
|
+
return {
|
|
259515
|
+
isError: true,
|
|
259516
|
+
output: `${displayPath}${error instanceof ExactEditError ? ` edit ${error.editNumber}` : ''}: ${fileFailure(error)}`
|
|
259517
|
+
};
|
|
259518
|
+
}
|
|
259519
|
+
}
|
|
259520
|
+
const { cleanupFailed } = await commitLocalPatch(changes, signal);
|
|
259521
|
+
return {
|
|
259522
|
+
output: `EditBatch applied: ${replacements} replacements across ${changes.length} files.` + (longFiles.length ? ` ${longFiles.join(', ')}: over 500 lines; follow the project's own size guidance.` : '') + (cleanupFailed ? ' Some temporary recovery files could not be removed.' : '')
|
|
259523
|
+
};
|
|
259524
|
+
} catch (error) {
|
|
259525
|
+
return {
|
|
259526
|
+
isError: true,
|
|
259527
|
+
output: fileFailure(error)
|
|
259528
|
+
};
|
|
259529
|
+
}
|
|
259530
|
+
}
|
|
259531
|
+
}
|
|
259532
|
+
return EditBatchTool;
|
|
259533
|
+
})();
|
|
259534
|
+
return new editBatchToolClass(kaos, workspace);
|
|
259535
|
+
}
|
|
259536
|
+
// END WAVE 3 EDIT BATCH
|
|
258968
259537
|
function makeEditInputSchema() {
|
|
258969
259538
|
const pathSchema = string().describe("Path to the text file to edit. Relative paths resolve against the working directory; a path outside the working directory must be absolute.");
|
|
258970
259539
|
const replacementSchema = object({
|
|
@@ -266222,6 +266791,7 @@ const BLUN_LEAN_TOOL_NAMES = new Set([
|
|
|
266222
266791
|
"Write",
|
|
266223
266792
|
"Edit",
|
|
266224
266793
|
"ApplyPatch",
|
|
266794
|
+
"EditBatch",
|
|
266225
266795
|
"Grep",
|
|
266226
266796
|
"Glob",
|
|
266227
266797
|
"Bash",
|
|
@@ -270270,6 +270840,7 @@ var ToolManager = class {
|
|
|
270270
270840
|
new WriteTool(kaos, workspace, () => this.agent.context.history, toolServices?.lsp),
|
|
270271
270841
|
new EditTool(kaos, workspace, () => this.agent.context.history, toolServices?.lsp),
|
|
270272
270842
|
kaos instanceof LocalKaos && new ApplyPatchTool(kaos, { workspaceDir: cwd, additionalDirs: this.agent.getAdditionalDirs() }),
|
|
270843
|
+
kaos instanceof LocalKaos && this.agent.experimentalFlags.enabled("edit_batch") && createEditBatchTool(kaos, { workspaceDir: cwd, additionalDirs: this.agent.getAdditionalDirs() }),
|
|
270273
270844
|
new GrepTool(kaos, workspace, this.agent.telemetry),
|
|
270274
270845
|
new GlobTool(kaos, workspace, this.agent.telemetry),
|
|
270275
270846
|
new BashTool(kaos, cwd, background, {
|