list_directory 对齐 ls 语义:path 传空字符串或省略时等同于当前目录(任务目录),不再报「路径不能为空」;definitions.json 同步把 path 改为可选
This commit is contained in:
@@ -169,11 +169,10 @@
|
|||||||
"description": "Lists files and directories in a given path.\n\nUse this to see the contents of a directory. For searching by name or content, prefer `find_path` or `grep`.",
|
"description": "Lists files and directories in a given path.\n\nUse this to see the contents of a directory. For searching by name or content, prefer `find_path` or `grep`.",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": ["path"],
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"path": {
|
"path": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Path of the directory to list, relative to the session working directory. Absolute paths are also accepted."
|
"description": "Path of the directory to list, relative to the session working directory. Absolute paths are also accepted. If empty or omitted, lists the current working directory (like `ls` with no argument)."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -420,7 +420,9 @@ async function toolEditFile(ctx, args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function toolListDirectory(ctx, args) {
|
async function toolListDirectory(ctx, args) {
|
||||||
const abs = resolveInTask(ctx.taskDir, args.path);
|
// 对齐 ls 语义:path 缺省或为空字符串时等同于当前目录(任务目录)。
|
||||||
|
const p = typeof args.path === 'string' && args.path.trim() ? args.path : '.';
|
||||||
|
const abs = resolveInTask(ctx.taskDir, p);
|
||||||
const entries = await fsp.readdir(abs, { withFileTypes: true });
|
const entries = await fsp.readdir(abs, { withFileTypes: true });
|
||||||
const dirs = []; const files = [];
|
const dirs = []; const files = [];
|
||||||
for (const e of entries) {
|
for (const e of entries) {
|
||||||
|
|||||||
Reference in New Issue
Block a user