MCPcopy Create free account
hub / github.com/bearlyai/OpenADE / handleDescribePath

Function handleDescribePath

projects/electron/src/modules/code/files.ts:542–686  ·  view source on GitHub ↗
(params: DescribePathParams)

Source from the content-addressed store, hash-verified

540// ============================================================================
541
542async function handleDescribePath(params: DescribePathParams): Promise<DescribePathResponse> {
543 const {
544 path: targetPath,
545 readContents = false,
546 maxReadSize,
547 showHidden = false,
548 } = params
549
550 logger.info("[Files:describePath] Describing path", JSON.stringify({ targetPath, readContents, maxReadSize, showHidden }))
551
552 // Check existence
553 if (!fs.existsSync(targetPath)) {
554 return { type: "not_found", path: targetPath }
555 }
556
557 let stats: fs.Stats
558 try {
559 stats = fs.lstatSync(targetPath)
560 } catch (err) {
561 return {
562 type: "error",
563 path: targetPath,
564 message: err instanceof Error ? err.message : "Failed to stat path",
565 }
566 }
567
568 const mode = stats.mode
569
570 // Handle directory
571 if (stats.isDirectory()) {
572 const entries: PathEntry[] = []
573
574 try {
575 const rawEntries = fs.readdirSync(targetPath, { withFileTypes: true })
576
577 for (const entry of rawEntries) {
578 // Skip hidden unless requested
579 if (!showHidden && entry.name.startsWith(".")) continue
580
581 const fullPath = path.join(targetPath, entry.name)
582 let entrySize = 0
583 let entryMode = 0
584
585 try {
586 const entryStat = fs.statSync(fullPath)
587 entrySize = entryStat.size
588 entryMode = entryStat.mode
589 } catch (err) {
590 logger.debug('[Files] Error statting entry, skipping:', err)
591 continue // Skip entries we can't stat
592 }
593
594 entries.push({
595 name: entry.name,
596 path: fullPath,
597 isDir: entry.isDirectory(),
598 isSymlink: entry.isSymbolicLink(),
599 size: entrySize,

Callers 1

describeRuntimePathFunction · 0.85

Calls 4

classifyFileMetadataFunction · 0.90
readFileSampleSyncFunction · 0.85
isDirectoryMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected