@closedloop-ai/cli 0.3.2 → 0.3.4

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 +29 -11
  2. package/dist/closedloop.js +137 -135
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -24,17 +24,20 @@ The npm package is `@closedloop-ai/cli`; users of the earlier `cl` CLI can updat
24
24
 
25
25
  ## Commands
26
26
 
27
- - `closedloop login` (also `closedloop signup`): sign in, or create an account on the Free plan, with a code sent to your email.
28
- - Which sign-in an account uses: an account with a password signs in with the password, and one whose workspace signs in with SSO uses SSO; both sign in through the browser with `closedloop login --sso`. Only a new email, or an account with neither (such as one made with `closedloop signup`), gets an emailed code. For any other account the code request is refused before an email is sent: `password_sign_in` for a password, `sso_required` for SSO, each naming `closedloop login --sso`.
29
- - In a terminal, `closedloop login` asks for the email and the code. Before creating a new account it asks for the data region: United States (US, the default) or European Union (EU). Existing accounts keep their region and are not asked to choose another one.
30
- - `--region us|eu` explicitly selects where a new account's data should live. For an agent creating an account, two runs: `closedloop signup --email you@example.com --region eu` sends the code; `closedloop login --email you@example.com --region eu --code BCDFG-HJKLM` finishes. Use `us` for the United States. Without a region, an agent creating a new account is refused with `region_required` before an email code is requested; existing accounts can still sign in without the flag. Add `--totp <code>` (or `--backup-code <code>`) when the account uses two-factor authentication.
31
- - `closedloop login --sso`: sign in through your browser instead, for accounts with a password and for workspaces that sign in with SSO (Entra, Okta). Add `--region eu` or `--region us` to choose the initial sign-in region. It prints a link and a short code; open the link, sign in to the app, type the code and approve. An existing account automatically completes sign-in in its home region, even when the command started elsewhere. In a terminal it also copies the code to your clipboard and opens the link when you press Enter, then waits; an agent runs the printed command again after you approve, keeping its `--region` flag.
27
+ - `closedloop login [email]` (also `closedloop signup`): sign in, or create an account on the Free plan, in one command.
28
+ - Give your email once: `closedloop login you@example.com` (`--email you@example.com` works too). As soon as the CLI finds your account, it saves the email and the account's region, so the next `closedloop login` needs no email. An email with no account (a typo) is never saved. Without an email and with none saved, a person at a terminal is asked for it, and an agent is refused with `missing_email` and the command to run.
29
+ - The CLI looks the email up in both regions (US and EU), says `Signing in as <email> (<region>)`, and picks the sign-in for you. An account with a password, or whose workspace signs in with SSO, signs in through the browser in its home region. An account with neither (such as one made with `closedloop signup`) gets a code by email. An email with no account signs up with an emailed code. As JSON, each answer carries the `email` and `region`.
30
+ - If an emailed code is refused because the account signs in with SSO (`sso_required`) or a password (`password_sign_in`), a person goes on to the browser sign-in in the same run, and an agent is told to run `closedloop login <email> --browser`.
31
+ - In a terminal, `closedloop login` asks for the code. Before creating a new account it asks for the data region: United States (US, the default) or European Union (EU). Existing accounts keep their region and are not asked to choose another one.
32
+ - `--region us|eu` explicitly selects where a new account's data should live. With `--region`, or with `CLOSEDLOOP_API_URL` set, the CLI skips the lookup and uses that API (`--browser` still signs in through the browser). For an agent creating an account, two runs: `closedloop signup --email you@example.com --region eu` sends the code; `closedloop login --email you@example.com --region eu --code BCDFG-HJKLM` finishes. Use `us` for the United States. Without a region, an agent creating a new account is refused with `region_required` before an email code is requested; existing accounts can still sign in without the flag. Add `--totp <code>` (or `--backup-code <code>`) when the account uses two-factor authentication.
33
+ - `closedloop login <email> --browser` (`--sso` still works): sign in through your browser, whatever sign-in the account uses. It prints a link and a short code; open the link, sign in to the app, type the code and approve. The link names your email, so the app goes straight to your sign-in. Add `--region eu` or `--region us` to choose the initial sign-in region. An existing account automatically completes sign-in in its home region, even when the command started elsewhere, and the saved region follows it. In a terminal it also copies the code to your clipboard and opens the link when you press Enter, then waits; an agent runs the printed command again after you approve (it names the email and any `--region`, which is how the second run finds the saved request).
34
+ - Whoever approves in the browser is who signs in. If the browser is signed in as another account than the email you gave, the CLI signs in as the account that approved, files the session under that account, and says so (as JSON: `different_account: true` and the `requested_email`).
32
35
  - An email whose account is in the other region (US or EU) signs in there, and the session stays with that region.
