| 20 | return last; |
| 21 | } |
| 22 | function classifyCall(name, args) { |
| 23 | const rawPath = args.path || args.file_path || args.target_file || args.notebook_path || ""; |
| 24 | const anchor = typeof args.anchor === "string" ? args.anchor : undefined; |
| 25 | if (rawPath) { |
| 26 | const m = rawPath.match(/\/(wiki|raw|my_thoughts|exports)\/(.+)$/); |
| 27 | const normPath = m ? `${m[1]}/${m[2]}` : rawPath; |
| 28 | return { |
| 29 | kind: "file", |
| 30 | key: anchor ? `${normPath}#${anchor}` : normPath, |
| 31 | title: normPath.split("/").pop().replace(/\.md$/, ""), |
| 32 | subtitle: normPath.split("/").slice(0, -1).join("/"), |
| 33 | path: normPath, |
| 34 | anchor, |
| 35 | }; |
| 36 | } |
| 37 | if (name === "search" || name === "Grep" || name === "Glob") { |
| 38 | const q = args.query || args.pattern || ""; |
| 39 | return { kind: "search", key: `search:${name}:${q}`, title: `🔍 ${q.slice(0, 32)}`, subtitle: name }; |
| 40 | } |
| 41 | if (name.startsWith("list_")) { |
| 42 | return { kind: "list", key: `list:${name}`, title: name, subtitle: "list" }; |
| 43 | } |
| 44 | return { kind: "other", key: `other:${name}:${JSON.stringify(args).slice(0, 64)}`, title: name, subtitle: "tool" }; |
| 45 | } |
| 46 | |
| 47 | const path = process.argv[2] || "/tmp/sse-out.txt"; |
| 48 | const raw = fs.readFileSync(path, "utf8"); |