@divergeai/cli 0.1.14 → 0.1.23

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 +45 -19
  2. package/dist/diverge.mjs +872 -639
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -13,16 +13,34 @@ diverge tools list --organization-id <id>
13
13
 
14
14
  Node 22 or later. Linux and macOS are supported; Windows is best-effort.
15
15
 
16
+ `diverge --help`, `diverge <command> --help` and `diverge <command> <verb>
17
+ --help` print the usage, and that usage is the CLI's command table: a
18
+ command, verb or option that does not exist is answered with the closest ones
19
+ it lists, by spelling or by what their description says (`diverge whoami` →
20
+ `diverge status`, `tools search` → `tools list --filter`), and exits 1.
21
+
16
22
  ## Sign in
17
23
 
18
24
  `diverge login` runs the browser sign-in (authorization code with PKCE on a
19
25
  loopback listener). The browser only authenticates you; the organization is
20
26
  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.
27
+ <id|name>` if given, else the last login's, else your only organization, else
28
+ a menu. The organizations offered are the ones you may act in: your
29
+ memberships, and for a platform actor every organization. That organization is the default — where commands that name none act —
30
+ and `diverge org use <id|name>` changes it. The login itself is yours, not an
31
+ organization's: every token is issued for the organization a command acts
32
+ in. The login is cached in
33
+ `~/.diverge/logins/<deployment>/login.json` (mode 0600) and refreshes itself:
34
+ each use extends it by seven days, never past thirty days from sign-in, and `diverge logout`
35
+ revokes it on the platform before forgetting it. `diverge status` shows both:
36
+ the idle expiry and the thirty-day end; after that every command exits 6 and says to run `diverge
37
+ login`.
38
+
39
+ The login is shared by every shell and agent on the machine, and so is the
40
+ default. To work in another organization without changing it, name it on the
41
+ command — `--organization-id <id>` or `DIVERGENT_ORG_ID`: the CLI gets a token
42
+ for that organization from the login and caches it beside the others. The
43
+ platform grants it only where your roles back the login's scopes.
26
44
 
27
45
  - `diverge status` shows the deployment, the organization, the scopes, and a
28
46
  `Tool execution:` line naming who a tool call would run as: you, or a
@@ -37,15 +55,19 @@ revokes it on the platform before forgetting it.
37
55
  which one; it signs that account in instead of reusing whatever session the
38
56
  browser holds and issues nothing to any other. Without `--as` the account
39
57
  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.
58
+ - Without `--scopes` a login asks for the scopes the platform registers for
59
+ this CLI — everything it and Forge use — and holds what your roles grant,
60
+ so a routine re-login never narrows what another session relies on. The
61
+ platform re-reads that registration on every refresh: a scope added there
62
+ reaches your login without a new CLI or a new sign-in. `--scopes` asks for
63
+ less, deliberately, and that login stays exactly that narrow.
64
+ - `diverge token [--organization-id <id>]` prints a fresh access token and
65
+ nothing else. It is the credential helper Claude Code, Codex and `forge`
66
+ call, so an agent never holds a long-lived key.
67
+ - Each deployment keeps its own login. `diverge login --api-url <url>` signs
68
+ in to another one (a test stack) beside the production login; commands
69
+ reach it when `DIVERGENT_API_URL` names it. Nothing on disk chooses the
70
+ deployment.
49
71
 
50
72
  ## Coding agents
51
73
 
@@ -113,15 +135,17 @@ shows it how, file-based arguments and batches included.
113
135
  ## Platform tools
114
136
 
115
137
  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
138
+ `DIVERGENT_ORG_ID`, else the login's organization; another one gets its own
139
+ token without moving the login) and, for a
117
140
  resource inside a project, `--project-id` (or `DIVERGENT_PROJECT_ID`).
118
141
 
119
142
  ```bash
120
- diverge tools list --filter rbac # find candidates
143
+ diverge tools list --filter rbac # find candidates by name or description
121
144
  diverge tools describe rbac_assign_role # one schema, on demand
122
145
  diverge tools call rbac_list_roles --args-json '{}'
146
+ diverge tools call rbac_list_roles --json # exactly one JSON outcome on stdout, errors included
123
147
  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
148
+ diverge tools run calls.json --wait # several calls from one file (- for stdin), one JSON line of outcome each
125
149
  ```
126
150
 
127
151
  Put arguments in a file or on stdin when a shell may touch them: Windows
@@ -132,7 +156,8 @@ order, and exits with the worst outcome: 1 failed, 4 rejected, 5 expired,
132
156
 
133
157
  A write that needs a human is not refused: it is persisted as a pending
134
158
  invocation, decided in the platform's approval inbox, and read back here by
135
- id. Branch on the exit code, never on text:
159
+ id. Branch on the exit code, never on text; `call`, `run` and `invocation <id>`
160
+ give the same code for the same status, with or without `--json`:
136
161
 
137
162
  | code | meaning |
138
163
  | --- | --- |
@@ -140,6 +165,7 @@ id. Branch on the exit code, never on text:
140
165
  | 3 | pending: hand over the link, read it back later with `diverge tools invocation <id>` (add `--wait` to stay attached) |
141
166
  | 4 | rejected, with the operator's reason |
142
167
  | 5 | expired: raise a fresh call, the old id is final |
168
+ | 6 | the login expired or was revoked: run `diverge login`; retrying will not help |
143
169
  | 1 | failure, including approved-but-failed |
144
170
 
145
171
  The CLI raises and reads; it never decides. `diverge tools bridge` serves the
@@ -182,7 +208,7 @@ non-interactive shells, under `CI`, and with `DIVERGE_NO_UPDATE_CHECK=1`.
182
208
 
183
209
  | variable | effect |
184
210
  | --- | --- |
185
- | `DIVERGENT_API_URL` | the deployment for this shell |
211
+ | `DIVERGENT_API_URL` | the deployment for this shell; production when unset |
186
212
  | `DIVERGE_HOME` | state directory, default `~/.diverge` |
187
213
  | `DIVERGENT_ORG_ID`, `DIVERGENT_PROJECT_ID` | tool scope when the flags are omitted; without either, the login's organization |
188
214
  | `DIVERGENT_CLIENT_ID`, `DIVERGENT_CLIENT_SECRET`, `DIVERGENT_USER_ID` | unattended tool execution with service credentials, delegated to that person |