# 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.

[Read the search docs](https://sailfork.com/docs/search) [Ask a language server](https://sailfork.com/docs/caissons)

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 searched](https://sailfork.com/docs/search#search-code)

Query

retryDelivery

Split into 11 trigrams

- ret
- etr
- try
- ryD
- yDe
- Del
- eli
- liv
- ive
- ver
- ery

1. 1\. Index

   Files that hold every trigram

   9 files

2. 2\. Read

   Files where the text itself matches

   5 files

3. 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 search](https://sailfork.com/docs/search#search-symbols)

## The 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.

[Caissons](https://sailfork.com/docs/caissons)

lsp-rename retryDelivery redeliver

Dry run: 6 edits in 4 files

services/webhooks/src/deliver.ts

10 10

11 11 /\*\* Sends a failed delivery again with the next backoff. \*/

12 − export async function retryDelivery(id: string, attempt: number) {

12 + export async function redeliver(id: string, attempt: number) {

13 13 const delay = backoff(attempt);

services/webhooks/src/worker.ts

40 40 if (job.failed) {

41 − await retryDelivery(job.id, job.attempt + 1);

41 + await redeliver(job.id, job.attempt + 1);

42 42 }

## 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](https://sailfork.com/docs/caissons)

- 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

```
~/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.

## Questions

###

Only people who can read the repository. Search shows public repositories to anyone and private ones to people with read access, and a token needs the repo:read scope.

###

The sandbox scope and a Drydock host, because each one runs in a sandbox of yours. While it starts or indexes, the answer says so and you ask again.

###

No. lsp-rename and ast-rewrite are dry runs that print the diff until you pass --apply, and each is all or nothing.

###

Yes. The MCP server has search_code, search_symbols and symbol_refs, and inside a caisson caisson_lsp and caisson_ast_grep.