33
36
  - `--region` never moves an existing account. A saved sign-in and `closedloop whoami` show the account's actual region. If a connection fails after browser approval in another region, repeat the same printed command: the CLI retains that pending sign-in and its original expiry. A rejected or expired request starts again with a fresh link and code.
34
37
  - A new account gets its own Free workspace unless the email was invited to one. One network can create three such accounts a day.
35
38
  - A new account is asked for its company website right after the code (in a terminal), or takes `--website <url>` (an agent passes it with `--code`). ClosedLoop AI researches the company from it before it analyses anything you send in; without it, imports run but nothing becomes insights. A website that cannot be saved does not undo the sign-in: the result names it and says to run `closedloop company --website <url>`.
36
39
  - Then its email domains: the domains of your colleagues' work addresses, which tell ClosedLoop AI who is a colleague and who is a customer. In a terminal it suggests them (from the website and your own address, never a personal one such as gmail.com) and you confirm or correct them, or type `none` and confirm that your company has none. An agent gets `domains_instructions`: plain sentences telling it what to ask its user and which command to run with their answer. Nothing in a new workspace is analysed until a person has confirmed them.
37
- - The session is saved in `credentials.json` in the config folder. Tokens are stored as local JSON, not in an OS keychain; passwords are not saved. Unix directories use mode `0700` and files `0600`; Windows uses the account's local application-data folder and its inherited access permissions.
40
+ - Signing in makes the account the active one (see Accounts). The config folder holds `general.json` (the active account, and the email and region last signed in with) and one file per account in `accounts/` (its session, its sign-in in progress, its working goal and numbered lists), each named by a hash of the email with the email inside. Tokens are stored as local JSON, not in an OS keychain; passwords are not saved. Unix directories use mode `0700` and files `0600`; Windows uses the account's local application-data folder and its inherited access permissions.
38
41
  - The API checks the session on every call. The CLI renews it once it is past half its 30 days, so it stays signed in while you use it; if the API refuses it, the CLI renews once more, and otherwise asks you to sign in again.
39
42
  - `closedloop whoami`: who you are signed in as, your workspace (role and plan), the other workspaces you belong to, the region, when and how this computer signed in (an email code, or Google, Microsoft, Okta or SAML SSO, or a password, in the browser), and when the sign-in ends if the CLI is not used.
40
43
  - `closedloop status`: what is running now (company research, history imports with what is left and when they should finish, your own data still waiting or processing) and the onboarding checklist: company website, company research, email domains, product structure, a source, history imported, and the optional goal and team. Each open step names the command or the place in the app for it; a part the CLI could not read shows as unknown. No insights here: see `closedloop insights`.
@@ -49,7 +52,7 @@ The npm package is `@closedloop-ai/cli`; users of the earlier `cl` CLI can updat
49
52
  - `closedloop products`: your product structure, the products, areas (parts of a product) and features (parts of the product that exist, never planned work) your insights are filed against, with insight counts, then the products your company research suggested and has not had confirmed. As JSON it is the API's answer, whose `structure` can be edited and saved.
50
53
  - `products confirm [name...]` adds the suggested products (all, or the ones named) to the structure; `products save --file <structure.json>` (or `--file -` for standard input) saves a structure of your own, either the whole `closedloop products --json` answer or only its `structure`. Products, areas and features left out are archived, never deleted. `--check` only checks.
