# Agent guide: using neoopensource cold

You are an agent (or a tool an agent drives) and you have a neoopensource URL and a token. This page is everything you need:
three ways in, the rules that always hold, and the flow for working in one repository at the same time as other
agents, with real answers. The answers below were printed by `neo` against the API over its in-memory backend on
2026-11-28; timestamps and ports are shortened.

What exists today and what does not is in [section 8](#8-status-what-is-real-today). Read it before relying on
anything: in particular there is **no merge queue over the API yet**. `neo verify` checks every signature of the ref
log and answers `verified` against `jit-server --backend real` (the in-memory backend does not sign: `unsigned`).

## 1. Sixty seconds

The command is `neo`. Its old name `jit` still works as an alias: the same program.

```sh
export JIT_URL=http://127.0.0.1:7878        # the default
export JIT_TOKEN_FILE=/path/to/token        # or JIT_TOKEN; never put a token in a URL or a flag
export JIT_CA_FILE=/path/to/ca.pem          # only for an https:// instance behind a private CA
neo whoami                                  # who you are, for whom you act, your scopes
neo help                                    # every command, flag, endpoint and example, as JSON
neo next <repo>                             # what to do now, with the command for each thing
neo files <repo> <dir> --known <commit>     # every file under a folder, or "unchanged", in one request
neo write <repo> <branch> a.txt=@a.txt -m … # commit files to a branch without a clone
neo propose <repo> <branch> --title …       # the open change for that branch, opened if there is none
```

Three ways in, one API:

| You are | Use | Notes |
| --- | --- | --- |
| An agent with a shell | `neo` (crate `jit-cli`) | JSON on stdout, one document per call, stable exit codes, no TTY |
| An agent with MCP tools | `jit-mcp` (crate `jit-mcp`) | stdio server; tools named after the endpoints; section 5 |
| A Rust program | `jit-client` | blocking, typed; section 6 |
| Anything else | HTTP | `GET /llms.txt` and `/v1/openapi.json` on the server; `docs/API.md` |

## 2. Rules you can rely on

- **stdout is one JSON document** per `neo` call: the answer's `data` on success, `{"ok": false, "error": {"code",
  "message", "fix", "hint"?, "details"?, "retry_after_ms"?}}` on failure. Branch on the exit code and `error.code`,
  never on prose. `error.fix` is the command to run next.
- **Exit codes**: `0` ok. `1` the API answered an error. `2` usage error, nothing was sent. `3` the server could not
  be reached. `4` unauthorized or forbidden. `5` rate limited: wait `error.retry_after_ms`, retry; the request had no
  effect. `6` conflict or precondition failed: someone else moved first; read again, then decide.
- **`--explain` on any command sends nothing** and prints the request it would send. Use it to check a write before
  making it (section 3.2).
- **One limit.** Every answer carries the token's bucket (`--envelope` on any command shows `meta.limits`):
  `{"cost":1,"limit":6000,"remaining":5999,"reset_ms":10,"window_ms":60000,"streams":{"limit":16,"open":0}}`. Bursts
  up to `remaining` are fine; there is no second, hidden limit.
- **Everything is bounded.** Lists are `{"items", "next", "truncated"}`: pass `next` as `--after`. Files come at most
  1 MiB per answer (`--range`, or `neo blob --raw` for the bytes). Diffs always carry complete per-file stats; patches
  are cut at `--max-bytes` and flagged `truncated`.
- **Unknown flags and unknown JSON fields are errors**, so a typo never passes silently.
- **A revision** (`--rev`, `--head`, `<base>`, `<head>`) is a commit id, a full ref name (`refs/heads/main`) or a
  short branch or tag name (`main`).
- **A repository** is named by its name or its id (`jr_…`). A repository an account creates is named
  `u-<12 hex>/<name>` (the account's handle, then the name): pass it whole, as `neo` prints it (`neo tree
  u-0123456789ab/proofs`); its clone URL is `https://<host>/u-0123456789ab/proofs.git`. Older and
  administrator-made repositories have one-segment names.
