@functional-systems/lambdadb-cli 0.1.7-dev.23 → 0.1.7-dev.25

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 (50) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/CONTRIBUTING.md +29 -0
  3. package/DESIGN.md +9 -3
  4. package/ONBOARDING.md +417 -0
  5. package/README.md +401 -138
  6. package/dist/account.d.ts +50 -0
  7. package/dist/account.js +301 -0
  8. package/dist/account.js.map +1 -0
  9. package/dist/agent-config.d.ts +4 -3
  10. package/dist/agent-config.js +12 -5
  11. package/dist/agent-config.js.map +1 -1
  12. package/dist/agents.d.ts +3 -3
  13. package/dist/agents.js +8 -8
  14. package/dist/agents.js.map +1 -1
  15. package/dist/cli.js +44 -6
  16. package/dist/cli.js.map +1 -1
  17. package/dist/config.d.ts +10 -4
  18. package/dist/config.js +43 -6
  19. package/dist/config.js.map +1 -1
  20. package/dist/credentials.d.ts +29 -0
  21. package/dist/credentials.js +116 -0
  22. package/dist/credentials.js.map +1 -0
  23. package/dist/device-auth.d.ts +16 -0
  24. package/dist/device-auth.js +160 -0
  25. package/dist/device-auth.js.map +1 -0
  26. package/dist/errors.d.ts +7 -0
  27. package/dist/errors.js +35 -1
  28. package/dist/errors.js.map +1 -1
  29. package/dist/init.d.ts +5 -2
  30. package/dist/init.js +58 -33
  31. package/dist/init.js.map +1 -1
  32. package/dist/mcp.js +8 -1
  33. package/dist/mcp.js.map +1 -1
  34. package/dist/projects.d.ts +29 -0
  35. package/dist/projects.js +323 -0
  36. package/dist/projects.js.map +1 -0
  37. package/package.json +6 -2
  38. package/skills/lambdadb/SKILL.md +43 -24
  39. package/skills/lambdadb/references/usage.md +98 -0
  40. package/src/account.ts +351 -0
  41. package/src/agent-config.ts +14 -8
  42. package/src/agents.ts +8 -8
  43. package/src/cli.ts +46 -6
  44. package/src/config.ts +43 -10
  45. package/src/credentials.ts +138 -0
  46. package/src/device-auth.ts +200 -0
  47. package/src/errors.ts +31 -2
  48. package/src/init.ts +50 -31
  49. package/src/mcp.ts +7 -1
  50. package/src/projects.ts +439 -0
package/README.md CHANGED
@@ -1,8 +1,62 @@
1
1
  # LambdaDB CLI
2
2
 
