@divergeai/cli 0.1.13 → 0.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +39 -19
  2. package/dist/diverge.mjs +740 -585
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -18,11 +18,23 @@ Node 22 or later. Linux and macOS are supported; Windows is best-effort.
18
18
  `diverge login` runs the browser sign-in (authorization code with PKCE on a
19
19
  loopback listener). The browser only authenticates you; the organization is
20
20
  chosen afterwards in the CLI, never through the browser: `--organization-id
21
- <id|name>` if given, else the last login's, else your only membership, else a
22
- menu. The login is bound to that organization on the platform, and `diverge
23
- org use <id|name>` switches without a browser. The login is cached in
24
- `~/.diverge/token.json` (mode 0600), refreshes itself, and `diverge logout`
25
- revokes it on the platform before forgetting it.
21
+ <id|name>` if given, else the last login's, else your only organization, else
22
+ a menu. The organizations offered are the ones you may act in: your
23
+ memberships, and for a platform actor every organization. That organization is the default — where commands that name none act —
24
+ and `diverge org use <id|name>` changes it. The login itself is yours, not an
25
+ organization's: every token is issued for the organization a command acts
26
+ in. The login is cached in
27
+ `~/.diverge/logins/<deployment>/login.json` (mode 0600) and refreshes itself:
28
+ each use extends it by seven days, never past thirty days from sign-in, and `diverge logout`
29
+ revokes it on the platform before forgetting it. `diverge status` shows both:
30
+ the idle expiry and the thirty-day end; after that every command exits 6 and says to run `diverge
31
+ login`.
32
+
33
+ The login is shared by every shell and agent on the machine, and so is the
34
+ default. To work in another organization without changing it, name it on the
35
+ command — `--organization-id <id>` or `DIVERGENT_ORG_ID`: the CLI gets a token
36
+ for that organization from the login and caches it beside the others. The
37
+ platform grants it only where your roles back the login's scopes.
26
38
 
27
39
  - `diverge status` shows the deployment, the organization, the scopes, and a
28
40
  `Tool execution:` line naming who a tool call would run as: you, or a
@@ -37,15 +49,19 @@ revokes it on the platform before forgetting it.
37
49
  which one; it signs that account in instead of reusing whatever session the
38
50
  browser holds and issues nothing to any other. Without `--as` the account
39
51
  of the last login is kept, so switching accounts is always explicit.
40
- - A login also remembers its scopes: without `--scopes` the next login asks
41
- for the same ones, so a routine re-login never narrows what the CLI may do.
42
- A token carries only what was asked at sign-in; the Forge scopes
43
- (`forge:read forge:write`) are what the Forge lanes need.
44
- - `diverge token` prints a fresh access token and nothing else. It is the
45
- credential helper Claude Code and Codex call, so an agent never holds a
46
- long-lived key.
47
- - `diverge login --api-url <url>` targets another deployment and remembers it;
48
- `DIVERGENT_API_URL` overrides per shell.
52
+ - Without `--scopes` a login asks for the scopes the platform registers for
53
+ this CLI — everything it and Forge use — and holds what your roles grant,
54
+ so a routine re-login never narrows what another session relies on. The
55
+ platform re-reads that registration on every refresh: a scope added there
56
+ reaches your login without a new CLI or a new sign-in. `--scopes` asks for
57
+ less, deliberately, and that login stays exactly that narrow.
58
+ - `diverge token [--organization-id <id>]` prints a fresh access token and
59
+ nothing else. It is the credential helper Claude Code, Codex and `forge`
60
+ call, so an agent never holds a long-lived key.
61
+ - Each deployment keeps its own login. `diverge login --api-url <url>` signs
62
+ in to another one (a test stack) beside the production login; commands
63
+ reach it when `DIVERGENT_API_URL` names it. Nothing on disk chooses the
64
+ deployment.
49
65
 
50
66
  ## Coding agents
51
67
 
@@ -113,15 +129,17 @@ shows it how, file-based arguments and batches included.
113
129
  ## Platform tools
114
130
 
115
131
  Every command takes the scope it acts in: `--organization-id` (or
116
- `DIVERGENT_ORG_ID`, else the organization the login was issued to) and, for a
132
+ `DIVERGENT_ORG_ID`, else the login's organization; another one gets its own
133
+ token without moving the login) and, for a
117
134
  resource inside a project, `--project-id` (or `DIVERGENT_PROJECT_ID`).
118
135
 
119
136
  ```bash
120
- diverge tools list --filter rbac # find candidates
137
+ diverge tools list --filter rbac # find candidates by name or description
121
138
  diverge tools describe rbac_assign_role # one schema, on demand
122
139
  diverge tools call rbac_list_roles --args-json '{}'
140
+ diverge tools call rbac_list_roles --json # exactly one JSON outcome on stdout, errors included
123
141
  diverge tools call inventory_lookup_stock --args-file args.json # or --args-json - to read stdin
124
- diverge tools run calls.json --wait # several calls from one file, one JSON line of outcome each
142
+ diverge tools run calls.json --wait # several calls from one file (- for stdin), one JSON line of outcome each
125
143
  ```
126
144
 
127
145
  Put arguments in a file or on stdin when a shell may touch them: Windows
@@ -132,7 +150,8 @@ order, and exits with the worst outcome: 1 failed, 4 rejected, 5 expired,
132
150
 
133
151
  A write that needs a human is not refused: it is persisted as a pending
134
152
  invocation, decided in the platform's approval inbox, and read back here by
135
- id. Branch on the exit code, never on text:
153
+ id. Branch on the exit code, never on text; `call`, `run` and `invocation <id>`
154
+ give the same code for the same status, with or without `--json`:
136
155
 
137
156
  | code | meaning |
138
157
  | --- | --- |
@@ -140,6 +159,7 @@ id. Branch on the exit code, never on text:
140
159
  | 3 | pending: hand over the link, read it back later with `diverge tools invocation <id>` (add `--wait` to stay attached) |
141
160
  | 4 | rejected, with the operator's reason |
142
161
  | 5 | expired: raise a fresh call, the old id is final |
162
+ | 6 | the login expired or was revoked: run `diverge login`; retrying will not help |
143
163
  | 1 | failure, including approved-but-failed |
144
164
 
145
165
  The CLI raises and reads; it never decides. `diverge tools bridge` serves the
@@ -182,7 +202,7 @@ non-interactive shells, under `CI`, and with `DIVERGE_NO_UPDATE_CHECK=1`.
182
202
 
183
203
  | variable | effect |
184
204
  | --- | --- |
185
- | `DIVERGENT_API_URL` | the deployment for this shell |
205
+ | `DIVERGENT_API_URL` | the deployment for this shell; production when unset |
186
206
  | `DIVERGE_HOME` | state directory, default `~/.diverge` |
187
207
  | `DIVERGENT_ORG_ID`, `DIVERGENT_PROJECT_ID` | tool scope when the flags are omitted; without either, the login's organization |
188
208
  | `DIVERGENT_CLIENT_ID`, `DIVERGENT_CLIENT_SECRET`, `DIVERGENT_USER_ID` | unattended tool execution with service credentials, delegated to that person |