51
54
  - Both check the structure first and list every change. In a terminal the CLI asks you to type `yes`; anyone else adds `--yes`, which an agent does only after its user agreed. Without it nothing is saved and the result's `instructions` say what to ask. Saving needs an owner or admin; the next nightly recalculation then re-places needs and insights, charged in credits.
52
- - `closedloop competitors`: the competitors ClosedLoop AI watches for in your insights, the same list as Settings, Company, Competitors in the app: each with its website, whether it is a direct competitor, how many times customers mentioned it, and where it came from (your company research, your insights, or added or changed by your team). Insights that name one count as competitor mentions, shown on opportunities, features, customer profiles and the weekly brief. As JSON it is the API's `competitors` and `can_change`.
55
+ - `closedloop competitors`: the competitors ClosedLoop AI watches for in your insights, the same list as Settings, Company, Competitors in the app: each with its website, whether it is a direct competitor, how many times customers mentioned it, and where it came from (AI research, mentioned by customers, or manual). Insights that name one count as competitor mentions, shown on opportunities, features, customer profiles and the weekly brief. As JSON it is the API's `competitors` and `can_change`.
53
56
  - `competitors add <name> [--website <url>] [--description <text>]` adds one as a direct competitor (adding one that was removed restores it); `competitors edit <name-or-id> [--name <name>] [--website <url>] [--description <text>]` changes only what you give (an empty value clears the website or description); `competitors remove <name-or-id>` marks it as not a competitor and takes it off the list, keeping the customer mentions behind it. A name matches in any case; one that matches none or several is refused with the candidates.
54
57
  - A removal asks you to type `yes` in a terminal; anyone else adds `--yes`, which an agent does only after its user agreed. Without it nothing is removed and the result's `instructions` say what to ask. Adding, editing and removing need the right to change the workspace's settings (an owner or admin).
55
58
  - `closedloop ingest [text]`: sends your own data in (feedback, notes, survey answers, transcripts) for the pipeline to turn into insights.
@@ -97,7 +100,18 @@ The npm package is `@closedloop-ai/cli`; users of the earlier `cl` CLI can updat
97
100
  - `usage export [--month 2026-10] [--output file] [--force]`: saves the month's usage per day and integration as a CSV, never over an existing file unless `--force`.
98
101
  - `closedloop plan`: your plan and what it includes; `plan upgrade` opens Plan & billing (payment happens in the browser), or gives an agent the link.
99
102
  - `closedloop glossary`: what the words mean (product structure, product, area, feature, insight, opportunity, need, customer, competitor), as ClosedLoop AI defines them.