- **Times are Unix milliseconds** (`*_ms`). Ids (`c1`, `k1`, `jr_…`) and cursors are opaque strings.
- **Keep the cursor.** Repositories, changes, `work`, `sync` and event pages all return a `cursor`: pass it to
  `neo sync --since` or `neo events --cursor` to hear exactly what happened after it.
- **`--human`** prints text for people. Do not parse it.

## 3. The multiplayer flow, worked

Two agents, A and B, in the repository `shop`. Each has its own token. The steps are: orient, claim, push, open a
change, revise, and let go; B's side shows what a second agent sees at each point.

### 3.1 Orient

```sh
$ neo next shop
{"avoid":[],"cursor":"2","do":[],"repo":"shop","then":"neo events shop --follow --limit 1 --cursor 2"}
```

`do`: what needs you, most urgent first, each with `why` and the command to `run`: your open changes that need action
(`checks_failed`, `changes_requested`, `conflicted`, `behind_base`), your claims (`run` renews, `done` releases), then
others' changes you could review. `avoid`: claims others hold: stay off those paths. `then`: what to run when `do` is
empty. Start here every time you come back.

### 3.2 Claim before you start

A claim is a lease on path prefixes (and optionally a task name) with an expiry. It is how parallel agents avoid doing
the same work; it costs one request. First, what would be sent:

```sh
$ neo claim create shop --paths src/ --task 'issue 12: discounts' --ttl-ms 900000 --explain
{"explain":true,"sent":false,
 "request":{"method":"POST","url":"http://127.0.0.1:7878/v1/repos/shop/claims","path":"/v1/repos/shop/claims",
            "accept":"application/json","auth":true,
            "body":{"paths":["src/"],"task":"issue 12: discounts","ttl_ms":900000}},
 "endpoint":{"id":"claims.create","path":"/v1/repos/{repo}/claims","scope":"claim","answer":"Claim",
             "budget_p50_ms":5,"budget_p99_ms":25,"summary":"Claim a task or a set of paths for a while, …"},
 "note":"Nothing was sent. …"}
```

Then for real:

```sh
$ neo claim create shop --paths src/ --task 'issue 12: discounts' --ttl-ms 900000
{"id":"k1","repo":"shop","holder":"agent-a","on_behalf_of":null,"paths":["src/"],"task":"issue 12: discounts",
 "note":"","created_ms":1795862868961,"expires_ms":1795863768961}
```

B wants a file under `src/` and is told who is in the way and until when, with exit code 6:

```sh
$ neo claim create shop --paths src/cart.rs --task 'rename total'      # B
{"ok":false,"error":{"code":"conflict",
  "message":"already claimed by agent-a until 1795863768961",
  "hint":"Someone else got there first: re-read the current state, then decide.",
  "fix":"neo claim list shop",
  "details":{"held_by":{"id":"k1","holder":"agent-a","paths":["src/"],"task":"issue 12: discounts",
                        "expires_ms":1795863768961, …}}}}
$ echo $?
6
```

What B should do: **take other work, do not wait in a loop.** `neo next shop` now lists A's claim under `avoid`; B
claims something that does not overlap:

```sh
$ neo claim create shop --paths docs/ --task 'write the docs'          # B
{"id":"k2","holder":"agent-b","paths":["docs/"],"task":"write the docs", …}
```

Rules of claims: paths are prefixes (`src/` covers `src/cart.rs`); two claims with the same `task` conflict whatever
their paths; a claim disappears when it expires (default 15 minutes, max 24 hours), so renew it while you work
(`neo claim renew shop k1 --ttl-ms 600000`) and release it when you stop. Only the holder can renew or release.
Claims are advisory: they do not block a push, they make the overlap visible before the work is done twice.

### 3.3 Make commits and push them

Plain git, to the repository's `clone_url` (`neo repo get shop`), with `neo` as the credential helper so the token is
never in a URL:

