resolve shell from PATH (fallback /bin/sh); rewrite write tool with lineOffset/byteOffset + delLines/delBytes
This commit is contained in:
@@ -401,30 +401,6 @@ struct JParser {
|
||||
return true;
|
||||
}
|
||||
if (c == '[') {
|
||||
pos++;
|
||||
skip_ws();
|
||||
out = Json::array();
|
||||
if (pos < src.size() && src[pos] == ']') {
|
||||
pos++;
|
||||
return true;
|
||||
}
|
||||
while (true) {
|
||||
Json elem;
|
||||
if (!parse_value(elem, depth + 1)) return false;
|
||||
out.aval.push_back(std::move(elem));
|
||||
skip_ws();
|
||||
if (pos < src.size() && src[pos] == ',') {
|
||||
pos++;
|
||||
continue;
|
||||
}
|
||||
if (pos < src.size() && src[pos] == ']') {
|
||||
pos++;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (c == '{') {
|
||||
pos++;
|
||||
skip_ws();
|
||||
out = Json::object();
|
||||
@@ -491,12 +467,14 @@ static const char *TOOLS_JSON = R"JSON([
|
||||
},"required":["filePath"]}}},
|
||||
{"type":"function","function":{
|
||||
"name":"write",
|
||||
"description":"Write content to a file. If offset and del_bytes are both omitted, the entire file is overwritten with the new content; otherwise content is written at the given byte offset, optionally deleting bytes first.",
|
||||
"description":"Write content to a file. If none of lineOffset, byteOffset, delLines and delBytes are provided, the entire file is overwritten with the new content (the file and any necessary parent directories are created if missing); otherwise content is written at the given line or byte offset, optionally deleting lines or bytes first. Line-based editing is primary.",
|
||||
"parameters":{"type":"object","properties":{
|
||||
"filePath":{"type":"string","description":"The path to the file to write"},
|
||||
"content":{"type":"string","description":"The content to write to the file"},
|
||||
"offset":{"type":"integer","description":"Byte offset to start writing from. If omitted together with del_bytes, the whole file is overwritten instead. Defaults to 0 (start of file)."},
|
||||
"del_bytes":{"type":"integer","description":"Bytes to delete starting at offset. If omitted together with offset, the whole file is overwritten instead."}
|
||||
"lineOffset":{"type":"integer","description":"1-indexed line number where writing begins (1 = first line). Takes precedence over byteOffset when both are given."},
|
||||
"byteOffset":{"type":"integer","description":"Byte offset where writing begins. Used only when lineOffset is not given."},
|
||||
"delLines":{"type":"integer","description":"Number of lines to delete starting at the insertion point. Takes precedence over delBytes when both are given."},
|
||||
"delBytes":{"type":"integer","description":"Number of bytes to delete starting at the insertion point. Used only when delLines is not given."}
|
||||
},"required":["filePath","content"]}}}
|
||||
])JSON";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user