This commit is contained in:
seb
2026-10-06 03:30:31 +02:00
parent 0369b4e819
commit d5e58e76e1
15 changed files with 103 additions and 196 deletions

View File

@@ -67,17 +67,10 @@ export function createPatchTool({ googleAuthId }) {
return defineTool({
name: 'patch',
description:
'Create, overwrite, or search-and-replace text in a virtual filesystem (VFS) file. ' +
'This is the only way to write VFS files — javascript_execute writes stay for bulk binary artifacts.\n' +
'Each op needs "file" and "replace"; "search" selects the mode:\n' +
' - search omitted/null → create the file, or overwrite it entirely (directories are auto-created).\n' +
' - search given → replace the FIRST occurrence of that exact text. "skiplines" skips N lines before\n' +
' matching, which is how you target a later duplicate.\n' +
'Create a SKILL file (title on line 1, markdown below; exempt from reset_vfs):\n' +
'[{"file": "image-pipeline.SKILL", "search": null, "replace": "Image pipeline\\n\\n# Steps\\n1. …"}]\n' +
'or, letting the tool render the title line for you:\n' +
'[{"file": "image-pipeline.SKILL", "search": null, "title": "Image pipeline", "replace": "# Steps\\n1. …"}]\n' +
'Read a file with read_file first and copy its text into "search" verbatim — the match is exact.',
'Create, overwrite, or search-and-replace text in VFS files. Operations apply in order. ' +
'Mode: search null/omitted = create or overwrite (directories auto-created). ' +
'search provided = replace first verbatim occurrence (read file with read_file first). ' +
'SKILL files: root-only "<slug>.SKILL" (line 1 is title, or provide title field).',
strict: false,
parameters: {
type: 'object',
@@ -86,7 +79,7 @@ export function createPatchTool({ googleAuthId }) {
properties: {
operations: {
type: 'array',
description: 'Operations, applied in order. If one fails, earlier ones are kept and the error names the op.',
description: 'Ordered patch operations.',
items: {
type: 'object',
additionalProperties: false,
@@ -94,28 +87,23 @@ export function createPatchTool({ googleAuthId }) {
properties: {
file: {
type: 'string',
description:
'VFS path, relative to the root, forward slashes (e.g. "notes.md", "image-pipeline.SKILL"). ' +
'SKILL file names may not contain "/" — they live at the root.',
description: 'VFS path (e.g. "notes.md", "pipeline.SKILL"). SKILL files must be root-level (no "/").',
},
search: {
type: ['string', 'null'],
description: 'Exact existing text to replace. null/omitted = create or overwrite the whole file.',
description: 'Exact text to replace. null/omitted = overwrite or create file.',
},
replace: {
type: 'string',
description:
'Text to write. For a SKILL file you may pass "{ title, markdown }" and the title line is rendered for you.',
description: 'Replacement text.',
},
title: {
type: 'string',
description:
'Optional title for a SKILL file written with a raw markdown string in "replace". ' +
'Becomes line 1 of the file.',
description: 'Optional line-1 title for SKILL files.',
},
skiplines: {
type: 'integer',
description: 'Skip this many lines before searching for "search". Use when the text occurs more than once.',
description: 'Lines to skip before searching.',
},
},
},