@senso-ai/cli 0.2.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 (4) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +422 -0
  3. package/dist/cli.js +1503 -0
  4. package/package.json +53 -0
package/README.md ADDED
@@ -0,0 +1,422 @@
1
+ # Senso CLI
2
+
3
+ > Infrastructure for the Agentic Web
4
+
5
+ The official command-line interface for [Senso](https://docssenso.ai). Search your knowledge base, manage content, and control your entire Senso organization — directly from the terminal.
6
+
7
+ Built for **AI agents** (Claude Code, Gemini CLI, Codex) and **developers** who want fast, scriptable access to their Senso workspace.
8
+
9
+ ---
10
+
11
+ ## Quick Install
12
+
13
+ Requires **Node.js 18+**. Works on **Linux**, **macOS**, and **Windows**.
14
+
15
+ ```bash
16
+ npm install -g @senso-ai/cli
17
+ ```
18
+
19
+ Verify it works:
20
+
21
+ ```bash
22
+ senso --version
23
+ ```
24
+
25
+ > **One-off usage** — If you just want to try it without installing globally:
26
+ >
27
+ > ```bash
28
+ > npx @senso-ai/cli --help
29
+ > ```
30
+
31
+ ## Quick Start
32
+
33
+ ### 1. Authenticate
34
+
35
+ Get an API key from [docs.senso.ai](https://docs.senso.ai), then:
36
+
37
+ ```bash
38
+ senso login
39
+ ```
40
+
41
+ The interactive prompt will walk you through pasting your key and verifying it against your organization.
42
+
43
+ Alternatively, set an environment variable (useful for CI and AI agents):
44
+
45
+ ```bash
46
+ export SENSO_API_KEY=tgr_your_key_here
47
+ ```
48
+
49
+ ### 2. Search your knowledge base
50
+
51
+ ```bash
52
+ senso search "What are the current mortgage rates?"
53
+ ```
54
+
55
+ ### 3. List your content
56
+
57
+ ```bash
58
+ senso content list
59
+ ```
60
+
61
+ That's it. Every endpoint in the Senso Org API is available as a CLI command.
62
+
63
+ ---
64
+
65
+ ## Platform Support
66
+
67
+ | Platform | Supported | Config Location |
68
+ |----------|-----------|-----------------|
69
+ | **Linux** | Node 18+ | `~/.config/senso/config.json` |
70
+ | **macOS** | Node 18+ | `~/Library/Preferences/senso/config.json` |
71
+ | **Windows** | Node 18+ | `%APPDATA%\senso\config.json` |
72
+
73
+ Config paths are handled automatically via XDG-compatible directories. The config file stores your API key, org info, and update check timestamps with owner-only permissions (`0600`).
74
+
75
+ ---
76
+
77
+ ## Usage with AI Agents
78
+
79
+ The CLI is designed as a first-class tool for AI LLM agents. Pass `--output json` to get structured output and `--quiet` to suppress banners:
80
+
81
+ ```bash
82
+ # Claude Code / Gemini CLI / Codex can call this directly
83
+ senso search "customer refund policy" --output json --quiet
84
+
85
+ # Pass API key inline (no config file needed)
86
+ senso search "billing FAQ" --api-key tgr_... --output json --quiet
87
+ ```
88
+
89
+ ### Auth Priority
90
+
91
+ The CLI resolves credentials in this order:
92
+
93
+ 1. `--api-key` flag (highest priority)
94
+ 2. `SENSO_API_KEY` environment variable
95
+ 3. `~/.config/senso/config.json` stored key
96
+ 4. Interactive prompt (first-run only)
97
+
98
+ For non-interactive use (CI, agents), set the env var or pass the flag.
99
+
100
+ ---
101
+
102
+ ## Commands
103
+
104
+ ### Authentication
105
+
106
+ ```
107
+ senso login Save API key (interactive)
108
+ senso logout Remove stored credentials
109
+ senso whoami Show current org and auth status
110
+ ```
111
+
112
+ ### Search
113
+
114
+ ```
115
+ senso search <query> Semantic search with AI-generated answer
116
+ senso search context <query> Semantic search — chunks only
117
+ senso search content <query> Semantic search — content IDs only
118
+ ```
119
+
120
+ Options: `--max-results <n>`
121
+
122
+ ### Content
123
+
124
+ ```
125
+ senso content list List content items
126
+ senso content get <id> Get content item by ID
127
+ senso content delete <id> Delete content (local + external)
128
+ senso content unpublish <id> Unpublish content
129
+ senso content verification List content awaiting verification
130
+ senso content reject <versionId> Reject a content version
131
+ senso content restore <versionId> Restore a content version to draft
132
+ senso content owners <id> List content owners
133
+ senso content set-owners <id> Replace content owners
134
+ senso content remove-owner <id> <userId> Remove content owner
135
+ ```
136
+
137
+ ### Content Generation
138
+
139
+ ```
140
+ senso generate settings Get content generation settings
141
+ senso generate update-settings Update content generation settings
142
+ senso generate sample Generate ad hoc content sample
143
+ senso generate run Trigger content engine run
144
+ ```
145
+
146
+ ### Content Engine
147
+
148
+ ```
149
+ senso engine publish Publish content via content engine
150
+ senso engine draft Save content as draft
151
+ ```
152
+
153
+ ### Ingestion
154
+
155
+ ```
156
+ senso ingest upload Request presigned S3 upload URLs
157
+ senso ingest reprocess <contentId> Re-ingest existing content
158
+ ```
159
+
160
+ ### Categories & Topics
161
+
162
+ ```
163
+ senso categories list List categories
164
+ senso categories list-all List all categories with their topics
165
+ senso categories create <name> Create a category
166
+ senso categories get <id> Get category by ID
167
+ senso categories update <id> Update a category
168
+ senso categories delete <id> Delete a category
169
+ senso categories batch-create Batch create categories with topics
170
+
171
+ senso topics list <categoryId> List topics in a category
172
+ senso topics create <categoryId> Create a topic
173
+ senso topics get <catId> <topicId> Get a topic
174
+ senso topics update <catId> <topicId> Update a topic
175
+ senso topics delete <catId> <topicId> Delete a topic
176
+ senso topics batch-create <catId> Batch create topics
177
+ ```
178
+
179
+ ### Brand Kit & Content Types
180
+
181
+ ```
182
+ senso brand-kit get Get brand kit
183
+ senso brand-kit set Upsert brand kit
184
+
185
+ senso content-types list List content types
186
+ senso content-types create Create a content type
187
+ senso content-types get <id> Get content type
188
+ senso content-types update <id> Update content type
189
+ senso content-types delete <id> Delete content type
190
+ ```
191
+
192
+ ### Prompts
193
+
194
+ ```
195
+ senso prompts list List prompts
196
+ senso prompts create Create a prompt
197
+ senso prompts get <promptId> Get prompt with full run history
198
+ senso prompts delete <promptId> Delete a prompt
199
+ ```
200
+
201
+ ### Organization
202
+
203
+ ```
204
+ senso org get Get organization details
205
+ senso org update Update organization details
206
+
207
+ senso users list List users
208
+ senso users add Add a user
209
+ senso users get <userId> Get a user
210
+ senso users update <userId> Update a user's role
211
+ senso users remove <userId> Remove a user
212
+
213
+ senso api-keys list List API keys
214
+ senso api-keys create Create API key
215
+ senso api-keys get <keyId> Get API key details
216
+ senso api-keys update <keyId> Update API key
217
+ senso api-keys delete <keyId> Delete API key
218
+ senso api-keys revoke <keyId> Revoke API key
219
+
220
+ senso members list List organization members
221
+ ```
222
+
223
+ ### Run Configuration
224
+
225
+ ```
226
+ senso run-config models Get configured AI models
227
+ senso run-config set-models Set AI models
228
+ senso run-config schedule Get run schedule
229
+ senso run-config set-schedule Set run schedule
230
+ ```
231
+
232
+ ### Notifications
233
+
234
+ ```
235
+ senso notifications list List notifications
236
+ senso notifications read <id> Mark notification as read
237
+ ```
238
+
239
+ ### CLI Management
240
+
241
+ ```
242
+ senso update Update to the latest version
243
+ senso --version Show current version
244
+ senso --help Show help
245
+ ```
246
+
247
+ ---
248
+
249
+ ## Global Options
250
+
251
+ | Flag | Description |
252
+ |------|-------------|
253
+ | `--api-key <key>` | Override API key (or set `SENSO_API_KEY` env var) |
254
+ | `--base-url <url>` | Override API base URL (default: `https://apiv2.senso.ai/api/v1`) |
255
+ | `--output <format>` | Output format: `json`, `table`, or `plain` (default: `plain`) |
256
+ | `--quiet` | Suppress banners and non-essential output |
257
+ | `--no-update-check` | Skip version check (or set `SENSO_NO_UPDATE_CHECK=1`) |
258
+ | `-v, --version` | Show version |
259
+ | `-h, --help` | Show help |
260
+
261
+ ---
262
+
263
+ ## Output Formats
264
+
265
+ **Plain** (default — human-friendly):
266
+
267
+ ```
268
+ $ senso search "mortgage rates"
269
+
270
+ Answer: Based on our knowledge base, current mortgage rates are...
271
+
272
+ Found 3 results:
273
+
274
+ 1. Mortgage Rate Overview
275
+ Content: Fixed-rate mortgages currently average...
276
+ ID: cnt_abc123
277
+ ```
278
+
279
+ **JSON** (for AI agents and scripting):
280
+
281
+ ```
282
+ $ senso search "mortgage rates" --output json
283
+ {
284
+ "answer": "Based on our knowledge base...",
285
+ "results": [
286
+ {
287
+ "title": "Mortgage Rate Overview",
288
+ "chunk_text": "Fixed-rate mortgages currently average...",
289
+ "content_id": "cnt_abc123"
290
+ }
291
+ ]
292
+ }
293
+ ```
294
+
295
+ **Table** (for listing resources):
296
+
297
+ ```
298
+ $ senso content list --output table
299
+
300
+ ID Title Status
301
+ cnt_abc123 Mortgage Rate Overview published
302
+ cnt_def456 Variable Rate Products draft
303
+ ```
304
+
305
+ ---
306
+
307
+ ## Auto-Update
308
+
309
+ The CLI checks for new versions once every 24 hours (via GitHub releases) and shows a notice on stderr if an update is available:
310
+
311
+ ```
312
+ ╭──────────────────────────────────────────────╮
313
+ │ │
314
+ │ Update available! 0.1.0 → 0.2.0 │
315
+ │ │
316
+ │ Run senso update to update │
317
+ │ │
318
+ ╰──────────────────────────────────────────────╯
319
+ ```
320
+
321
+ Update notices are written to `stderr` so they won't interfere with `--output json` piped to other programs.
322
+
323
+ To disable: `--no-update-check` or `export SENSO_NO_UPDATE_CHECK=1`.
324
+
325
+ ---
326
+
327
+ ## Development
328
+
329
+ ```bash
330
+ # Clone the repo
331
+ git clone https://github.com/AI-Template-SDK/senso-user-cli.git
332
+ cd senso-user-cli
333
+
334
+ # Install dependencies
335
+ npm install
336
+
337
+ # Run in dev mode (TypeScript directly via tsx)
338
+ npm run dev -- search "test query"
339
+
340
+ # Build (single ESM bundle via tsup)
341
+ npm run build
342
+
343
+ # Run the built version
344
+ node dist/cli.js --help
345
+
346
+ # Run tests
347
+ npm test
348
+ ```
349
+
350
+ ### Project Structure
351
+
352
+ ```
353
+ src/
354
+ ├── cli.ts # Entry point — arg parsing, command dispatch
355
+ ├── commands/ # One file per command group (18 files)
356
+ │ ├── auth.ts # login, logout, whoami
357
+ │ ├── search.ts # search, search context, search content
358
+ │ ├── content.ts # CRUD + verification + owners
359
+ │ ├── generate.ts # content generation settings + triggers
360
+ │ ├── engine.ts # publish, draft
361
+ │ ├── ingest.ts # upload, reprocess
362
+ │ ├── categories.ts # CRUD + batch
363
+ │ ├── topics.ts # CRUD + batch
364
+ │ ├── brand-kit.ts # get, set
365
+ │ ├── content-types.ts # CRUD
366
+ │ ├── prompts.ts # CRUD
367
+ │ ├── org.ts # get, update
368
+ │ ├── users.ts # CRUD
369
+ │ ├── api-keys.ts # CRUD + revoke
370
+ │ ├── members.ts # list
371
+ │ ├── run-config.ts # models, schedule
372
+ │ ├── notifications.ts # list, read
373
+ │ └── update.ts # self-update
374
+ ├── lib/
375
+ │ ├── api-client.ts # HTTP wrapper (native fetch, X-API-Key auth)
376
+ │ ├── config.ts # Config read/write (~/.config/senso/)
377
+ │ ├── output.ts # json/table/plain formatting
378
+ │ └── version.ts # Reads version from package.json
379
+ └── utils/
380
+ ├── logger.ts # Colored log helpers (picocolors)
381
+ ├── branding.ts # ASCII logo, gradient banner, boxed panels
382
+ └── updater.ts # GitHub releases version check
383
+ ```
384
+
385
+ ### Tech Stack
386
+
387
+ | Concern | Choice |
388
+ |---------|--------|
389
+ | Language | TypeScript |
390
+ | Runtime | Node.js 18+ |
391
+ | Bundler | tsup (esbuild) — single 50KB ESM bundle |
392
+ | CLI Framework | Commander.js |
393
+ | Interactive Prompts | @clack/prompts |
394
+ | Colors | picocolors |
395
+ | ASCII Branding | figlet + gradient-string + boxen |
396
+ | Config | env-paths (XDG-compatible) |
397
+ | HTTP | Native `fetch` |
398
+
399
+ ### Releasing a New Version
400
+
401
+ This project uses [semantic versioning](https://semver.org/). The CLI's auto-update checker compares the installed version against the latest GitHub release using semver, so pre-release tags and version ordering are handled correctly.
402
+
403
+ ```bash
404
+ # 1. Bump the version in package.json, commit, and create a git tag
405
+ npm version patch # 0.1.0 → 0.1.1 (bug fixes)
406
+ npm version minor # 0.1.0 → 0.2.0 (new features, backwards-compatible)
407
+ npm version major # 0.1.0 → 1.0.0 (breaking changes)
408
+
409
+ # 2. Push the commit and tag
410
+ git push origin main --tags
411
+
412
+ # 3. Create a GitHub release (this is what the auto-updater checks)
413
+ gh release create v0.2.0 --title "v0.2.0" --notes "Release notes here"
414
+ ```
415
+
416
+ After step 3, users running the CLI will see the update notice within 24 hours (or immediately via `senso update`).
417
+
418
+ ---
419
+
420
+ ## License
421
+
422
+ [AGPL-3.0](LICENSE)