Getting started

Your first branch

Write files to a disk, fork it, change the fork, and merge it back.

This walks through the basic loop: write files to a disk, fork it, change the fork, see what changed, and merge the change back.

import { Skywake } from "skywake";

const app = new Skywake().disk("app");

await app.write(
  { "README.md": "# Shop\n", "config.toml": "port = 8080\n" },
  { message: "first version" },
);

const work = await app.fork("agent-1");
await work.write("config.toml", "port = 9090\n", { message: "change the port" });

console.log(await work.diff("main"));

await work.mergeInto("main");
console.log(await app.read("config.toml"));

The CLI tab uploads a folder, ./project, that holds the same two files.

What each step does

StepWhat it does
write, or uploadThe first write creates the disk app and its main branch. Many files in one call are one commit.
fork("agent-1")Forks main into agent-1. No data is copied, however big the disk is.
write on the forkSaves a commit on agent-1. main doesn't change.
diff("main")Lists the paths that differ from main, each added, removed or modified.
mergeInto("main"), mergeMerges agent-1 into main, three-way. main now has port = 9090.

In the SDKs, fork returns a handle on the new branch. To get one for a branch that already exists, pass it as an option: sky.disk("app", { branch: "agent-1" }) in TypeScript, sky.disk("app", branch="agent-1") in Python. In the CLI, app@agent-1 names the branch, and no @ means main.

If both branches changed the same lines of a file, the merge saves nothing and lists the files in conflict. See diff and merge.

Look at history

Every write is a commit. skywake log app lists the commits of main, newest first, and --path config.toml keeps only those that changed that file. skywake branches app lists the branches. In the SDKs, these are app.log() and app.branches(). To read a file as it was, pass at with a commit id or a time.

Next