# Set up Slashcode on this computer (always current at https://slashcode.dev/install.md)

You are a coding agent with a shell on the user's Mac or Linux machine. Follow these steps in order to install Slashcode, the daemon that runs coding agents on this machine so the user can drive them from the Slashcode app on their iPhone, iPad or browser. Run each command, read its output, and stop to tell the user when a step fails.

## Rules

- Do not use `sudo`. Nothing here needs it: everything installs under the user's home folder.
- Do not edit shell profiles (`~/.zshrc`, `~/.bashrc`, ...) without telling the user what you will add and getting a yes.
- Do not invent flags or subcommands. If you need one that is not listed here, read `slashcode --help` or `slashcode <command> --help` first.
- Do not try to pair by yourself. Pairing needs the user, in the Slashcode app (step 5).
- Do not run the installer or `slashcode service install` a second time without saying so: both restart the daemon, which stops the sessions it is running.

## 1. Install

```sh
curl -fsSL https://slashcode.dev/install | sh
```

The installer needs `curl`. It downloads the binary for this system (macOS or Linux, arm64 or x86_64), puts it at `~/.local/bin/slashcode` and prints:

```
Downloading <url>
Installed <path>/slashcode (slashcode <version>)
```

On macOS it then runs `slashcode service install`, which writes the LaunchAgent `~/Library/LaunchAgents/dev.slashcode.daemon.plist`, starts the daemon now and at every login, and prints:

```
The daemon runs now and starts at login (relay <url>).
Logs: <home>/.slashcode/logs/daemon.log
Next: `slashcode pair` to add your phone.
```

On Linux it prints `Start it with: slashcode daemon` instead and installs no service (see step 3).

If it fails, it says why on a line starting with `slashcode install:` (`curl is needed`, `unsupported system`, `unsupported processor`, `download failed`, `the archive is damaged`, `no slashcode binary in`). If `slashcode service install` fails, its own message comes last, without that prefix. Report the failing line to the user and stop.

## 2. Put it on the PATH

If the installer printed a line starting with `Add ... to your PATH`, then `~/.local/bin` is not on the PATH. Do not edit a shell profile on your own: show the user the line the installer suggested and ask before adding it. Until then, call the binary by its full path, `~/.local/bin/slashcode`, in every command below.

## 3. Check that it runs

```sh
slashcode --version
slashcode service status
```

`service status` prints one of:

- `Running (pid <n>).` The daemon is up. Go on.
- `Not installed. Run \`slashcode service install\`.` Run `slashcode service install`, then check again.
- `Installed but not loaded: run \`slashcode service install\` again (<plist>)` Do as it says, then check again.
- `Loaded but not running; see <log>` Read the end of that log file and report what it says to the user.

On Linux there is no service: `slashcode service` is macOS only. Tell the user to keep `slashcode daemon` running in a terminal of their own.

## 4. See which agents it found

```sh
slashcode agents
```

One line per agent: its id, its name, its command, then `available` or `not installed`, and `accepts edits` or `accepts all` when the user let that agent act without asking. Slashcode starts the agents already installed on this machine and signed in with the user's own accounts; it installs none. Tell the user which ones are `available`. If none is, say so and ask which agent they want to install; do not pick one for them.

The daemon looks for agents on the PATH of the shell that ran `slashcode service install`. If the user installs an agent somewhere new afterwards and it still shows `not installed`, tell them that running `slashcode service install` again from a shell that finds it will fix it, and that this restarts the daemon.

To add an agent that is not in the list, it must speak the Agent Client Protocol (ACP) on its stdin and stdout. Give it an id (1 to 32 lowercase letters, digits, `-` or `_`), a name, and its command after `--`:

```sh
slashcode agent add my-agent --name "My Agent" -- my-agent --acp
```

It prints `Added my-agent: my-agent --acp`, and a `Note:` line if the command is not on the PATH yet. The running daemon picks it up at once. `slashcode agent remove <id>` removes one you added.

## 5. Pair the user's device: stop here and hand over

```sh
slashcode pair
```

It prints a QR code, then:

```
Scan this with your phone's camera, or type the code in the Slashcode app:

    XXXX-XXXX

It expires in 15 minutes and works once. Waiting…
```

and keeps waiting until a device pairs. Only the user can finish this step:

- Show the user the 8-character code exactly as printed and tell them to type it in the Slashcode app (on their iPhone or iPad, or signed in at https://slashcode.dev/app in a browser), within 15 minutes.
- A QR code rarely survives being relayed by an agent. If the user would rather scan, ask them to run `slashcode pair` in their own terminal.
- Do not type the code anywhere yourself, and do not open pairing links.

When the device joins, the command prints `Paired <name> (<kind>)` and exits. If it prints `Code expired` or `Code burned after 5 failed attempts`, run `slashcode pair` again for a new code. If it prints `the daemon is not running`, go back to step 3.

## 6. Report

Tell the user, briefly: the version installed and where, whether the daemon is running, which agents are available, and whether a device was paired. `slashcode devices` lists the paired devices. If one shows `waiting for approval`, tell the user; run `slashcode devices approve <id>` only once they confirm that device is theirs.
