From 2dfb4a246acfd15b7c875aeb552ee1a9a63ac71e Mon Sep 17 00:00:00 2001 From: kicer Date: Thu, 17 Sep 2026 16:08:11 +0800 Subject: [PATCH] =?UTF-8?q?list=5Fdirectory=20=E5=AF=B9=E9=BD=90=20ls=20?= =?UTF-8?q?=E8=AF=AD=E4=B9=89=EF=BC=9Apath=20=E4=BC=A0=E7=A9=BA=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E4=B8=B2=E6=88=96=E7=9C=81=E7=95=A5=E6=97=B6=E7=AD=89?= =?UTF-8?q?=E5=90=8C=E4=BA=8E=E5=BD=93=E5=89=8D=E7=9B=AE=E5=BD=95=EF=BC=88?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E7=9B=AE=E5=BD=95=EF=BC=89=EF=BC=8C=E4=B8=8D?= =?UTF-8?q?=E5=86=8D=E6=8A=A5=E3=80=8C=E8=B7=AF=E5=BE=84=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E3=80=8D=EF=BC=9Bdefinitions.json=20?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=8A=8A=20path=20=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E5=8F=AF=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/server/tools/definitions.json | 3 +-- app/server/tools/executor.js | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) 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) {