# Set up Rift

This file is for an agent that has been asked to install Rift and join a filesystem. Follow it in order. Stop where it says to stop.

## What you are doing

You will install the `rift` command, join the filesystem of the person you work for with an invite token, and confirm that this machine is in sync. The person only has to give you the token.

## 1. Check for an existing install

```
rift status
```

Read the first line of the output.

- It says `joined as <name>`: this machine already joined with an invite. Do not run `rift init` and do not use a token. If you were given a token, tell the person it was not used and which name this machine joined as. Go to step 5.
- It shows a key that starts `ed25519:` and no `joined as`: the machine's owner set it up, and you are working with their key.
  - No token: go to step 5. Say in your report that Rift was already set up and which folder it printed.
  - A token and a directory from the person: run `rift init --invite <token> --home <dir>`, add `--home <dir>` to every `rift` command, and go to step 5.
  - A token and no directory: stop. Tell the person that this machine already uses their key, that you can see every folder in `~/rift`, and that the token is unused. If they give you a directory, do as in the line above. If they tell you to keep working with their key, do not use the token, and go to step 5.
- The command is not found: run `~/.local/bin/rift status`. If it prints a first line, read it by this list and call the binary by its full path from here on. If that is not found either, go to step 2.
- It is found and prints no folder: go to step 3.

## 2. Install

```
curl -fsSL https://rift.sh/install | sh
```

It installs one binary to `~/.local/bin`. If that directory is not on your `PATH`, call the binary by its full path for the rest of this file.

## 3. Get the invite token

If the person already gave you a token, or the environment variable `RIFT_INVITE` is set, go to step 4.

If not, stop and show them this text, then wait:

```
To add me to your Rift filesystem, run this on your own machine and send me the token it prints:

rift invite <a name for me>
```

Do not invent a token and do not look for one on disk. Treat the token as a secret. Do not repeat it in your report or write it to a file.

## 4. Join

```
rift init --invite <token>
```

It prints that a key was created, then the public key, the name you joined as and Rift's folder.

## 5. Verify

```
rift status
```

Setup has passed when it prints Rift's folder:

```
✓ joined as <your name> · in sync
  folder at ~/rift
```

On a machine its owner set up, the first line shows the key in place of `joined as`. That also passes.

If it does neither, report the message as it is and stop.

## 6. Install the skill

Ask the person whether to install the Rift skill, which tells you the commands next time. If they agree, and you support Agent Skills and have `npx`, run:

```
npx -y skills add https://rift.sh -g -y
```

Otherwise, or if nobody is there to answer, do not install it. Read https://rift.sh/skill.md once and say so in your report.

## 7. Report

Tell the person, in a few lines:

- the name you joined as, or that the machine was already set up
- Rift's folder, as `rift status` printed it
- which folders `rift ls` lists, since those are where you will work. If it shows none, say so and ask which folder to write to
- whether you installed the Rift skill
- anything that failed, with the exact message

From now on keep your work inside a folder that `rift ls` lists. A folder it lists as `work/` is at `~/rift/work`. If you joined with `--home <dir>`, use the folder that `rift status --home <dir>` prints in place of `~/rift`. If you need a folder you cannot see, run `rift request <path> --reason "<why>"`. When the person approves, the folder appears in `rift ls`.

After you ask, tell the person you asked, carry on with work that does not need the folder, and check `rift ls` again before you use it. If nothing is left that you can do without it, stop and tell the person what you asked for. Do not look for another way to reach it.
