@collective-intelligence/cli 0.1.0 → 0.1.2

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 +74 -14
  2. package/dist/cli.js +36 -20
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -4,25 +4,42 @@ The public `ci` binary manages Extension Package development and immutable
4
4
  release operations. It talks to the Backend only through generated OpenAPI
5
5
  operations; it does not import private Backend runtime code.
6
6
 
7
- ## Sign In and Enroll a Local App
7
+ ## Install
8
+
9
+ The `ci` binary runs on [Bun](https://bun.sh). Install Bun, then install the
10
+ CLI globally with one of these package managers:
11
+
12
+ ```sh
13
+ # npm
14
+ npm install -g @collective-intelligence/cli
15
+ # pnpm (run `pnpm setup` once if pnpm has no global bin directory)
16
+ pnpm add -g @collective-intelligence/cli
17
+ # Bun
18
+ bun add -g @collective-intelligence/cli
19
+ ```
20
+
21
+ Run `ci --help` to check the installation.
22
+
23
+ ## Sign In and Enroll Your App
8
24
 
9
25
  Interactive developers sign in once; pipelines keep using a token. Every
10
26
  command accepts either credential.
11
27
 
12
28
  ```sh
13
- # Device login: copy this command from the Dashboard (Organization settings →
14
- # CLI), approve the code in the Dashboard, then the CLI stores a 30-day CLI
15
- # Session in ~/.config/ci/profiles.json (mode 0600).
16
- ci login https://api.devpunks.example.com --organization <organization-id>
29
+ # Device login: copy this command from the Dashboard (Organization →
30
+ # Developers → CLI), approve the code in the Dashboard, then the CLI stores a
31
+ # 30-day CLI Session in ~/.config/ci/profiles.json (mode 0600).
32
+ ci login <api-url> --organization <organization-id>
17
33
  ci whoami
18
34
  ci orgs list
19
35
  ci orgs use <organization-id>
20
36
 
21
- # Create or replace one Organization-scoped Public Application by FQN and
22
- # write its connection values.
37
+ # Create or replace one Organization-scoped External App by FQN and
38
+ # write its connection values. Replace the placeholders with your app's FQN
39
+ # and sign-in callback URL.
23
40
  ci apps enroll \
24
- --fqn acme.portal.local \
25
- --redirect-uri http://localhost:3000/login/callback \
41
+ --fqn <your.app.fqn> \
42
+ --redirect-uri <your-app-callback-url> \
26
43
  --scopes context:read \
27
44
  --env-file .env.local
28
45
  ci logout
@@ -31,7 +48,7 @@ ci logout
31
48
  - `ci login <API URL>` resolves the API origin, issuer and JWKS URL from the
32
49
  API host's `/.well-known/ci-configuration`. A Dashboard URL is rejected as
33
50
  "not a CI API URL"; the Dashboard shows the exact command under Organization
34
- settings → CLI. `--organization <id>` selects the Current Organization;
51
+ → Developers → CLI. `--organization <id>` selects the Current Organization;
35
52
  without it, a re-login keeps the Profile's previous Organization for the same
36
53
  API origin. `--no-browser` only prints the URL.
37
54
  - Resolution order for the backend URL, credential and Organization: flag
@@ -39,10 +56,14 @@ ci logout
39
56
  `CI_MANAGEMENT_TOKEN`), then the Profile (`--profile` or `CI_PROFILE` selects
40
57
  one). A Profile never supplies a session for a different origin.
41
58
  - `CI_MANAGEMENT_TOKEN` can be an Organization API key with the
42
- `public_applications_manage` scope. The key fixes its Organization.
59
+ `external_apps_manage` scope. The key fixes its Organization.
43
60
  - `ci apps enroll` requires `--fqn`, `--redirect-uri` (repeatable) and
44
61
  `--scopes`. Defaults: `--type public`, name = FQN, allowed origins = redirect
45
- URI origins, audience = first redirect URI origin. Loopback redirect URIs
62
+ URI origins, audience = first redirect URI origin, primary redirect URI =
63
+ first `--redirect-uri`. `--primary-redirect-uri <uri>` picks another primary;
64
+ it must be one of the `--redirect-uri` values. `--allowed-origin <origin>`
65
+ (repeatable) replaces the derived allowed origins; each value must be an
66
+ exact origin such as `https://<your-app-host>`. Loopback redirect URIs
46
67
  (`http://localhost`, `http://127.0.0.1`, `http://[::1]`) need an explicit port.
47
68
  - Output keys: `CI_ISSUER`, `CI_AUDIENCE`, `CI_APPLICATION_ID`, `CI_CLIENT_ID`,
48
69
  `CI_ORGANIZATION_ID`, `CI_JWKS_URL`, `CI_SCOPES`, plus `CI_CLIENT_SECRET` for
@@ -61,6 +82,45 @@ ci logout
61
82
  `apps` also fails after 30 seconds without a complete response; a login
62
83
  token poll gets its own 30 seconds. Ctrl-C cancels the request in flight.
63
84
  - `ci apps list|get|rotate-secret|disable` manage existing applications.
85
+ `list` and `get` show `primaryRedirectUri` beside `redirectUris`.
86
+
87
+ ## Manage Redirect URIs and Trusted Websites
88
+
89
+ An application accepts every registered redirect URI. A sign-in chooses its
90
+ callback with the OAuth `redirect_uri` parameter; the primary redirect URI is
91
+ the default that people and tools use. `allowedOrigins` lists the trusted
92
+ websites: exact origins that may call CI from a browser. `<application>` is an
93
+ Application Id or an FQN.
94
+
95
+ ```sh
96
+ ci apps redirect-uris list <your.app.fqn>
97
+ # Register another callback. By default this also trusts its origin;
98
+ # --no-trust-origin skips that, --primary also makes it the primary.
99
+ ci apps redirect-uris add <your.app.fqn> <your-preview-callback-url>
100
+ ci apps redirect-uris set-primary <your.app.fqn> <your-app-callback-url>
101
+ ci apps redirect-uris remove <your.app.fqn> <your-preview-callback-url>
102
+
103
+ ci apps origins list <your.app.fqn>
104
+ ci apps origins add <your.app.fqn> https://<your-app-host>
105
+ ci apps origins remove <your.app.fqn> https://<your-app-host>
106
+ ```
107
+
108
+ - Each write reads the application, computes the full new lists and sends one
109
+ update. The CLI checks URLs before any request: HTTPS, or loopback HTTP with
110
+ an explicit port, with no `#` and no `*`. An origin must have no path.
111
+ - `list` prints `{ "primaryRedirectUri", "redirectUris" }` or
112
+ `{ "allowedOrigins" }`; a write prints the updated application like
113
+ `ci apps get`. Notes and warnings go to stderr.
114
+ - Adding a registered redirect URI or a trusted origin again changes nothing
115
+ and says so. `redirect-uris add` then reports the redirect-URI check of
116
+ `ci doctor`; a failed check does not undo the write.
117
+ - `redirect-uris remove` refuses the last redirect URI and the primary one (run
118
+ `set-primary` first). When no remaining redirect URI uses the removed URI's
119
+ origin, it prints the `ci apps origins remove` command but keeps the origin.
120
+ - `redirect-uris set-primary` needs a registered redirect URI.
121
+ `origins remove` warns when a redirect URI still uses the origin.
122
+ - These commands refuse package-owned applications; change those through their
123
+ Extension Package.
64
124
 
65
125
  ## Deploy an Exact Release
66
126
 
@@ -335,9 +395,9 @@ native Dataset behavior; refresh does not approve or widen a policy implicitly.
335
395
  ## Client secrets for package-created applications
336
396
 
337
397
  Install creates a declared confidential application without a client secret.
338
- An administrator holding `public_applications:manage` (CLI Session, Dashboard
398
+ An administrator holding `external_apps:manage` (CLI Session, Dashboard
339
399
  session token or API key) runs `ci apps rotate-secret <application-id>`, calls
340
- `POST /admin/organization/public-applications/<application-id>/credential/rotate`
400
+ `POST /admin/organization/external-apps/<application-id>/credential/rotate`
341
401
  with the `x-organization-id` header, or chooses **Rotate secret** on the
342
402
  application in the Dashboard External Apps page. The response shows
343
403
  `clientSecret` once; store it server-side immediately, because CI keeps only its