MCPcopy
hub / github.com/Dimillian/CodexMonitor / parseSearch

Function parseSearch

src/utils/threadItems.explore.ts:204–222  ·  view source on GitHub ↗
(tokens: string[])

Source from the content-addressed store, hash-verified

202}
203
204function parseSearch(tokens: string[]): ExploreEntry | null {
205 const commandName = tokens[0]?.toLowerCase() ?? "";
206 const hasFilesFlag = tokens.some((token) => token === "--files");
207 if (tokens[0] === "rg" && hasFilesFlag) {
208 const paths = findPathTokens(tokens);
209 const path = paths[paths.length - 1] || "rg --files";
210 return { kind: "list", label: path };
211 }
212 const positional = collectNonFlagOperands(tokens, commandName);
213 if (positional.length === 0) {
214 return null;
215 }
216 const query = positional[0];
217 const rawPath = positional.length > 1 ? positional[1] : "";
218 const path =
219 commandName === "rg" ? rawPath : rawPath && isPathLike(rawPath) ? rawPath : "";
220 const label = path ? `${query} in ${path}` : query;
221 return { kind: "search", label };
222}
223
224function parseRead(tokens: string[]): ExploreEntry[] | null {
225 const paths = findPathTokens(tokens).filter(Boolean);

Callers 1

parseCommandSegmentFunction · 0.85

Calls 3

findPathTokensFunction · 0.85
collectNonFlagOperandsFunction · 0.85
isPathLikeFunction · 0.85

Tested by

no test coverage detected