npm run eval Β· method β EVAL.md
---
## β‘ The five commands
| You want | Run | Saves |
|---|---|:---:|
| "Do we already have this?" | `agentmap --find formatCurrency` | 99.9% |
| "What breaks if I touch this?" | `agentmap --relates lib/auth.ts` | 99.2% |
| "Where is this defined?" | `agentmap --find ChatMessage` | 99% |
| "Give me the repo, cheap" | `agentmap --map --tokens 2000` | 99.3% |
| Don't want to pick? | `agentmap --any ` β the router (file β symbol β feature β live content) See [The `--any` router](#the---any-router) above. Default first move for any "where/what/who" question. ### `--find` β reuse-before-rebuild symbol search Find every symbol whose name contains the query β exported symbols **plus** non-exported top-level declarations. Use it before writing a new util or component to check what already exists (a private helper counts as reusable too). ``` $ node agentmap.mjs --find Message find "Message": 55 match hooks/use-messages.tsx β useMessages (FunctionDeclaration) lib/errors.ts β getMessageByErrorCode (FunctionDeclaration) lib/types.ts β messageMetadataSchema (VariableDeclaration) lib/types.ts β MessageMetadata (TypeAliasDeclaration) lib/types.ts β ChatMessage (TypeAliasDeclaration) lib/utils.ts β convertToUIMessages (FunctionDeclaration) lib/utils.ts β getTextFromMessage (FunctionDeclaration) tests/helpers.ts β generateTestMessage (FunctionDeclaration) app/(chat)/actions.ts β generateTitleFromUserMessage (FunctionDeclaration) β¦ ``` **Barrels don't hide the real file.** When a match is reached through a re-export (`export * from "./x"`, or a named/renamed re-export, at any depth), the output names the file that actually declares it. The TypeScript checker resolves the chain, so this works where a name search can't β `rg` sees the barrel and the origin as two equal hits with no way to tell which one you can edit. An origin outside the repo reports `β defined outside the repo`; a `node_modules` path is never printed. ``` $ node agentmap.mjs --find useComposedRefs # radix-ui/primitives@579c5b84 find "useComposedRefs": 3 match packages/react/compose-refs/src/index.ts β useComposedRefs (FunctionDeclaration) β defined in packages/react/compose-refs/src/compose-refs.tsx packages/react/compose-refs/src/compose-refs.tsx β useComposedRefs (FunctionDeclaration) packages/react/radix-ui/src/internal.ts β useComposedRefs (?) ``` In `--json` this is `definedIn: ""` or `external: true` on the match, present only when the entry is a pass-through β a real definition carries neither. ### `--search ` β BM25 lexical search for vague queries When you don't know the exact symbol name β the query an agent actually types β `--search` ranks symbols by **BM25 lexical relevance** over split-identifier tokens (the symbol name, its file's path segments, feature, and kind), fused with file PageRank so a strong hit in an important file wins ties. No embeddings, no vector DB; the index is built into `map.json`. The same ranker is wired into `--any` as a rung that fires **only** when exact file/symbol matching found nothing, so exact routing is unchanged. ``` $ node agentmap.mjs --search "auth retry logic" search "auth retry logic": 3 match src/authRetry.ts β retryWithBackoff (FunctionDeclaration) [6.83] β¦ ``` Stopwords (`the`, `that`, `of`, β¦) are dropped, so `--search "the function that dedupes symbols"` works. Also available as the `search` MCP tool. ### `--relates` β blast radius + transitive relevance The file's own block (exports / imports / direct dependents) **plus** a random-walk relevance list (personalized PageRank on the bidirectional import graph) β the files most related to the target, transitively, not just its direct importers. ``` $ node agentmap.mjs --relates lib/db/schema.ts relates: lib/db/schema.ts (pr 0.073744) exports (14): user(VariableDeclaration), User(TypeAliasDeclaration), chat(VariableDeclaration), Chat(TypeAliasDeclaration), message(VariableDeclaration), DBMessage(TypeAliasDeclaration), β¦ imports (0): β dependents (21): hooks/use-active-chat.tsx, lib/types.ts, lib/utils.ts, components/chat/artifact.tsx, components/chat/message.tsx, lib/db/queries.ts, app/(chat)/api/chat/route.ts, β¦ related (random-walk relevance): lib/utils.ts (0.0476) lib/types.ts (0.0376) components/chat/artifact.tsx (0.0372) components/chat/icons.tsx (0.0264) components/chat/message.tsx (0.0237) lib/db/queries.ts (0.0225) app/(chat)/api/chat/route.ts (0.0218) β¦ ``` **Type-only dependencies are listed separately, not silently dropped.** `dependents` means "would break at runtime". A file imported only via `import type` has no runtime dependents at all β but renaming or deleting its exports still breaks every consumer at compile time. Those appear under `type-only dependents`, so a types module stops reading like an orphan: ``` $ node agentmap.mjs --relates lib/types.ts # vercel/chatbot@c2f8235e relates: lib/types.ts (pr 0.002898) exports (7): messageMetadataSchema(VariableDeclaration), MessageMetadata(TypeAliasDeclaration), β¦ imports (0): β dependents (0): β type-only imports (6): components/chat/artifact.tsx, lib/ai/tools/create-document.ts, β¦ type-only dependents (23): hooks/use-active-chat.tsx, hooks/use-auto-resume.ts, lib/utils.ts, β¦ ``` 22.4% of that repo's import statements are type-only. The fields are `typeOnlyImports` / `typeOnlyDependents` in `--json`, omitted entirely when empty, and they never enter PageRank, `--hubs`, symbol ranking or `--export` β the ranking graph stays a runtime graph. For a file carrying a React Server Components directive prologue, the output adds one more line β `boundary: 'use client' (client component)` or `boundary: 'use server' (server module/actions)` (`rsc: 'client' | 'server'` in `--json`) β right after `dependents`. This is additive and optional: repos with no `'use client'`/`'use server'` directives never see the line. ### `--callers ` β compiler-accurate call graph (experimental) Who actually **calls** a symbol, resolved by the TypeScript language service (`ts-morph` `findReferencesAsNodes`) β not tree-sitter name-matching. This is symbol-level blast radius: a type-position mention (`typeof foo`), a re-export, a bare value reference (`const x = foo`), or a same-named private local in another file is a *different* symbol and is never mis-attributed. `--in ` disambiguates a name defined in more than one file (exported definitions win over same-named private locals); results are ranked by caller-file PageRank and capped. ``` $ node agentmap.mjs --callers getMessageByErrorCode callers of getMessageByErrorCode [lib/errors.ts]: 3 call sites app/(chat)/api/chat/route.ts:88 β POST lib/db/queries.ts:142 β saveMessage components/chat/message.tsx:57 β PureMessage ``` **JSX counts as a call site.** ` ` compiles to `React.createElement(Foo, β¦)` (classic runtime) or `jsx(Foo, β¦)` (automatic runtime) β either way it's an invocation, so a component's callers include everywhere it's rendered, not just plain `foo()` calls. ` ` resolves to `Bar`, not the `Foo` namespace; ` ... ` counts once (the closing tag isn't a second call site); an intrinsic tag (``) resolves to nothing in-project and produces no edge. ``` $ node agentmap.mjs --callers Button callers of Button [components/ui/button.tsx]: 25 call sites components/ai-elements/message.tsx:93 β MessageAction components/ai-elements/message.tsx:263 β MessageBranchPrevious components/ui/sidebar.tsx:249 β SidebarTrigger components/ui/alert-dialog.tsx:158 β AlertDialogAction components/ui/dialog.tsx:72 β DialogContent β¦ ``` Before 0.17.0, JSX wasn't a recognized call shape at all, so that same query returned **0 call sites** β a plain `rg '