MCPcopy Create free account
hub / github.com/boringstack-xyz/boringstack / extractPaths

Function extractPaths

tools/spec-loop/hooks/gate.ts:127–145  ·  view source on GitHub ↗
(payload: unknown, root: string)

Source from the content-addressed store, hash-verified

125}
126
127function extractPaths(payload: unknown, root: string): string[] {
128 if (typeof payload !== "object" || payload === null) {
129 return [];
130 }
131 const toolInput =
132 "tool_input" in payload &&
133 typeof (payload as { tool_input?: unknown }).tool_input === "object" &&
134 (payload as { tool_input?: unknown }).tool_input !== null
135 ? ((payload as { tool_input?: Record<string, unknown> }).tool_input ?? {})
136 : {};
137 const paths: string[] = [];
138 for (const key of ["file_path", "path"] as const) {
139 const value = toolInput[key];
140 if (typeof value === "string" && value.length > 0) {
141 paths.push(normalize(value, root));
142 }
143 }
144 return [...new Set(paths)].sort();
145}
146
147function isTest(path: string): boolean {
148 return TEST_PATTERNS.some((re) => re.test(path));

Callers 1

mainFunction · 0.85

Calls 1

normalizeFunction · 0.70

Tested by

no test coverage detected