MCPcopy Create free account
hub / github.com/Qinbf/groundmap / classifyCall

Function classifyCall

tools/debug-console/lib/build-flow-graph.ts:154–220  ·  view source on GitHub ↗
(name: string, args: Record<string, unknown>)

Source from the content-addressed store, hash-verified

152}
153
154function classifyCall(name: string, args: Record<string, unknown>): {
155 kind: NodeKind;
156 key: string;
157 title: string;
158 subtitle?: string;
159 path?: string;
160 anchor?: string;
161 isBlock?: boolean;
162} {
163 const rawPath =
164 (typeof args.path === "string" && args.path) ||
165 (typeof args.file_path === "string" && args.file_path) ||
166 (typeof args.target_file === "string" && args.target_file) ||
167 (typeof args.notebook_path === "string" && args.notebook_path) ||
168 "";
169 const anchor = typeof args.anchor === "string" ? args.anchor : undefined;
170
171 // backlinks / outlinks 也带 path arg 但不是"读文件"——是查链接关系
172 // 必须先于通用 path 检查,避免被误分类为 file
173 if (name === "backlinks" || name === "outlinks") {
174 const norm = rawPath ? normalizeAbsToRel(rawPath) : "(unknown)";
175 return {
176 kind: "list",
177 key: `${name}:${norm}`,
178 title: name === "backlinks" ? `← ${basename(norm)}` : `→ ${basename(norm)}`,
179 subtitle: name,
180 };
181 }
182
183 if (rawPath) {
184 const normPath = normalizeAbsToRel(rawPath);
185 return {
186 kind: "file",
187 key: anchor ? `${normPath}#${anchor}` : normPath,
188 title: basename(normPath),
189 subtitle: dirOf(normPath),
190 path: normPath,
191 anchor,
192 isBlock: anchor ? /^[ptcf]-/.test(anchor) : false,
193 };
194 }
195 if (name === "search" || name === "Grep" || name === "Glob") {
196 const q =
197 (typeof args.query === "string" && args.query) ||
198 (typeof args.pattern === "string" && args.pattern) || "";
199 return {
200 kind: "search",
201 key: `search:${name}:${q}`,
202 title: q ? `🔍 ${q.slice(0, 32)}` : `🔍 ${name}`,
203 subtitle: name,
204 };
205 }
206 if (name.startsWith("list_")) {
207 return {
208 kind: "list",
209 key: `list:${name}`,
210 title: name.replace(/_/g, " "),
211 subtitle: "list",

Callers 1

buildFlowGraphFunction · 0.70

Calls 3

normalizeAbsToRelFunction · 0.70
basenameFunction · 0.70
dirOfFunction · 0.70

Tested by

no test coverage detected