Search a symbol, list its references, rename it everywhere.
Trigram search across every repository you can read, then a language server in a caisson to change what you found.
retryDelivery
5 files in 2 repositories
acme/shop
services/webhooks/src/deliver.ts
- 12 export async function retryDelivery(id: string, attempt: number) {
services/webhooks/src/worker.ts
- 3 import { retryDelivery } from './deliver';
- 38 // retryDelivery backs off, so do not loop here
- 41 await retryDelivery(job.id, job.attempt + 1);
apps/admin/src/routes/events.ts
- 27 await retryDelivery(event.deliveryId, 1);
services/webhooks/src/deliver.test.ts
- 2 import { retryDelivery } from './deliver';
- 9 await retryDelivery('d_1', 2);
acme/ops
scripts/replay.ts
- 8 await retryDelivery(id, 1);
A search reads only the files that could match.
The index keeps every three-letter run of each file, so a query narrows to a handful of files before any text is read.
What is searchedQuery
retryDelivery
Split into 11 trigrams
- ret
- etr
- try
- ryD
- yDe
- Del
- eli
- liv
- ive
- ver
- ery
1. Index
Files that hold every trigram
9 files
2. Read
Files where the text itself matches
5 files
3. Check access
Repositories you can read
acme/shop, acme/ops
retryDelivery
function in acme/shop
| definition | services/webhooks/src/deliver.ts:12 |
| import | services/webhooks/src/worker.ts:3 |
| call | services/webhooks/src/worker.ts:41 |
| call | apps/admin/src/routes/events.ts:27 |
| import | services/webhooks/src/deliver.test.ts:2 |
| call | services/webhooks/src/deliver.test.ts:9 |
comment, not a useservices/webhooks/src/worker.ts:38
References are the lines that use the symbol, not the lines that mention it.
The definition first, then each import and call. A comment or a string that happens to hold the name is not a use.
Symbol searchThe language server renames it everywhere or not at all.
A caisson is a private workspace for one change on a repository. Its language server also sees your uncommitted edits, and a rename is a dry run until you pass --apply.
lsp-rename retryDelivery redeliver
Dry run: 6 edits in 4 files
ast-grep changes call shapes by syntax.
A pattern matches syntax nodes, so comments and strings never match. The rewrite previews as a diff and lands all or nothing.
ast-grep commands- Pattern, typescript
- redeliver($ID, $N)
- Rewrite
- redeliver({ id: $ID, attempt: $N })
services/webhooks/src/worker.ts:41
redeliver(job.id, job.attempt + 1)
apps/admin/src/routes/events.ts:27
redeliver(event.deliveryId, 1)
services/webhooks/src/deliver.test.ts:9
redeliver('d_1', 2)
3 matches in 3 files. The comment on worker.ts line 38 names the function but is not a call, so it is left alone.
From the first search to a renamed symbol
The language server is still starting on the first question, so the second one is the one that answers.
~/acme/shop $ sailfork search code retryDelivery --all-repos
acme/shop services/webhooks/src/deliver.ts
12: export async function retryDelivery(id: string, attempt: number) {
acme/shop services/webhooks/src/worker.ts
3: import { retryDelivery } from './deliver';
38: // retryDelivery backs off, so do not loop here
41: await retryDelivery(job.id, job.attempt + 1);
5 files in 2 repositories
~/acme/shop $ sailfork search symbols retryDelivery
function retryDelivery services/webhooks/src/deliver.ts:12
~/acme/shop $ sailfork caisson lsp c-k3m9x2 references services/webhooks/src/deliver.ts:12:23
typescript language server is starting: ask again in a few seconds
~/acme/shop $ sailfork caisson lsp c-k3m9x2 references services/webhooks/src/deliver.ts:12:23
services/webhooks/src/deliver.ts:12:23
services/webhooks/src/worker.ts:3:10
services/webhooks/src/worker.ts:41:15
apps/admin/src/routes/events.ts:27:8
services/webhooks/src/deliver.test.ts:2:10
services/webhooks/src/deliver.test.ts:9:8
~/acme/shop $ sailfork caisson lsp-rename c-k3m9x2 services/webhooks/src/deliver.ts:12:23 redeliver
Dry run: renames retryDelivery to redeliver with 6 edits in 4 files. Pass --apply to write them.
~/acme/shop $ sailfork caisson lsp-rename c-k3m9x2 services/webhooks/src/deliver.ts:12:23 redeliver --apply
Renamed retryDelivery to redeliver: 6 edits in 4 files
~/acme/shop $ sailfork caisson lsp c-k3m9x2 diagnostics services/webhooks/src/worker.ts
No errors in services/webhooks/src/worker.ts
~/acme/shop $ What it covers
- Every branch of a repository is indexed, up to 256 branchs by default, the default branch first.
- A search that runs past 2 seconds fails and says so, so narrow it with a path, a language or one repository.
- Files over 1 MiB, binaries, vendored and build directories, lockfiles, minified files and type declaration files are not indexed.
- Rust, TypeScript, JavaScript, Python, Go are parsed for symbols. Other languages use line patterns, so results are looser.
- Language servers exist for Rust, TypeScript and JavaScript, Python, Go. One starts with your first question and ends 30 minutes after the last.
- ast-grep reads rust, typescript, tsx, javascript, python, go.