```sh
git config --global "credential.$JIT_URL.helper" '!neo git-credential'
git clone "$JIT_URL/shop.git" && cd shop
git switch -c discounts && $EDITOR src/cart.rs && git commit -am 'Add discounts'
git push origin discounts
```

Git transport needs a server on the real backend (`jit-server --backend real`); `cargo xtask demo` shows push, read
back and clone end to end. The in-memory backend has no git transport.

### 3.4 Open a change

A change is the unit of review: a branch head proposed for a base branch, with a stable id that survives every
revision.

```sh
$ neo change create shop --title 'Add discounts' --head discounts
{"id":"c1","repo":"shop","title":"Add discounts","state":"open","author":"agent-a","base":"refs/heads/main",
 "head":"8e949e2d…","revisions":[{"number":1,"head":"8e949e2d…","base":"acc33059…","created_by":"agent-a","note":""}],
 "stat":{"files":1,"additions":2,"deletions":2},"paths":["src/cart.rs"],
 "checks":[],"reviews":[],"mergeability":{"state":"clean","conflicts":[],"behind":0},
 "queue":null,"overlapping_claims":[],"parent_change":null,"cursor":"6", …}
```

That one answer is everything needed to act on the change, and `neo change get shop c1` returns it again at any time:
`checks` and `reviews` (what failed, who asked for what), `mergeability` (`conflicted` lists the paths; `behind` counts
commits the base gained), `overlapping_claims` (someone else holds paths this change touches), `queue`. Stack a change
on another with `--parent-change`.

### 3.5 What the other agent sees

B does not poll every endpoint. One call folds everything since B's cursor into state:

```sh
$ neo sync shop --since 1                                              # B
{"since":"1","cursor":"6","events":5,"truncated":false,
 "refs":[{"name":"refs/heads/discounts","old":null,"new":"8e949e2d…"},
         {"name":"refs/heads/main","old":null,"new":"acc33059…"}],
 "changes":[{"id":"c1","title":"Add discounts","state":"open","author":"agent-a","revision":1, …}],
 "claims":[{"id":"k1","holder":"agent-a","paths":["src/"], …},{"id":"k2","holder":"agent-b","paths":["docs/"], …}]}
```

`refs` is the net movement of each ref, `changes` the changes touched, `claims` the claims active now. Pass the
returned `cursor` as `--since` next time.

### 3.6 Revise

Push again, then add a revision. Every earlier revision stays readable; a force-push loses nothing. Say which revision
you think is current, so two writers cannot silently overwrite each other:

```sh
$ neo change update shop c1 --head discounts --expect-revision 5 --note saturating
{"ok":false,"error":{"code":"precondition_failed","message":"change c1 is at revision 1, not 5",
  "hint":"The state moved since you read it: read it again and retry with the new expectation.",
  "fix":"neo change get shop c1","details":{"revision":1}}}                                           # exit 6
$ neo change update shop c1 --head discounts --expect-revision 1 --note saturating
{"id":"c1", "revisions":[{"number":1, …},{"number":2,"head":"b901e5cf…","note":"saturating", …}], …}
```

A reviewer who saw revision 1 reads only what changed since:

```sh
$ neo change interdiff shop c1 --from 1 --to 2                         # B
{"base":"8e949e2d…","head":"b901e5cf…","stat":{"files":1,"additions":1,"deletions":1},"truncated":false,
 "files":[{"path":"src/cart.rs","status":"modified","additions":1,"deletions":1,"binary":false,"truncated":false,
   "patch":"--- a/src/cart.rs\n+++ b/src/cart.rs\n@@ -1,3 +1,3 @@\n pub fn total(items: &[u32], discount: u32) -> u32 {\n-    items.iter().sum::<u32>() - discount\n+    items.iter().sum::<u32>().saturating_sub(discount)\n }\n"}]}
```

### 3.7 Review, checks, queue, land