100
- - `closedloop logout`: forgets the saved sign-in on this computer. Your other sessions, the web app included, stay signed in.
103
+ - `closedloop logout`: forgets the active account's sign-in on this computer (`--as <email>` names another one; `--all` forgets every account). It also cancels sign-ins still in progress for accounts that are not signed in. Your other sessions, the web app included, stay signed in.
104
+
105
+ ## Accounts
106
+
107
+ One computer can stay signed in to several ClosedLoop AI accounts. Each keeps its own session, region, workspace selections and working goal.
108
+
109
+ - `closedloop login <email>` with a new email adds that account and makes it the active one; with the email of an account already signed in, it signs that account in again.
110
+ - `closedloop accounts`: the accounts signed in here, each with its region and workspace, and which one is active. As JSON: `accounts` (`email`, `region`, `workspace`, `api_url`, `active`) and `active_account`.
111
+ - `closedloop use <email>`: makes that account the active one. An account that is not signed in here is refused with `account_not_signed_in`.
112
+ - `--as <email>` runs one command as one of the accounts signed in here, before or after the command, without changing the active one; `CLOSEDLOOP_ACCOUNT=<email>` does the same for every command in that environment, and `--as` wins over it. Agents should name the account explicitly. (`--account` stays what it is in `insights search`: a customer's account domain, as in `closedloop insights search --account acme.com --as you@example.com`.) An account that is not signed in here is refused with `account_not_signed_in`.
113
+ - `closedloop whoami` shows the active account, or the one named with `--as`.
114
+ - Updating from 0.3.3 or earlier moves the saved sign-in into this layout on the first command, once: you stay signed in, it becomes the active account, and its working goal and numbered lists come with it.
101
115
 
102
116
  ## How it looks
103
117
 
@@ -110,6 +124,7 @@ Every command does only what the person may do in the app, and the API decides:
110
124
  ## Settings
111
125
 
112
126
  - `CLOSEDLOOP_API_URL`: the API to talk to. Defaults to the production API (`https://api.closedloop.sh`); existing EU accounts sign in through the EU API automatically. Use `http://localhost:3017` for an API running on your machine. An explicit API selects the deployment for sign-up and skips the production region question. Combining it with `--region` is a usage error; unset it to choose a production region.
127
+ - `CLOSEDLOOP_ACCOUNT`: the signed-in account (its email) to run commands as, instead of the active one; `--as` wins over it.
113
128
  - `CLOSEDLOOP_CONFIG_DIR`: explicitly selects the folder for saved sign-in and settings; it takes precedence over every default.
114
129
  - `XDG_CONFIG_HOME`: when explicitly set, retains the existing `$XDG_CONFIG_HOME/closedloop` location on every platform.
115
130
  - Otherwise the default is `~/.config/closedloop` on Linux, `~/Library/Application Support/closedloop` on macOS, and `%LOCALAPPDATA%\closedloop` on Windows (falling back to the account's `AppData\Local` folder).
@@ -124,7 +139,8 @@ not trigger migration. Treat retained copies and backups as credentials too.
124
139
  The earlier API-key CLI's `config.json` is retained during installation and
125
140
  upgrades, but its team API key does not prove a person's identity: run
126
141
  `closedloop login` to sign in. Existing person sessions from version 0.3.0
127
- are preserved; team API keys are never converted into a person's session.
142
+ are preserved (moved into their account on the first command); team API keys
143
+ are never converted into a person's session.
128
144
 
129
145
  ## Upgrade and troubleshoot
130
146
 
@@ -137,7 +153,7 @@ closedloop whoami --json
137
153
 
138
154
  Upgrading replaces the installed package and preserves the separate config
139
155
  folder. Uninstalling the package also leaves that folder intact; use
140
- `closedloop logout` when you want this computer to forget its current sign-in.
156
+ `closedloop logout` (or `closedloop logout --all`) when you want this computer to forget its sign-ins.
141
157
  Logout also cancels pending email and browser sign-in requests. It does not
142
158
  revoke sessions on other computers or remove retained migration backups.
143
159
 
@@ -147,7 +163,9 @@ minimum version; in that case follow the `upgrade_required` hint. If npm fails
147
163
  during an upgrade, check both commands' versions and repeat the installation
148
164
  before assuming the package changed successfully.
149
165
 
150
- - `not_signed_in` or `session_expired`: run `closedloop login`; the CLI renews an existing session automatically when possible.
166
+ - `not_signed_in` or `session_expired`: run `closedloop login`; the CLI renews an existing session automatically when possible. When other accounts are signed in here, `not_signed_in` names them: `closedloop use <email>` picks one.
167
+ - `account_not_signed_in`: the account named with `use`, `--as` or `CLOSEDLOOP_ACCOUNT` is not signed in here; run `closedloop login <email>` or `closedloop accounts`. `invalid_account`: give the account's email address.
168
+ - `missing_email`: run `closedloop login you@example.com`.
151
169
  - `region_required`: choose `--region us` or `--region eu` before creating a new account in a noninteractive flow. `region_check_failed` means the CLI could not establish whether an account already exists; retry or choose a region explicitly. Existing accounts still sign in in their original region.
152
170
  - `config_invalid`: back up the named JSON file and follow the recovery hint; the error never prints its contents. `closedloop logout` can remove damaged credentials and pending sign-in files.
153
171
  - `config_write_failed`: check folder permissions and free disk space; a failed replacement keeps the previous saved file.