xonecas.io
64875
Mc

mini-coder / commit 4f63797

refactor: rename write->create and edit->replace tools

xonecas2026-02-20 4f637972d92dc3541c12db2f5df861c59f2c97e5 parent a867716

3 files changed

src/agent/tools.ts+4−4
@@ -1,12 +1,12 @@
11 import type { ToolDef } from "../llm-api/types.ts";
2-import { editTool } from "../tools/edit.ts";
2+import { createTool } from "../tools/create.ts";
33 import { globTool } from "../tools/glob.ts";
44 import { grepTool } from "../tools/grep.ts";
55 import { insertTool } from "../tools/insert.ts";
66 import { readTool } from "../tools/read.ts";
7+import { replaceTool } from "../tools/replace.ts";
78 import { shellTool } from "../tools/shell.ts";
89 import { createSubagentTool } from "../tools/subagent.ts";
9-import { writeTool } from "../tools/write.ts";
1010
1111 // ─── Hook types ────────────────────────────────────────────────────────────────
1212
@@ -72,8 +72,8 @@ export function buildToolSet(opts: {
7272 withCwdDefault(grepTool as ToolDef, opts.cwd),
7373 withCwdDefault(readTool as ToolDef, opts.cwd),
7474 // Write: create/overwrite, replace/delete, insert
75- withCwdDefault(writeTool as ToolDef, opts.cwd),
76- withCwdDefault(editTool as ToolDef, opts.cwd),
75+ withCwdDefault(createTool as ToolDef, opts.cwd),
76+ withCwdDefault(replaceTool as ToolDef, opts.cwd),
7777 withCwdDefault(insertTool as ToolDef, opts.cwd),
7878 // Shell and subagent
7979 withCwdDefault(shellTool as ToolDef, opts.cwd),
src/tools/create.ts+3−3
@@ -17,12 +17,12 @@ export interface WriteOutput {
1717 created: boolean;
1818 }
1919
20-export const writeTool: ToolDef<WriteInput, WriteOutput> = {
21- name: "write",
20+export const createTool: ToolDef<WriteInput, WriteOutput> = {
21+ name: "create",
2222 description:
2323 "Create a new file or fully overwrite an existing file with the given content. " +
2424 "Use this only for new files. " +
25- "For targeted line edits on existing files, **use `edit` or `insert` instead**.",
25+ "For targeted line edits on existing files, **use `replace` or `insert` instead**.",
2626 schema: WriteSchema,
2727 execute: async (input) => {
2828 const cwd = input.cwd ?? process.cwd();
src/tools/replace.ts+4−4
@@ -33,14 +33,14 @@ export interface EditOutput {
3333 const HASH_NOT_FOUND_ERROR =
3434 "Hash not found. Re-read the file to get current anchors.";
3535
36-export const editTool: ToolDef<EditInput, EditOutput> = {
37- name: "edit",
36+export const replaceTool: ToolDef<EditInput, EditOutput> = {
37+ name: "replace",
3838 description:
3939 "Replace or delete a range of lines in an existing file using hashline anchors. " +
4040 'Anchors come from the `read` or `grep` tools (format: "line:hash", e.g. "11:a3"). ' +
4141 "Provide startAnchor alone to target a single line, or add endAnchor for a range. " +
4242 "Set newContent to the replacement text, or omit it to delete the range. " +
43- "To create a file use `write`. To insert without replacing any lines use `insert`.",
43+ "To create a file use `create`. To insert without replacing any lines use `insert`.",
4444 schema: EditSchema,
4545 execute: async (input) => {
4646 const cwd = input.cwd ?? process.cwd();
@@ -53,7 +53,7 @@ export const editTool: ToolDef<EditInput, EditOutput> = {
5353 const file = Bun.file(filePath);
5454 if (!(await file.exists())) {
5555 throw new Error(
56- `File not found: "${relPath}". To create a new file use the \`write\` tool.`,
56+ `File not found: "${relPath}". To create a new file use the \`create\` tool.`,
5757 );
5858 }