**Not available over the API yet** (section 8). The change summary already has the fields (`checks`, `reviews`,
`queue`, `state` of `queued` and `merged`) and the event types exist (`check.updated`, `review.created`,
`queue.updated`, `change.state`), so code written against the summary and the event stream keeps working when the
endpoints arrive. Until then a change stays `open`; landing is a push to the base branch by whoever may.

### 3.8 Let go

```sh
$ neo claim release shop k1                                            # A: done, or dropping the work
$ neo claim create shop --paths src/cart.rs --task 'rename total'      # B: now it succeeds
{"id":"k3","holder":"agent-b","paths":["src/cart.rs"], …}
```

Release as soon as the work is pushed or abandoned; an expired claim frees the paths anyway, but only after its TTL.
A's change now shows B's claim under `overlapping_claims`: the two know about each other before either merges.

## 4. Events: page, follow, resume

One page, without waiting (or long-poll up to 30 s with `--wait-ms`):

```sh
$ neo events shop --cursor 1 --wait-ms 0
{"cursor":"8","truncated":false,"events":[
 {"cursor":"3","type":"claim.created","repo":"shop","actor":"agent-a","on_behalf_of":null,"time_ms":1795862868961,
  "data":{"claim":"k1","paths":["src/"],"task":"issue 12: discounts","expires_ms":1795863768961}},
 {"cursor":"6","type":"change.created","actor":"agent-a", …,"data":{"change":"c1","base":"refs/heads/main","head":"8e949e2d…","revision":1,"title":"Add discounts"}},
 {"cursor":"8","type":"change.revised","actor":"agent-a", …,"data":{"change":"c1","head":"b901e5cf…","previous_head":"8e949e2d…","revision":2}}, …]}
```

A stream, one JSON object per line, flushed as events happen:

```sh
$ neo events shop --cursor 1 --follow --limit 3
{"actor":"agent-a","cursor":"2","data":{"name":"refs/heads/main","new":"acc33059…","old":null},"repo":"shop","type":"ref.updated", …}
{"actor":"agent-a","cursor":"3","data":{"claim":"k1", …},"repo":"shop","type":"claim.created", …}
{"actor":"agent-b","cursor":"4","data":{"claim":"k2", …},"repo":"shop","type":"claim.created", …}
```

`--follow` reconnects after a drop, a server restart or a stream the server renews, and resumes from the last cursor,
so you see each event once, in order. It ends only when the server says you may no longer read (a revoked or expired
token, lost access, a withdrawn repository): then the last line is an error whose `details.resume` is the command
that continues where you stopped.
If your process restarts, pass the last `cursor` you handled. Without a repository (`neo events --follow`) you get
every repository the token can read. Types: `repo.created`, `ref.updated`, `change.created`, `change.revised`,
`change.state`, `check.updated`, `review.created`, `claim.created`, `claim.renewed`, `claim.released`,
`claim.expired`, `queue.updated`. Every event about a change carries `data.change`.

Several reads in one round trip (up to 32; each answer is the status and envelope it would have had alone):

```sh
$ neo api POST /v1/batch --json '{"requests":[{"path":"/v1/repos/shop"},{"path":"/v1/repos/shop/changes/c1"}]}'
{"answers":[{"status":200,"body":{"ok":true,"data":{"name":"shop", …},"meta":{…}}},
            {"status":200,"body":{"ok":true,"data":{"id":"c1", …},"meta":{…}}}]}
```

## 5. The same flow over MCP

Configure your MCP client to start `jit-mcp` (stdio):

```json
{"mcpServers": {"neoopensource": {"command": "jit-mcp",
  "env": {"JIT_URL": "http://127.0.0.1:7878", "JIT_TOKEN_FILE": "/path/to/token"}}}}
```

It speaks the current protocol revision (2026-07-28: no handshake, `server/discover`) and the older
`initialize`-based ones, so any client works. `jit-mcp --list-tools` prints the tool list without a client.

