Use the Termdock AST API to locate symbols, dependencies, callers/callees, or impact before exploring unknown code. Skip when the user gives an exact file path or only needs a literal string search.
Use AST API first when:
Skip AST API when:
Default rule: Use AST for discovery and impact; skip it for known-file edits.
If API is unavailable: Fall back to rg/rg --files and note the limitation.
curl -s 'http://localhost:3033/api/workspaces' | jq '.data.workspaces[0].id'
Save this ID for all subsequent calls.
| Goal | API | Example |
|---|---|---|
| Find symbol by name | /api/search |
"Where is UserService?" |
| See file imports/exports | /api/graph/deps |
"What does this file import?" |
| Find callers | /api/graph/callers |
"Who calls this function?" |
| Find callees | /api/graph/calls |
"What does this function call?" |
| Impact analysis | /api/impact |
"What breaks if I change this?" |
curl 'http://localhost:3033/api/search?q=<name>&workspace=<wsId>&limit=10'
Response fields:
symbolId: Use for callers/calls queriesfile: Absolute pathline: 0-indexed (add 1 for display)type: 5=Class, 6=Method, 11=Interface, 12=Functioncurl 'http://localhost:3033/api/graph/deps?file=src/path/to/file.ts&workspace=<wsId>'
Returns: imports (what this file uses) and exports (what it provides)
curl 'http://localhost:3033/api/graph/callers?to=<symbolId>&workspace=<wsId>'
curl 'http://localhost:3033/api/graph/calls?from=<symbolId>&workspace=<wsId>'
curl 'http://localhost:3033/api/impact?symbolId=<id>&depth=2&workspace=<wsId>'
Returns all symbols and files affected by changing this symbol.
User asks about code
|
v
Is it a "where is X?" question?
|yes |no
v v
/api/search Is it about dependencies?
| |yes |no
v v v
Got symbolId? /api/graph/deps Is it about call chain?
|yes |yes |no
v v v
Need callers? -----> /api/graph/callers Use other tools
Need callees? -----> /api/graph/calls
Need impact? -----> /api/impact
# 1. Find it
curl 'http://localhost:3033/api/search?q=TerminalService&workspace=ws_xxx&limit=1'
# Note: symbolId, file
# 2. See dependencies
curl 'http://localhost:3033/api/graph/deps?file=src/main/services/TerminalService.ts&workspace=ws_xxx'
# 3. Now read the file with context
# 1. Find function
curl 'http://localhost:3033/api/search?q=createSession&workspace=ws_xxx&limit=5'
# Pick the right symbolId
# 2. Find all callers
curl 'http://localhost:3033/api/graph/callers?to=<symbolId>&workspace=ws_xxx'
# Before changing a function, check impact
curl 'http://localhost:3033/api/impact?symbolId=<id>&depth=2&workspace=ws_xxx'
# Review impactedFiles before making changes
| Error | Cause | Action |
|---|---|---|
| No workspace found | API not running | Start Termdock app |
| Empty search results | Symbol not indexed | Try partial name or rebuild index |
| 404 on symbolId | Stale ID after code change | Re-search to get new ID |
Rebuild index after code changes:
curl -X POST 'http://localhost:3033/api/index/update' -H 'Content-Type: application/json' -d '{"workspace":"<wsId>"}'
All APIs return:
{
"success": true|false,
"data": {...},
"error": {"code": "...", "message": "..."}
}
Always check success before using data.
src/main/...)http://localhost:3033 (prod) or :3032 (dev)