3
- A first, project-scoped CLI for developers, coding agents and CI. It uses
4
- `@functional-systems/lambdadb@0.8.1` for authentication, HTTP, read retries,
5
- pagination, bulk transfers and large response downloads.
3
+ Connect a LambdaDB project, configure coding agents, and import or search data
4
+ from your terminal or CI.
5
+
6
+ - [Quick start](#quick-start)
7
+ - [Install and run](#install-and-run)
8
+ - [First-use setup](#first-use-setup-with-init)
9
+ - [Supported coding agents](#supported-coding-agents)
10
+ - [Account and project management](#account-and-project-management)
11
+ - [Configuration and authentication](#configuration-and-authentication)
12
+ - [Query existing data](#query-existing-data)
13
+ - [Command examples](#command-examples)
14
+ - [Output and exit codes](#output-deadlines-and-exit-codes)
15
+ - [Development](#development-and-boundaries)
16
+
17
+ ## Quick start
18
+
19
+ Requires Node.js 22.14 or newer and npm. Run from your repository root:
20
+
21
+ ```sh
22
+ npx @functional-systems/lambdadb-cli@latest init
23
+ ```
24
+
25
+ If the CLI is already installed, run `lambdadb init` instead. Both entry points
26
+ use the same package and executable. The command examples below assume an
27
+ installed `lambdadb`; with npx, replace that prefix with
28
+ `npx @functional-systems/lambdadb-cli@latest`.
29
+
30
+ 1. Choose Console signup/login or connect an existing project with an API-key
31
+ environment variable.
32
+ 2. For browser setup, sign up or sign in, compare the terminal code, and approve
33
+ **CLI Login**. Return to the terminal to select an Org and project or explicitly
34
+ create a project with a name and region.
35
+ 3. Choose coding agents, project/user scope, and whether to enable MCP write
36
+ tools. Review the displayed paths before approving the file changes.
37
+ 4. After the connection check, restart or reload the selected agents and follow
38
+ the generated first-query guidance.
39
+
40
+ Init checks authentication and collection-list access. It does not create
41
+ collections or documents, and success does not establish search readiness.
42
+ For an existing collection, try this prompt in your agent:
43
+
44
+ > Prefer the LambdaDB CLI with JSON output and my selected configuration file;
45
+ > use MCP if terminal execution is unavailable or I request it. List collections,
46
+ > inspect the chosen collection's index, and read a small sample at my selected
47
+ > ref before searching an indexed field. Do not create or modify data.
48
+
49
+ The installed skill prefers an available, authenticated CLI and keeps the same
50
+ target when using MCP instead. Its usage reference covers recent-write visibility,
51
+ query examples, pagination, result interpretation and error recovery. CLI defaults
52
+ can differ from an existing MCP entry; check the target before switching. A recent
53
+ empty read is not by itself an error: eligible ordinary writes can be read with
54
+ `consistentRead:true` on a direct branch, separately from committed index checks.
55
+
56
+ Browser setup requires matching Backend and Console support and an accessible
57
+ OS credential store. If either is unavailable, use
58
+ [environment-variable setup](#environment-variable-setup). For CI or a
59
+ non-interactive shell, use [non-interactive init](#non-interactive-setup).
6
60
 
7
61
  ## Install and run
8
62
 
@@ -46,113 +100,139 @@ disabling trust checks. See the
46
100
  [maintainer guide](https://github.com/lambdadb/lambdadb-cli/tree/develop/packaging/homebrew#readme)
47
101
  for packaging and validation details.
48
102
 
49
- ### Build from source
50
-
51
- Requires Node.js 22.14 or newer and npm. From a checkout of this repository:
103
+ ## First-use setup with `init`
52
104
 
53
- ```sh
54
- npm ci
55
- npm run build
56
- node dist/cli.js --help
57
- ```
105
+ ### Connect or reuse a project
58
106
 
59
- Run commands with `node dist/cli.js`, or install the built directory into a local
60
- prefix to use the `lambdadb` executable:
107
+ On a first run, init offers browser setup or an existing environment-held key.
108
+ Reruns reuse the saved connection. To select or create a project through account
109
+ login, run `lambdadb init --connect`; previously saved project keys are reused.
110
+ For SSH or a host without a visible browser, run:
61
111
 
62
112
  ```sh
63
- npm install --prefix "$HOME/.local" /absolute/path/to/lambdadb-cli
64
- export PATH="$HOME/.local/node_modules/.bin:$PATH"
65
- lambdadb --help
113
+ lambdadb init --connect --no-browser
66
114
  ```
67
115
 
68
- `npm start -- ...` also works for human use. For machine-readable stdout, invoke
69
- `node dist/cli.js ... --json` or the executable directly; npm may print banners.
70
-
71
- ## Configuration and authentication
116
+ Approve CLI Login in Console after Google/email signup or login. The printed URL
117
+ and code also work in a browser on another device. Project selection and creation
118
+ continue in the terminal. A default Org is created only on first project
119
+ submission. Pending invitations require a Console decision first; the survey is
120
+ optional.
72
121
 
73
- Obtain the endpoint, existing project name and project API key from the LambdaDB
74
- Console. This CLI does not create projects or issue keys. Endpoint is the API
75
- origin, such as `https://api.lambdadb.ai`, without `/projects/...`. HTTPS is
76
- required, except HTTP on localhost/127.0.0.1/::1 for local testing.
122
+ ### Project limits and manual Console steps
77
123
 
78
- ```sh
79
- lambdadb configure --endpoint https://api.lambdadb.ai --project YOUR_DEV_PROJECT
80
- ```
81
-
82
- Set `LAMBDADB_API_KEY` through your shell's secure input or your CI secret manager.
83
- For example, in Bash, this avoids putting the value into shell history:
84
-
85
- ```bash
86
- read -r -s -p 'LambdaDB project API key: ' LAMBDADB_API_KEY
87
- printf '\n'
88
- export LAMBDADB_API_KEY
89
- ```
124
+ The remaining manual Console steps are signup/login and deliberate CLI approval,
125
+ invitation decisions when present, and any billing activation. If the Org has
126
+ reached its project limit, init offers existing projects and an Org-specific
127
+ billing link. Only the owner can activate billing. After billing, choose retry to
128
+ read the server's updated limits; opening the link does not upgrade or charge.
129
+ New Orgs normally start at one project, but CLI always uses the backend's actual
130
+ limit, including paid/custom limits. A provisioning project can be selected on a
131
+ later run; do not create another project to resume. Device approval expires after
132
+ 15 minutes and provisioning waits up to ten minutes. Remote MCP is outside this
133
+ setup; agents use the existing stdio MCP package.
90
134
 
91
- ### First-use setup with `init`
135
+ ### Non-interactive setup
92
136
 
93
- After securely exporting the key, run either entry point. Both use this same
94
- package and executable:
137
+ Inject a project key securely, then explicitly select agents and scope:
95
138
 
96
139
  ```sh
97
- lambdadb init
98
- npx @functional-systems/lambdadb-cli@latest init
140
+ # Inject LAMBDADB_API_KEY securely before running this command.
141
+ lambdadb init --non-interactive --agents codex,claude,cursor --scope project \
142
+ --endpoint https://api.lambdadb.ai --project YOUR_PROJECT --json
99
143
  ```
100
144
 
101
- `init` guides you through the existing project's endpoint, name and API-key
102
- environment-variable name. It detects Codex, Claude Code, Cursor, VS Code,
103
- Gemini CLI, OpenCode, GitHub Copilot CLI, Kiro IDE/CLI and the Cline VS Code
104
- extension using PATH and configuration directories, then lets you choose any subset (or `none`),
105
- project/user scope, and whether to enable MCP write tools. Detection is a hint,
106
- not proof that an agent is installed or connected. Project scope means the
107
- current working directory; run from your repository root.
108
- Cursor detection recognizes both the editor's `cursor` command and the
109
- `cursor-agent` CLI, which reads the same MCP configuration. With Cursor CLI,
110
- check the generated server with `cursor-agent mcp list-tools lambdadb`.
111
-
112
- The remaining manual step is in [LambdaDB Console](https://console.lambdadb.ai):
113
- select an existing project and obtain its API endpoint, project name and project
114
- API key. Inject the key into your shell or secret manager before running init.
115
- There is no browser login, account/project creation, key issuance, remote MCP,
116
- or backend/Console change in this flow. Init never asks for the key value and
117
- does not load or write `.env` files.
118
-
119
- For automation, explicitly select both agents and scope:
145
+ To configure only the CLI, use `--agents none`. This example expects the key in
146
+ `MY_PROJECT_KEY` instead of `LAMBDADB_API_KEY`; inject that variable securely
147
+ before running it:
120
148
 
121
149
  ```sh
122
- # Inject LAMBDADB_API_KEY securely before running this command.
123
- lambdadb init --non-interactive --agents codex,claude,cursor --scope project \
124
- --endpoint https://api.lambdadb.ai --project YOUR_PROJECT --json
125
- # Configure only the CLI, without changing agent files:
126
150
  lambdadb init --non-interactive --agents none --scope project \
127
151
  --endpoint https://api.lambdadb.ai --project YOUR_PROJECT --api-key-env MY_PROJECT_KEY
128
152
  ```
129
153
 
130
- `--agents` accepts a comma-separated subset of
131
- `codex,claude,cursor,vscode,gemini,opencode,copilot,kiro,cline` or `none`. For example:
154
+ `--agents` accepts comma-separated values from the
155
+ [supported agents](#supported-coding-agents) table, or `none`. Once connection
156
+ settings are saved, you can reuse them:
132
157
 
133
158
  ```sh
134
159
  lambdadb init --non-interactive --agents vscode,gemini,opencode --scope project
135
160
  lambdadb init --non-interactive --agents copilot,kiro,cline --scope user
136
161
  ```
137
162
 
138
- This example reuses your existing CLI settings and environment-held key.
139
- `--scope` accepts `project` or `user`. `--write-tools` explicitly enables MCP
140
- write tools; omission disables them, including on reruns and when the inherited
141
- `LAMBDADB_MCP_ENABLE_WRITE_TOOLS` environment variable is true. The normal global
142
- `--config`, `--endpoint`, `--project`, `--api-key-env`, and `--timeout-ms` flags
143
- apply. Existing settings/environment precedence is unchanged. Non-TTY and
144
- `--json` runs require `--non-interactive`; missing choices, target or key fail
145
- with exit 2 and instructions, without prompting. This mode authorizes applying
163
+ These two examples reuse existing CLI settings and an OS-stored or
164
+ environment-held key. `--scope` accepts `project` or `user`. `--write-tools`
165
+ explicitly enables MCP write tools; omission disables them, including on reruns and when the inherited
166
+ `LAMBDADB_MCP_ENABLE_WRITE_TOOLS` environment variable is true.
167
+
168
+ The global `--config`, `--endpoint`, `--project`, `--api-key-env`, and
169
+ `--timeout-ms` flags apply to existing-credential setup. `--connect` instead
170
+ chooses its target in the terminal after account login. It cannot be combined
171
+ with explicit endpoint/project/key-reference flags and requires an interactive
172
+ terminal. Non-interactive setup never starts browser authorization or requests
173
+ a key. Non-TTY and `--json` runs require `--non-interactive`; missing choices,
174
+ target or key fail with exit 2 and instructions, without prompting. This mode authorizes applying
146
175
  the displayed file plan; it does not silently select detected agents.
147
- Cline's extension supports only user-scope MCP settings. Selecting `cline` with
148
- `--scope project` fails before any file writes or connection; interactive setup
149
- offers user scope when Cline is selected. It never silently broadens the scope.
150
176
 
151
- Before writing, init displays exact paths and create/update/unchanged actions,
152
- then uses the same SDK check as `doctor` to verify authentication and collection-list
153
- access. Failed validation/authentication leaves files untouched. The CLI's
177
+ Cline's extension supports only user-scope MCP settings. Selecting `cline` with
178
+ `--scope project` rejects agent installation; interactive setup offers user scope
179
+ when Cline is selected. It never silently broadens the scope. A browser-approved
180
+ connection may already be saved before agent choices are validated, as described
181
+ under [files and safe reruns](#files-and-safe-reruns). Rerun without `--connect`
182
+ to finish setup.
183
+
184
+ ### Files and safe reruns
185
+
186
+ Before agent installation, init displays exact paths and create/update/unchanged
187
+ actions, then uses the same SDK check as `doctor` to verify authentication and
188
+ collection-list access. Manual setup leaves files untouched on failed validation.
189
+ Browser setup first shows and confirms the CLI settings path and credential store;
190
+ once approved, it saves that connection before doctor/agent installation so a
191
+ failed check or interrupted agent setup can resume without issuing another key.
192
+ Agent files are still untouched until the reviewed plan and check succeed. The CLI's
154
193
  non-secret settings always use its usual configuration path (or `--config`),
155
- independently of agent scope:
194
+ independently of agent scope.
195
+
196
+ Unrelated configuration and comments are preserved where JSONC is accepted.
197
+ Copilot and Cline settings must be strict JSON for init; comments/trailing
198
+ commas cause an actionable failure and leave the file untouched. Shared files
199
+ (such as Claude/Copilot project MCP and VS Code/Copilot skills) are written only
200
+ once when both agents request identical contents; conflicting changes stop
201
+ before connection or writes. Symbolic links are preserved: init displays the
202
+ resolved write target and updates it once. Links with missing targets fail before
203
+ connection or writes; restore their targets before rerunning init.
204
+
205
+ Reruns update only recognizable init-generated `lambdadb` MCP entries;
206
+ existing custom entries or additions inside a generated entry cause an actionable
207
+ conflict. Existing skills and reference files are preserved, including user edits.
208
+ New skills include `references/usage.md`; an unchanged current bundled skill can
209
+ also have its missing reference restored on rerun. Custom or older skill bodies
210
+ are left intact. To reinstall the bundled version, back up the skill directory
211
+ and remove only the files you want init to reinstall. Writes use
212
+ atomic replacement per file, not a transaction across files: a disk/permission
213
+ failure can leave a partial installation; inspect the displayed paths and rerun.
214
+
215
+ ## Supported coding agents
216
+
217
+ Init detects agents using PATH and configuration directories, then lets you choose
218
+ any subset or `none`. Detection is a hint, not proof that an agent is installed or
219
+ connected. Project scope means the current working directory, so run from your
220
+ repository root. Cline supports user scope only.
221
+
222
+ | Agent | `--agents` value | Supported scope |
223
+ | --- | --- | --- |
224
+ | Codex | `codex` | Project or user |
225
+ | Claude Code | `claude` | Project or user |
226
+ | Cursor editor/CLI | `cursor` | Project or user |
227
+ | VS Code | `vscode` | Project or user |
228
+ | Gemini CLI | `gemini` | Project or user |
229
+ | OpenCode | `opencode` | Project or user |
230
+ | GitHub Copilot CLI | `copilot` | Project or user |
231
+ | Kiro IDE/CLI | `kiro` | Project or user |
232
+ | Cline VS Code extension | `cline` | User only |
233
+
234
+ <details>
235
+ <summary>MCP and skill paths, agent-specific overrides and reload instructions</summary>
156
236
 
157
237
  | Agent | Project MCP / skill | User MCP / skill |
158
238
  | --- | --- | --- |
@@ -166,6 +246,10 @@ independently of agent scope:
166
246
  | Kiro IDE/CLI | `.kiro/settings/mcp.json` / `.kiro/skills/lambdadb/SKILL.md` | `~/.kiro/settings/mcp.json` / `~/.kiro/skills/lambdadb/SKILL.md` |
167
247
  | Cline VS Code extension | Unsupported; choose user scope | VS Code user profile `globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json` / `~/.cline/skills/lambdadb/SKILL.md` |
168
248
 
249
+ Cursor detection recognizes both the editor's `cursor` command and the
250
+ `cursor-agent` CLI, which reads the same MCP configuration. With Cursor CLI,
251
+ check the generated server with `cursor-agent mcp list-tools lambdadb`.
252
+
169
253
  When `CLAUDE_CONFIG_DIR` is set, Claude's user MCP file is
170
254
  `$CLAUDE_CONFIG_DIR/.claude.json` and its user skill is under
171
255
  `$CLAUDE_CONFIG_DIR/skills/lambdadb/SKILL.md`.
@@ -195,34 +279,29 @@ Copilot CLI is separate from the VS Code adapter. It reads `mcpServers`, not
195
279
  VS Code's `servers` map. Project setup reuses `.mcp.json` if present, otherwise
196
280
  an existing `.github/mcp.json`, otherwise creates `.mcp.json`. Both wrapped
197
281
  `mcpServers` and existing bare server maps are preserved. `COPILOT_HOME` overrides
198
- the user MCP and skill directory. Restart with the selected key in the launch
199
- environment, trust the repository, check `/mcp`, and run `/skills reload`.
282
+ the user MCP and skill directory. Restart, trust the repository, check `/mcp`,
283
+ and run `/skills reload`. In environment mode, include the selected key variable
284
+ in the launch environment. In OS-store mode, run as the same OS user with the
285
+ recorded store unlocked and accessible; no key environment variable is required.
200
286
 
201
287
  Kiro IDE and CLI share one `kiro` adapter; detection recognizes both `kiro` and
202
- `kiro-cli` executables. Approve the selected key variable in **Mcp Approved Env
203
- Vars** when prompted. For a custom Kiro agent, ensure it includes the MCP JSON
204
- and skill resources; init does not edit agent definitions or grant tool approvals.
288
+ `kiro-cli` executables. In environment mode, supply the selected key variable
289
+ and approve it in **Mcp Approved Env Vars** when prompted. In OS-store mode,
290
+ run as the same OS user with access to the unlocked recorded store; no key
291
+ variable approval is needed. For a custom Kiro agent, ensure it includes the
292
+ MCP JSON and skill resources; init does not edit agent definitions or grant tool approvals.
205
293
 
206
294
  The `cline` adapter targets the Cline extension in the default stable VS Code
207
295
  user profile, using the same platform/portable user directory rules above.
208
- Reload VS Code from an environment containing the selected key and inspect
209
- Cline's MCP Servers and Skills menus. Cline CLI, other editors and named profiles
296
+ Reload VS Code and inspect Cline's MCP Servers and Skills menus. In environment
297
+ mode, launch VS Code with the selected key variable. In OS-store mode, use the
298
+ same OS user with access to the unlocked recorded store; no key environment
299
+ variable is required. Cline CLI, other editors and named profiles
210
300
  use different configuration locations and are outside this adapter's scope.
211
301
 
212
- Unrelated configuration and comments are preserved where JSONC is accepted.
213
- Copilot and Cline settings must be strict JSON for init; comments/trailing
214
- commas cause an actionable failure and leave the file untouched. Shared files
215
- (such as Claude/Copilot project MCP and VS Code/Copilot skills) are written only
216
- once when both agents request identical contents; conflicting changes stop
217
- before connection or writes. Symbolic links are preserved: init displays the
218
- resolved write target and updates it once. Links with missing targets fail before
219
- connection or writes; restore their targets before rerunning init.
220
- Reruns update only recognizable init-generated `lambdadb` MCP entries;
221
- existing custom entries or additions inside a generated entry cause an actionable
222
- conflict. Existing skills are preserved, including user edits; remove the skill
223
- file deliberately if you want to reinstall the bundled version. Writes use
224
- atomic replacement per file, not a transaction across files: a disk/permission
225
- failure can leave a partial installation; inspect the displayed paths and rerun.
302
+ </details>
303
+
304
+ ### MCP launch and credential forwarding
226
305
 
227
306
  Agent settings launch `npx -y @functional-systems/lambdadb-cli@<installed-version> mcp`,
228
307
  which runs the existing `@functional-systems/lambdadb-mcp@0.1.5` stdio package.
@@ -233,11 +312,16 @@ may download both packages and requires npm registry access.
233
312
  After upgrading the CLI, rerun init for the same agents and scope to refresh
234
313
  their exact CLI version pin, then restart/reload the agent with the key available.
235
314
 
236
- The `mcp` bridge reads the selected key from the agent environment at startup and
237
- maps CLI endpoint/project/key to MCP's `LAMBDADB_BASE_URL`,
315
+ The `mcp` bridge reads the selected OS credential reference or environment
316
+ variable at startup and maps CLI endpoint/project/key to MCP's `LAMBDADB_BASE_URL`,
238
317
  `LAMBDADB_PROJECT_NAME`, and `LAMBDADB_PROJECT_API_KEY`. The bridge sets
239
318
  `LAMBDADB_MCP_ENABLE_WRITE_TOOLS` explicitly. No key value is placed in arguments
240
- or configuration. Codex uses `env_vars` to forward the selected variable;
319
+ or agent configuration. OS references need the same OS user and an accessible
320
+ credential store, with no shell key export. Linux Secret Service also needs access
321
+ to the desktop/user D-Bus session; Codex forwards its non-secret
322
+ `DBUS_SESSION_BUS_ADDRESS` and `XDG_RUNTIME_DIR` names when supplied. Launch other
323
+ agents with that session available, and allow those variables if the agent filters
324
+ its environment. For environment-mode connections, Codex uses `env_vars` to forward the selected variable;
241
325
  Claude, Gemini, Copilot and Kiro use `${VAR}`; Cursor, VS Code and Cline use `${env:VAR}`; and
242
326
  OpenCode uses `{env:VAR}` environment references. Gemini's explicit `env` entry
243
327
  also forwards the key through its inherited-environment sanitization. An unresolved
@@ -247,25 +331,8 @@ after setup or credential changes, check `/mcp` in Codex/Claude or Cursor's MCP
247
331
  settings, and approve/trust project settings if prompted. Higher-priority agent
248
332
  settings or organization policies may override or block these files.
249
333
 
250
- The no-secret-persistence contract covers files written by this CLI. Agents
251
- manage their own runtime storage; for example, Codex shell snapshots can capture
252
- the launch environment. Review your agent's environment/snapshot settings and
253
- protect its runtime directory when forwarding a project key.
254
-
255
- Init does not query documents or create collections/data. Connection success does
256
- not establish search readiness. Its result includes a read-only agent prompt:
257
- list collections, inspect the selected collection's index configuration, then
258
- read up to five documents at `branch:main` with `query` omitted before searching
259
- an actual indexed field. Without an agent, run `lambdadb collections list --json`,
260
- choose an existing collection, save `{"size":5}` in `first-query.json`, and run:
261
-
262
- ```sh
263
- lambdadb collections describe --collection YOUR_COLLECTION --json
264
- lambdadb query --collection YOUR_COLLECTION --ref branch:main --file first-query.json --json
265
- ```
266
-
267
- An empty project needs deliberately supplied data outside init. Empty results
268
- are not evidence of indexing failure or readiness.
334
+ <details>
335
+ <summary>Official agent documentation used for format checks</summary>
269
336
 
270
337
  Agent formats were checked against official documentation on 2026-10-24:
271
338
  [Codex MCP](https://developers.openai.com/codex/mcp),
@@ -292,9 +359,139 @@ Agent formats were checked against official documentation on 2026-10-24:
292
359
  Generated settings still require
293
360
  verification in the actual agent; local contract tests simulate that boundary.
294
361
 
295
- No command accepts a raw key argument. Configuration stores only `endpoint`,
296
- `project` and `apiKeyEnv`. Keys are read from the selected environment variable at
297
- runtime and are never persisted by this CLI. Environment variables are still
362
+ </details>
363
+
364
+ ## Account and project management
365
+
366
+ These commands use a saved account login, independently of project API-key
367
+ configuration. They never prompt for missing arguments. `login` deliberately
368
+ waits for browser approval and prints a URL usable on another device; it does not
369
+ prompt on stdin. Use the same `--config` path throughout if overriding it.
370
+
371
+ ```sh
372
+ lambdadb login --no-browser
373
+ lambdadb orgs list --json
374
+ lambdadb projects regions --json
375
+ lambdadb projects list --org ORG_UUID --json
376
+ lambdadb projects create --org ORG_UUID --name my-project --region REGION --json
377
+ # For a new account with no Org, choose --default-org instead of --org.
378
+ lambdadb projects list --org ORG_UUID --json # wait until ACTIVE
379
+ lambdadb projects use --org ORG_UUID --project-id PROJECT_UUID --issue-key
380
+ lambdadb doctor
381
+ # Later switches reuse a previously saved key without --issue-key:
382
+ lambdadb projects use --org ORG_UUID --project-id PROJECT_UUID
383
+ lambdadb logout
384
+ ```
385
+
386
+ `create` requires exactly one of `--org UUID` or `--default-org`, plus `--name`
387
+ and `--region`. Creation does not select the CLI default or install agents.
388
+ `use` requires both IDs; first connection or deliberate key replacement requires
389
+ `--issue-key` and owner/admin key-management permission. Saved project keys are
390
+ reused without that flag. `projects use` changes only the CLI default: existing
391
+ agent entries stay pinned until you rerun `init` and approve their file plan.
392
+ Expired, missing or unreadable account credentials fail with login/unlock guidance;
393
+ ordinary management commands never start browser login automatically.
394
+
395
+ ### Limits and failures
396
+
397
+ The API-key environment path remains available without account login. Management
398
+ requests do not follow redirects and never retry writes. `--timeout-ms` overrides
399
+ `LAMBDADB_TIMEOUT_MS` (default `30000`, range 1–3600000 milliseconds). For account
400
+ login, logout and project/Organization management, this limits each HTTP request,
401
+ including its response body; sequential requests each receive a fresh budget.
402
+ It does not limit time spent at prompts, the server-issued browser authorization
403
+ window (up to 15 minutes), or project provisioning polling (up to 10 minutes).
404
+ For data API commands such as `doctor`, `query` and `docs import`, it remains a
405
+ shared command budget across sequential requests, retries and transfers. During
406
+ `init --connect`, management uses per-request limits and the subsequent doctor
407
+ check receives its own data API budget.
408
+ A project-limit error includes `organization.max_projects`, `projects_count`,
409
+ `can_upgrade`, and `billing_url` in JSON, plus the link in terminal diagnostics.
410
+ A transport failure or HTTP 408/5xx response to a management mutation, or uncertain
411
+ key delivery (including an incomplete successful issuance response) exits 5
412
+ with `data.state: "unknown"`; inspect existing projects
413
+ or the displayed named key in Console before explicitly retrying.
414
+
415
+ ### Session recovery
416
+
417
+ Account metadata and the per-project connection cache live beside the resolved
418
+ CLI config file as `.account.json` and `.connections.json` suffixes. They contain
419
+ no secrets. The `.management.lock` suffix serializes local login/selection work;
420
+ if a process was killed, confirm it is no longer running before removing its
421
+ stale lock. `logout` needs the saved OS entry and server connectivity to confirm
422
+ revocation; otherwise it retains metadata and fails with an actionable error.
423
+ Undelivered/unavailable account sessions expire within seven days. Project keys
424
+ have their existing lifetime; logout does not revoke them. Explicit replacement
425
+ retains older project entries for agents still pinned to them; revoke unused keys
426
+ in Console and remove their local reference deliberately.
427
+
428
+ ## Configuration and authentication
429
+
430
+ ### Environment-variable setup
431
+
432
+ For an existing project or CI, obtain its endpoint, project name and API key from
433
+ [LambdaDB Console](https://app.lambdadb.ai). No account login is required for this
434
+ path. The endpoint is the API origin, such as `https://api.lambdadb.ai`, without
435
+ `/projects/...`. HTTPS is required, except HTTP on localhost/127.0.0.1/::1 for
436
+ local testing.
437
+
438
+ ```sh
439
+ lambdadb configure --endpoint https://api.lambdadb.ai --project YOUR_DEV_PROJECT
440
+ ```
441
+
442
+ Set `LAMBDADB_API_KEY` through your shell's secure input or your CI secret manager.
443
+ For example, in Bash, this avoids putting the value into shell history:
444
+
445
+ ```bash
446
+ read -r -s -p 'LambdaDB project API key: ' LAMBDADB_API_KEY
447
+ printf '\n'
448
+ export LAMBDADB_API_KEY
449
+ ```
450
+
451
+ `init` never accepts a key value in a prompt or flag and never loads or writes
452
+ `.env` files. Keep keys out of chat, shell history and source files.
453
+
454
+ For development deployments, select the account API origin with
455
+ `--api-url https://api-dev.lambdadb.ai`. Later login renewal reuses that saved
456
+ origin unless explicitly overridden; the server supplies its configured Console
457
+ URL. HTTPS is required except for loopback tests.
458
+
459
+ ### OS credential storage
460
+
461
+ Account login and project credentials use separate OS credential-store namespaces.
462
+ The opaque account session expires after seven days and is valid only for CLI
463
+ management routes. It is never sent to MCP or agents, and is not a Console JWT or
464
+ refresh token. Run `login` again to renew it; `logout` revokes it immediately and
465
+ preserves project keys. Project settings and agent files contain only references.
466
+ Use `--credential-store auto` (default),
467
+ `keychain`, `windows`, `secret-service`, or `keyutils` to select an available OS
468
+ backend. Linux auto selection tries Secret Service, then kernel keyutils for a
469
+ new connection. Kernel storage is a cache: reboot/expiry may remove it. Existing
470
+ references always use their recorded backend; failure never silently switches
471
+ stores or issues another key. There is no plaintext-file fallback.
472
+
473
+ To remove the current connection's local OS key, run `lambdadb credentials remove`.
474
+ It leaves metadata and agent references intact and does **not** revoke the server
475
+ key. Revoke unused keys in Console under Project API Keys, using the saved key
476
+ name/ID. Explicit reconnection creates a fresh credential slot; it does not revoke
477
+ or delete older slots that other agents might still use. If key delivery or local
478
+ storage fails after approval, inspect the named `lambdadb-cli-...` key in Console
479
+ and revoke it if unused before reconnecting. Requests are never blindly retried
480
+ across an uncertain key-issuance response.
481
+
482
+ The no-plaintext-secret-persistence contract covers CLI and agent configuration
483
+ files. Browser setup deliberately persists the project key only in the selected
484
+ OS store. Environment mode does not persist a key. Agents
485
+ manage their own runtime storage; for example, Codex shell snapshots can capture
486
+ the launch environment. Review your agent's environment/snapshot settings and
487
+ protect its runtime directory when forwarding a project key.
488
+
489
+ ### Settings and precedence
490
+
491
+ No command accepts a raw key argument. Environment-mode configuration stores `endpoint`,
492
+ `project` and `apiKeyEnv`. Browser setup adds `credentialStore`, `credentialId`,
493
+ `credentialKeyId` and `credentialKeyName`, all non-secret metadata. Keys are read
494
+ from the selected environment variable or OS store at runtime. Environment variables are still
298
495
  accessible to the current process and appropriately privileged local processes;
299
496
  the CLI is not a secret vault. Avoid shell tracing around secret injection.
300
497
 
@@ -310,9 +507,9 @@ Use a CI secret manager instead of adding credentials to tracked files.
310
507
  | Endpoint | `--endpoint`, `LAMBDADB_ENDPOINT`, saved `endpoint` |
311
508
  | Project | `--project`, `LAMBDADB_PROJECT`, saved `project` |
312
509
  | Key variable name | `--api-key-env`, `LAMBDADB_API_KEY_ENV`, saved `apiKeyEnv`, `LAMBDADB_API_KEY` |
313
- | Key value | Value of the selected variable only; no fallback to another key |
510
+ | Key value | Explicit `--api-key-env` / `LAMBDADB_API_KEY_ENV` selects environment mode; otherwise use a saved OS reference when present, else the selected variable. An explicit OS reference from generated agent arguments stays bound to its store. No automatic fallback on read failure. |
314
511
  | Config path | `--config`, `LAMBDADB_CONFIG`, default user path |
315
- | Network budget | `--timeout-ms`, `LAMBDADB_TIMEOUT_MS`, `30000` milliseconds |
512
+ | Network timeout (scope above) | `--timeout-ms`, `LAMBDADB_TIMEOUT_MS`, `30000` milliseconds |
316
513
 
317
514
  There is no implicit endpoint, project, collection, branch or read ref. Explicit
318
515
  empty values fail validation instead of silently falling back. An explicitly
@@ -328,6 +525,8 @@ lambdadb configure --api-key-env MY_PROJECT_KEY
328
525
  lambdadb doctor --json
329
526
  ```
330
527
 
528
+ ### Check the connection with doctor
529
+
331
530
  `doctor` validates configuration and uses `listCollections({size: 1})` to check
332
531
  authentication and project collection-list access. Success does not prove write
333
532
  permissions, collection readiness, or search visibility. Failure provides a safe
@@ -336,12 +535,40 @@ error category and a recovery hint. SDK debug logging is disabled even when
336
535
  are not printed. The active key is redacted if echoed inside returned data.
337
536
  Other document data remains visible; redirect results to appropriate storage.
338
537
 
339
- ## First-use flow
538
+ ## Query existing data
539
+
540
+ Init does not query documents or create collections/data. Connection success does
541
+ not establish search readiness. The setup result includes a read-only agent
542
+ prompt. To inspect data directly, list collections and choose an existing
543
+ collection:
544
+
545
+ ```sh
546
+ lambdadb collections list --json
547
+ lambdadb collections describe --collection YOUR_COLLECTION --json
548
+ ```
549
+
550
+ Save `{"size":5}` in `first-query.json`, then read up to five documents:
551
+
552
+ ```sh
553
+ lambdadb query --collection YOUR_COLLECTION --ref branch:main --file first-query.json --json
554
+ ```
555
+
556
+ Omitting `query` reads sample documents. Inspect the index configuration before
557
+ searching an actual indexed field.
558
+
559
+ An empty project needs deliberately supplied data outside init. Empty results
560
+ are not evidence of indexing failure or readiness.
561
+
562
+ ## Command examples
563
+
564
+ The JSON files below are included in the package under `examples/`.
565
+
566
+ ### Try sample data in a development project
340
567
 
341
568
  Only run the following against a project explicitly designated for development.
342
- Configuration and the API key must already be supplied as above. Replace
343
- `cli-demo-docs` with a new, unique collection name. Each JSON example is included
344
- in this repository.
569
+ Connect to the project first, then replace `cli-demo-docs` with a new, unique
570
+ collection name. These commands create a collection and write sample documents;
571
+ `init` does neither.
345
572
 
346
573
  ```sh
347
574
  lambdadb doctor
@@ -382,7 +609,11 @@ Both create and update take the index map itself through `--index-config`, not a
382
609
  full request body. Updates are subject to server index-change restrictions and
383
610
  return `state: "updated"`, `searchable: "not_verified"`; acceptance does not prove
384
611
  query readiness.
385
- SDK 0.7.0 accepts 49 fixed lowercase text analyzer presets:
612
+
613
+ <details>
614
+ <summary>Text analyzer presets</summary>
615
+
616
+ The CLI accepts 49 fixed lowercase text analyzer presets:
386
617
  `standard`, `english`, `korean`, `japanese`, `chinese`, `cjk`, `arabic`,
387
618
  `french`, `german`, `hindi`, `indonesian`, `italian`, `portuguese`, `russian`,
388
619
  `spanish`, `turkish`, `armenian`, `basque`, `bengali`, `brazilian`, `bulgarian`,
@@ -398,6 +629,8 @@ analyzer does not confer keyword field sorting/facets. Nepali/Tamil/Telugu are
398
629
  Lucene extensions, not common Elasticsearch/OpenSearch support. See the
399
630
  [SDK analyzer contract](https://github.com/lambdadb/lambdadb-typescript-client/blob/v0.7.0/docs/models/analyzer.md).
400
631
 
632
+ </details>
633
+
401
634
  ### Native embeddings and Bayesian search
402
635
 
403
636
  ```sh
@@ -649,6 +882,33 @@ npm bootstrap, Trusted Publishing and release checks. CI validates Node.js 22
649
882
  and 24 using local contracts and the same CLI contracts against an installed
650
883
  tarball.
651
884
 
885
+ ### Build from source
886
+
887
+ Requires Node.js 22.14 or newer and npm. From a checkout of this repository:
888
+
889
+ ```sh
890
+ npm ci
891
+ npm run build
892
+ node dist/cli.js --help
893
+ ```
894
+
895
+ Run commands with `node dist/cli.js`, or install the built directory into a local
896
+ prefix to use the `lambdadb` executable:
897
+
898
+ ```sh
899
+ npm install --prefix "$HOME/.local" /absolute/path/to/lambdadb-cli
900
+ export PATH="$HOME/.local/node_modules/.bin:$PATH"
901
+ lambdadb --help
902
+ ```
903
+
904
+ `npm start -- ...` also works for human use. For machine-readable stdout, invoke
905
+ `node dist/cli.js ... --json` or the executable directly; npm may print banners.
906
+
907
+ ### Run checks
908
+
909
+ This CLI uses `@functional-systems/lambdadb@0.8.1` for authentication, HTTP,
910
+ read retries, pagination, bulk transfers and large response downloads.
911
+
652
912
  ```sh
653
913
  npm run lint
654
914
  npm run check:version
@@ -664,10 +924,13 @@ They do not contact a LambdaDB service. See [DESIGN.md](DESIGN.md) for contract
664
924
  decisions and [CONTRIBUTING.md](CONTRIBUTING.md#validation-scope) for validation
665
925
  methods and their limits.
666
926
 
667
- This MVP intentionally omits Branch/Tag/Alias management: default `main` supports
668
- first use, while reads can select existing refs. It also omits Console management,
669
- remote MCP, Git collection, chunking, embedding workflows, code-search logic, delete,
670
- plugins and publication. There are no changes to the SDK or reference repositories.
927
+ ### Scope and live validation
928
+
929
+ The CLI supports account login and Org/project setup, plus project-scoped data
930
+ commands. Billing, membership management and account deletion stay in Console.
931
+ Branch/Tag/Alias management, remote MCP, Git collection, chunking, code-search
932
+ workflows, data deletion and plugins are outside this CLI's current scope. Reads
933
+ can select existing refs. This change does not modify the SDK or MCP package.
671
934
 
672
935
  Live verification requires an explicitly designated development project, endpoint
673
936
  and project key. Do not discover or borrow credentials from another repository.