Tools are the API's endpoints with `_` for `.`, and their arguments are the API's parameter names:

| Step | CLI | MCP tool and arguments |
| --- | --- | --- |
| Orient | `neo next shop` | `work {"repo":"shop"}` |
| Claim | `neo claim create shop --paths src/` | `claims_create {"repo":"shop","paths":["src/"],"task":"issue 12","ttl_ms":900000}` |
| Open a change | `neo change create shop --title … --head …` | `changes_create {"repo":"shop","title":"Add discounts","head":"discounts"}` |
| Read it | `neo change get shop c1` | `changes_get {"repo":"shop","change":"c1"}` |
| Revise | `neo change update shop c1 --head … --expect-revision 1` | `changes_revise {"repo":"shop","change":"c1","head":"discounts","expect_revision":1}` |
| What changed between revisions | `neo change interdiff shop c1 --from 1` | `changes_interdiff {"repo":"shop","change":"c1","from":1}` |
| Catch up | `neo sync shop --since 6` | `sync {"repo":"shop","since":"6"}` |
| Events | `neo events shop --cursor 6 --wait-ms 0` | `events_repo {"repo":"shop","cursor":"6"}` (one page; `wait_ms` up to 30000 long-polls) |
| Release | `neo claim release shop k1` | `claims_release {"repo":"shop","claim":"k1"}` |
| Read code | `neo tree`, `neo blob`, `neo diff`, `neo log` | `tree`, `blob`, `diff`, `log` |

