MCPcopy Create free account
hub / github.com/OpenHands/OpenHands / buildWorkspaceFileListCommand

Function buildWorkspaceFileListCommand

src/utils/workspace-file-discovery.ts:60–78  ·  view source on GitHub ↗
(
  options: WorkspaceFileDiscovery,
)

Source from the content-addressed store, hash-verified

58
59// @spec WFD-001 — Configurable local workspace discovery
60export function buildWorkspaceFileListCommand(
61 options: WorkspaceFileDiscovery,
62): string {
63 const patterns = options.excludedPatterns.map((pattern) => {
64 if (!pattern.includes("/")) return `-name ${shellQuote(pattern)}`;
65 const relative = pattern.startsWith("./") ? pattern : `./${pattern}`;
66 return `-path ${shellQuote(relative)}`;
67 });
68 const prune = patterns.length
69 ? `-type d \\( ${patterns.join(" -o ")} \\) -prune -o `
70 : "";
71 const types = options.includeSymlinks
72 ? "\\( -type f -o \\( -type l -exec test -f {} \\; \\) \\)"
73 : "-type f";
74 // Fetch one extra path to distinguish truncation from an exact-size result.
75 const limit =
76 options.maxFiles > 0 ? ` | head -n ${options.maxFiles + 1}` : "";
77 return `find . ${prune}${types} -print 2>/dev/null | sort${limit}`;
78}
79
80export function parseWorkspaceFileList(stdout: string, maxFiles: number) {
81 const paths = Array.from(

Callers 2

useLocalWorkspaceFilesFunction · 0.90
listFunction · 0.90

Calls 1

shellQuoteFunction · 0.70

Tested by 1

listFunction · 0.72