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

Function parseWindowsWorkspaceFileList

src/utils/workspace-file-discovery.ts:133–157  ·  view source on GitHub ↗
(
  stdout: string,
  workingDir: string,
  options: WorkspaceFileDiscovery,
)

Source from the content-addressed store, hash-verified

131}
132
133export function parseWindowsWorkspaceFileList(
134 stdout: string,
135 workingDir: string,
136 options: WorkspaceFileDiscovery,
137) {
138 const root = workingDir.replaceAll("/", "\\").replace(/\\+$/, "");
139 const excluded = options.excludedPatterns
140 .filter((pattern) => !pattern.includes("/"))
141 .map((pattern) => pattern.toLowerCase());
142 const relative = stdout
143 .split(/\r?\n/)
144 .map((line) => line.trim())
145 .filter(Boolean)
146 .map((line) =>
147 line.toLowerCase().startsWith(`${root.toLowerCase()}\\`)
148 ? line.slice(root.length + 1)
149 : line,
150 )
151 .map((line) => line.replace(/\\/g, "/"))
152 .filter((line) => {
153 const dirs = line.toLowerCase().split("/").slice(0, -1);
154 return !dirs.some((dir) => excluded.includes(dir));
155 });
156 return parseWorkspaceFileList(relative.join("\n"), options.maxFiles);
157}

Callers 2

useLocalWorkspaceFilesFunction · 0.90

Calls 1

parseWorkspaceFileListFunction · 0.85

Tested by

no test coverage detected