Code Reader
首页
帮助
设计文档
首页
帮助
设计文档
  • Ls 工具

Ls 工具

Ls 工具用于列出目录内容。

概述

Ls 工具允许 AI 助手列出目录中的文件和子目录。它支持:

  • 列出当前目录
  • 列出指定路径
  • 识别文件类型

定义位置

  • packages/opencode/src/tool/ls.ts

参数说明

参数名类型必填说明
pathstring否要列出的目录路径

TypeScript 类型定义

export type LsInput = {
  path?: string
}

export type LsOutput = {
  title: string
  output: string
  metadata: {
    entries: FileInfo[]
  }
}

典型使用场景

列出当前目录

await LsTool.execute({}, ctx)

列出指定目录

await LsTool.execute({ path: "src/components" }, ctx)

相关文档

  • Glob - 模式匹配查找文件