MCPcopy Create free account
hub / github.com/Work-Fisher/code-claw / readFile

Function readFile

compatible-shell/src/tools.mjs:202–220  ·  view source on GitHub ↗
(workspaceDir, input)

Source from the content-addressed store, hash-verified

200}
201
202async function readFile(workspaceDir, input) {
203 if (typeof input.path !== 'string' || !input.path) {
204 throw new Error('read_file requires a path')
205 }
206
207 const absolutePath = resolveWorkspacePath(workspaceDir, input.path)
208 const text = await fs.readFile(absolutePath, 'utf8')
209 const maxChars =
210 Number.isInteger(input.max_chars) && input.max_chars > 0
211 ? Math.min(input.max_chars, MAX_READ_CHARS)
212 : MAX_READ_CHARS
213
214 return {
215 ok: true,
216 path: toWorkspaceRelative(workspaceDir, absolutePath),
217 truncated: text.length > maxChars,
218 content: text.slice(0, maxChars),
219 }
220}
221
222async function writeFile(workspaceDir, input) {
223 if (typeof input.path !== 'string' || !input.path) {

Callers 15

loadMemoryIndexFunction · 0.85
scanMemoryManifestFunction · 0.85
loadMemoryFilesFunction · 0.85
loadDailyLogsFunction · 0.85
shouldRunDreamFunction · 0.85
runDreamFunction · 0.85
loadSkillsFunction · 0.85
scanMagicDocsFunction · 0.85
updateMagicDocFunction · 0.85
loadConfigFunction · 0.85
readAppSessionsStoreFunction · 0.85
loadRuntimeQueueStateFunction · 0.85

Calls 2

resolveWorkspacePathFunction · 0.85
toWorkspaceRelativeFunction · 0.85

Tested by

no test coverage detected