Search
Turn on a disk's search switch, then query its files by meaning and keywords, on every branch.
Search is a switch on a disk. Turn it on and call query on the disk. There is nothing else to make or sync.
import { Skywake } from "skywake";
const sky = new Skywake();
const app = await sky.createDisk("app", { search: true });
await app.write({
"docs/retries.md": "Retry failed requests with exponential backoff.",
"docs/auth.md": "Sign requests with your API key.",
});
let hits = await app.query("retry backoff", { limit: 1 });
for (let i = 0; i < 50 && hits.length === 0; i++) {
await new Promise((done) => setTimeout(done, 200));
hits = await app.query("retry backoff", { limit: 1 });
}
console.log(hits);Each hit is { path, score, snippet }, best first, one per file. query takes limit (10 by default) and path to search one folder, and searches the handle's branch. Agents get the same search as the query tool of the MCP server.
Turn it on or off
search is on by default when the environment has an embedding model, so a disk made by its first write is usually searchable already. Set it yourself when you make the disk, or change it later:
| Do | TypeScript | Python | CLI or HTTP |
|---|---|---|---|
| On when making it | sky.createDisk("app", { search: true }) | sky.create_disk("app", search=True) | skywake create disk app --search |
| Change it | app.configure({ search: false }) | app.configure(search=False) | PATCH /v2/disks/app {"search": …} |
| See it | (await app.info()).search | app.info()["search"] | GET /v2/disks/app |
With search off, query fails with Conflict and a hint to turn it on. grep and find work either way. Turning search off deletes the disk's search data.
Branches
Every branch of the disk has its own search. A fork is searchable at once, and what an agent writes on its branch is found only there. After a merge, main catches up on its own.
import { Skywake, type Disk } from "skywake";
async function found(disk: Disk, text: string, path: string) {
for (let i = 0; i < 50; i++) {
const hits = await disk.query(text, { limit: 1 });
if (hits[0]?.path === path) return true;
await new Promise((done) => setTimeout(done, 200));
}
return false;
}
const app = new Skywake().disk("app");
await app.write("docs/auth.md", "Sign requests with your API key.");
console.log("main finds auth.md:", await found(app, "api key", "docs/auth.md"));
const work = await app.fork("agent-1");
await work.write("docs/retries.md", "Retry failed requests with exponential backoff.");
console.log("agent-1 finds retries.md:", await found(work, "retry backoff", "docs/retries.md"));
const onMain = await app.find("**/retries.md");
console.log("main has retries.md:", onMain.length > 0);What gets searched, and when
- Text files, PDFs, and Word, PowerPoint and Excel files (
.docx,.pptx,.xlsx), up to 16 MiB of text each. Long files are split into passages, and a file is returned once, at its best passage. - Binary files, old
.doc,.pptand.xlsfiles, and PDFs without a text layer are skipped. - A commit is searchable within seconds, not at once, so poll briefly in scripts as the examples do. Saves from a mount are batched for about 30 seconds.
- Only what changed is processed again, and an edit embeds only the passages it changed. Embeddings are billed as usual.
There is no setting for which paths are searched and no sync status yet: every file the rules above accept is searched.