files.ts
commands/files/files.ts
20
Lines
688
Bytes
1
Exports
5
Imports
10
Keywords
What this is
This page documents one file from the repository and includes its full source so you can read it without leaving the docs site.
Beginner explanation
This file lives in the command layer. It likely turns a user action into concrete program behavior.
How it is used
Start from the exports list and related files. Those are the easiest clues for where this file fits into the system.
Expert explanation
Architecturally, this file intersects with file-tools, commands. It contains 20 lines, 5 detected imports, and 1 detected exports.
Important relationships
Detected exports
call
Keywords
contextfilesrelativetoolusecontextlocalcommandresultgetcwdutilscachekeysreadfilestatetext
Detected imports
path../../Tool.js../../types/command.js../../utils/cwd.js../../utils/fileStateCache.js
Source notes
This page embeds the full file contents. Small or leaf files are still indexed honestly instead of being over-explained.
Full source
import { relative } from 'path'
import type { ToolUseContext } from '../../Tool.js'
import type { LocalCommandResult } from '../../types/command.js'
import { getCwd } from '../../utils/cwd.js'
import { cacheKeys } from '../../utils/fileStateCache.js'
export async function call(
_args: string,
context: ToolUseContext,
): Promise<LocalCommandResult> {
const files = context.readFileState ? cacheKeys(context.readFileState) : []
if (files.length === 0) {
return { type: 'text' as const, value: 'No files in context' }
}
const fileList = files.map(file => relative(getCwd(), file)).join('\n')
return { type: 'text' as const, value: `Files in context:\n${fileList}` }
}