# Triple

**A modern way to safely backup and store codebases.**

```text
{ Production Code + Infinite Drafts + Structured Data }
```

Humans: [triple.host](https://triple.host) · how it works: [WORLD.md](./WORLD.md)  
Agents: this file (`https://triple.host/AgentWelcome.md`, also `/` via [ECP](https://endpointcontextprotocol.io))

CLI: `npm install -g @triplehost/cli`

---

## Paste this to your agent

```text
Use Triple (@triplehost/cli). Authority: https://triple.host/AgentWelcome.md
How it works (human): WORLD.md

Install: npm install -g @triplehost/cli

Auth (pick one):
- Human default: triple login
- Agent/browser: triple login --browser   (opens triple.host/login; human finishes; CLI waits)
- Agent knows email: triple login --email you@x.com   (sends code; human pastes code into Terminal)
Credentials: ~/.config/triple/credentials.json   (or TRIPLE_TOKEN)

Laws:
- Production = folder with .triple/ sidecar. Drafts = sibling folders …-draft-a… (ids draft-a, draft-b, …).
- Draft commands take draft-a (not bare a). Run them from Production, never inside a draft.
- triple new only in Production (never inside a draft folder).
- Work in drafts. makeprod promotes a draft to Production. Previous Production is stored for local undo.
- Other open drafts keep their edits and stay lined up with the new Production.
- Structured = drop files in .triple/structured/. triple reconcile / triple watch keep the index fresh.
- Every action adds, undoes, or refuses. No silent destroy.
- Clone = get current vault release onto this machine. Empty path ok. Occupied path only with --replace-local after human approval. Agents must not invent --replace-local.
- Local undo ≠ vault. undo = this machine only. rollback = vault current release only (does not change local files).
- Backup publishes a new current release. Last 10 kept. If vault is newer, backup refuses — stop. Prefer leave alone, or human runs releases/rollback, or clone --replace-local after approval. Do not invent --replace-vault unless the human said so.
- Vault clock only. Vault is private.

Receipts: last line triple: ok|refused|error <op> key=value …
Exit: 0=ok  2=refused  1=error
On refused: stop.

Commands: login, logout, whoami, new, draft, drafts, rename, discard, makeprod, undo,
reconcile, watch, backup, releases, rollback [at], list, clone, status, agent
```

---

## This machine vs vault

| | This machine | Vault |
| --- | --- | --- |
| What | Your folders | Cloud backup on triple.host |
| Go back | `triple undo` | `triple rollback` |
| Touches the other? | Never | Never |

Backup → new **current** release (last **10** kept). Rollback changes current in the vault only.

---

## Auth

| Who | Command |
| --- | --- |
| Human in Terminal | `triple login` |
| Agent (open browser for human) | `triple login --browser` |
| Agent (has email; human pastes code) | `triple login --email you@example.com` |

Bare browser `/login` without `?cli=` does not authorize Terminal.

---

## Commands

### Get started

| Command | Meaning |
| --- | --- |
| `npm install -g @triplehost/cli` | Install |
| `triple login` | Sign in with email. One-time code. |
| `triple new` | In your project folder. Creates a `.triple` sidecar. That folder is Production. |

### Drafts

| Command | Meaning |
| --- | --- |
| `triple draft` | Next draft beside Production (letter automatic) |
| `triple makeprod draft-a` | Draft becomes Production. Previous Production stored for undo. |
| `triple undo` | Undo last local step |
| `triple drafts` / `rename` / `discard` | List / rename / delete drafts only |

### Structured + local sync

| Command | Meaning |
| --- | --- |
| `triple reconcile` | Refresh structured index; keep drafts lined up with local Production |
| `triple watch` | Do that when folders change |

### Remote vault

| Command | Meaning |
| --- | --- |
| `triple backup` | Save to vault (new current release; last 10 kept) |
| `triple releases` | List release history |
| `triple rollback` | Previous release becomes current (vault only) |
| `triple rollback <at>` | That release becomes current (vault only) |
| `triple clone <id> [dir]` | Current release into an **empty** path |
| `triple clone <id> [dir] --replace-local` | Replace folder with current release (**human approval**) |
| `triple list` | Vault projects |

Agents must not invent `--replace-local` or `--replace-vault`.

---

## Safety baked in

**Clone into a full folder** → refused unless `--replace-local` after human approval.

**Vault newer than this folder** → backup refused. Leave alone, roll vault (`releases` / `rollback`), or clone with `--replace-local` after approval. `--replace-vault` only if the human said so.

**Not a Triple** → backup refused. Run `triple new` first.

**`triple new` inside a draft folder** → refused.

**Discard Production** → never.

---

## Receipts

```text
triple: <ok|refused|error> <op> [code=…] [key=value …]
```

Exit `0` / `2` / `1`. Parse the receipt line. Ignore prose for control flow. `help` and `agent` are silent (no receipt).

---

## Custody API

```http
PUT  /triples/:id
GET  /triples/:id
GET  /triples/:id/releases
POST /triples/:id/rollback
GET  /library
```

Bearer session required. Prefer the CLI.

---

## ECP

Same URL `https://triple.host/`: HTML for browsers, this markdown for agents.  
Manifest: `/ecp.json` · Canonical agent doc: `/AgentWelcome.md`