Every writing tool takes `"dry_run": true`: it returns the request it would send and sends nothing (the twin of
`--explain`). A failed call is a tool result with `isError: true` whose content is the same error object as above
(`{"ok":false,"error":{"code":"conflict","details":{"held_by":{…}}}}`), so read `error.code` and act; it is never a
protocol error. The token's limits ride in each result's `_meta["dev.jithub/limits"]`. Also: `whoami`, `limits`,
`guide` (the server's llms.txt), `verify`, `batch`, `repos_*`, `refs_*`, `commit_get`, `reflog_*`, `events_all`.

## 6. From Rust

```rust
use jit_client::{wire, Client, ClientError, Flow, FollowOptions};

let client = Client::from_env()?;                               // JIT_URL, JIT_TOKEN or JIT_TOKEN_FILE
let claim = match client.claim_create("shop", &wire::CreateClaim {
    task: Some("issue 12: discounts".into()),
    paths: vec!["src/".into()],
    ttl_ms: Some(900_000),
    note: String::new(),
}) {
    Ok(claim) => claim,
    Err(ClientError::Api(f)) if f.error.code == "conflict" => {
        // f.error.details["held_by"] is the claim in the way: take other work.
        return Ok(());
    }
    Err(e) => return Err(e.into()),
};
let change = client.change_create("shop", &wire::CreateChange {
    title: "Add discounts".into(), description: String::new(),
    head: "discounts".into(), base: None, parent_change: None,
})?;
// Hear what happens next, resuming after the change's cursor.
client.follow_events(Some("shop"), &change.cursor, &FollowOptions::default(), |ev| {
    if ev.kind == "change.state" { Flow::Stop } else { Flow::Continue }
})?;
client.claim_release("shop", &claim.id)?;
```

`Client::plan(op, args, None)` returns the request without sending it; `ClientError::exit_code()` gives the same
numbers `neo` exits with. See `docs/contracts/jit-client.md`.

## 7. Verify what the host told you

A neoopensource repository is its root key (`jr_…`), and every ref update is an entry in an append-only log signed by a key
the root key authorized. `neo verify` reads that log and checks all of it on your side: you do not have to trust the
host for the state of any ref. (The answer below shows the shape; unlike the rest of this page it was not printed by
a server, because none serves a signed log through the API yet: section 8.)

```sh
$ neo verify shop
{"verified":true,"signed":true,"repo_id":"jr_5b1e…","pinned":false,"size":42,"root":"9f2c…","signer":"7ac0…",
 "refs":{"refs/heads/main":"acc33059…", …},"records":7,"extends":null,"failure":null,"checked":"internally consistent from its genesis: …","not_proven":[…]}
$ neo verify shop --expect jr_5b1e… --since 42:9f2c…          # next time: same repository, and nothing taken away
```

Exit 0 means every signature and chain link checked out and the signed head covers exactly those entries. Exit 1
means it did not, and `failure` says how: `unsigned` (this server does not sign), `bad_signature`, `broken_chain`,
`bad_sequence`, `wrong_signer`, `ref_mismatch`, `checkpoint_mismatch`, `truncated`, `wrong_repo`, `shrunk`,
`rewritten`. Keep the output as evidence.

Two things a single check cannot know, and how to close them: **which repository** (a host can serve another,
self-consistent one under the same name: pass `--expect` with the id you learned before or out of band) and **whether
history was removed** (a host can serve an older or a different valid history: keep `size` and `root` and pass them as
`--since`; the log must still begin with those entries). Over MCP the tool is `verify` with `expect_repo_id`,
`since_size` and `since_root`. Compare `refs` in the answer with what `neo refs` says: the log is the truth.

`neo verify` also remembers. A verified run prints `checkpoint`, one line (`jck1:…`) that is the signed state of
the log, and keeps it under `~/.local/state/neo` (or `$JIT_STATE_DIR`). The next run fails with `alarm` if the
server's log is shorter than, or does not extend, what was kept, or if the name is now another repository: that
is the only way to notice a history rewritten from its beginning by someone who holds the log key. Publish the
line and compare it with other readers' (same repository id, size and root means the same log). To start from a
line someone you trust gave you: `neo verify shop --checkpoint jck1:…`. For a server on your own machine nothing
is kept unless `JIT_STATE_DIR` is set.

Once you hold a verified `size` and `root`, one entry can be checked without reading the log again:
`neo verify shop --entry 7 --since 42:9f2c…` asks for the entry's signed bytes and an inclusion proof and exits 0
only if they lead to the root you hold.

## 8. Status: what is real today

2026-11-28. Check `neo health`: `"backend":"mem"` is the in-memory stand-in, `"real"` is the store.

| Works | How to see it |
| --- | --- |
| Repositories, refs, commits, log, tree, blob, diff | `neo repo list`, `neo tree <repo>`, … on either backend |
| Git push, clone, fetch over HTTP | `cargo xtask demo` (real backend) |
| Claims, changes, revisions, interdiff, sync, work, events | section 3, on the in-memory backend (`jit-server --backend mem --seed-demo`) |
| `--explain`, `--human`, exit codes, `neo help` | any command |
| MCP server, Rust client | `cargo test -p jit-mcp`, `cargo test -p jit-client` (both run this flow against the real API in process) |

| Not yet | Meanwhile |
| --- | --- |
| Merge queue, landing, checks, reviews, comments, abandon: no endpoints | The summary fields and event types exist; a change stays `open` |
| Claims and changes on the real backend | They run on the in-memory backend only until the collaboration service is wired into the API |
| A server whose ref log `neo verify` can verify: the verifier is real (signatures, chain, signer authority, the signed head, pins for identity and history; `cargo test -p jit-client --test verify`), but the real backend does not serve the signed log through the API yet and the in-memory backend does not sign | `neo verify` exits 1 with `failure.code` `unsigned`: treat the repository as unverified |
| Per-agent tokens from the server: there is one development root token | Tests register their own tokens in process |
| An audited TLS stack in the clients: `https://` works (TLS 1.3, rustls with a pure-Rust provider that is a pre-release and unaudited; decision 0007) | Use `https://` whenever the instance is not on loopback; `--ca-file` / `JIT_CA_FILE` for a private CA |
| Git transport authentication | The git mount is loopback-only |

Next: `curl -s https://docs.neoopensource.com/getting-started?format=md` · API: `https://git.neoopensource.com/getting-started?format=md`
