diff --git a/app/server/tools/definitions.json b/app/server/tools/definitions.json index fa6d072..f67b1e4 100644 --- a/app/server/tools/definitions.json +++ b/app/server/tools/definitions.json @@ -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`.", "parameters": { "type": "object", - "required": ["path"], "properties": { "path": { "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)." } } } diff --git a/app/server/tools/executor.js b/app/server/tools/executor.js index 25775d1..3f5f49e 100644 --- a/app/server/tools/executor.js +++ b/app/server/tools/executor.js @@ -420,7 +420,9 @@ async function toolEditFile(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 dirs = []; const files = []; for (const e of entries) {