@headband/cli 0.1.0 → 0.2.0

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 +130 -9
  2. package/dist/index.js +2543 -70
  3. package/package.json +6 -2
package/README.md CHANGED
@@ -1,17 +1,40 @@
1
1
  # @headband/cli
2
2
 
3
- Interactive CLI for setting up [Headband](https://headband.dev) search in any project.
3
+ Command-line tools for [Headband](https://headband.dev): project setup, device login,
4
+ API key management, index operations, document pushes, search, and task inspection.
4
5
 
5
6
  ## Usage
6
7
 
7
8
  ```bash
9
+ npx @headband/cli --help
8
10
  npx @headband/cli init
11
+ npx @headband/cli login
12
+ ```
13
+
14
+ Global flags:
15
+
16
+ ```bash
17
+ --url <url> Select a Headband profile URL
18
+ --json Print JSON for supported list/get commands
19
+ --yes Skip confirmation prompts
20
+ --help Show help
21
+ ```
22
+
23
+ Credentials are stored in `~/.config/headband/credentials.json` or
24
+ `$XDG_CONFIG_HOME/headband/credentials.json` with file mode `0600`.
25
+
26
+ ## Commands
27
+
28
+ ### Setup
29
+
30
+ ```bash
31
+ headband init [--yes]
9
32
  ```
10
33
 
11
34
  This will:
12
35
 
13
36
  1. Ask for your Headband URL (default: `https://headband.dev`)
14
- 2. Ask for your search API key (`hb_src_...` or `hb_adm_...`)
37
+ 2. Ask for your browser-safe search API key (`hb_src_...` only)
15
38
  3. Ask for your default search index (e.g. `products`, `movies`)
16
39
  4. Detect your package manager (npm, pnpm, yarn, or bun)
17
40
  5. Install `@headband/react`
@@ -25,6 +48,105 @@ npx @headband/cli init --yes # Skip prompts, use defaults
25
48
  npx @headband/cli --help # Show help
26
49
  ```
27
50
 
51
+ ### Auth
52
+
53
+ ```bash
54
+ headband login [--url <url>]
55
+ headband logout [--url <url>] [--yes]
56
+ headband whoami [--url <url>] [--json]
57
+ ```
58
+
59
+ `login` uses Headband's device flow and stores only the API key profile locally.
60
+ The full key is never printed during login; success output shows only the key
61
+ prefix. `logout` removes local credentials and can offer to revoke the CLI key
62
+ server-side first.
63
+
64
+ ### Projects
65
+
66
+ ```bash
67
+ headband projects list [--json]
68
+ headband projects create <name> --engine <meilisearch|typesense|elasticsearch>
69
+ ```
70
+
71
+ ### Keys
72
+
73
+ ```bash
74
+ headband keys list [--json]
75
+ headband keys create <name> --type <admin|search> [--project <id>] [--json]
76
+ headband keys revoke <id> [--yes]
77
+ ```
78
+
79
+ `keys create` is the only command that prints a raw API key. Store it when it is
80
+ shown because Headband returns raw keys only once.
81
+
82
+ ### Indexes
83
+
84
+ ```bash
85
+ headband indexes list [--json]
86
+ headband indexes create <uid> [--primary-key <pk>] [--engine <engine>] [--instance <id>] [--json]
87
+ headband indexes delete <uid> [--yes]
88
+ headband indexes settings get <uid> [--json]
89
+ headband indexes settings set <uid> --file <settings.json> [--json]
90
+ headband indexes stats <uid> [--json]
91
+ ```
92
+
93
+ `--instance <id>` creates the index on one of your dedicated engines (ids from
94
+ `headband instances list`). The index takes that engine's type, so `--engine` is
95
+ optional; if you pass it, it must match.
96
+
97
+ On the engine, the index has a longer name (`engineIndexUid`, such as
98
+ `hbo_<org>_products`). `indexes create` and `indexes list` show it. Use that name,
99
+ not the uid, with the engine's own client on the instance endpoint.
100
+
101
+ ### Engines
102
+
103
+ Dedicated engines are private Meilisearch, Elasticsearch or Typesense servers for
104
+ your organization, reachable with each engine's own client. They are rolling out
105
+ gradually. Until your organization has access, these commands say so.
106
+
107
+ ```bash
108
+ headband instances list [--json]
109
+ headband instances create <meilisearch|elasticsearch|typesense> [--name <name>] [--lane <serverless|always_on>] [--memory <512m|1g|...>] [--region <region>] [--idle-timeout <seconds>] [--json]
110
+ headband instances show <id> [--json]
111
+ headband instances wake <id> [--json]
112
+ headband instances park <id> [--json]
113
+ headband instances delete <id> [--yes]
114
+ headband instances connect <id> [--client <node|curl>]
115
+ ```
116
+
117
+ `connect` prints the endpoint and a snippet for the engine's own client. Authenticate
118
+ with an organization-wide key. The snippets create an index and add a document, so
119
+ run them with an admin key (`headband keys create <name> --type admin`); a search
120
+ key can only search.
121
+ Project keys do not work on engine endpoints. Serverless engines are available for
122
+ Meilisearch only for now. If a command says the key cannot manage engines, run
123
+ `headband login` again.
124
+
125
+ ### Documents
126
+
127
+ ```bash
128
+ headband docs push <file.json|file.jsonl> --index <uid>
129
+ headband docs delete <docId> --index <uid>
130
+ ```
131
+
132
+ `docs push` accepts a JSON array or JSONL file and sends documents to
133
+ `/v1/bulk` in batches of 1000.
134
+
135
+ ### Search
136
+
137
+ ```bash
138
+ headband search <index> <query> [--limit N] [--filter <expr>] [--json]
139
+ ```
140
+
141
+ Plain output shows a compact table. `--json` prints the raw API response.
142
+
143
+ ### Tasks
144
+
145
+ ```bash
146
+ headband tasks list [--json]
147
+ headband tasks get <id> [--json]
148
+ ```
149
+
28
150
  ## What gets created
29
151
 
30
152
  **`headband.config.ts`** -- Search configuration that reads from `NEXT_PUBLIC_HEADBAND_KEY` env var with a fallback:
@@ -37,18 +159,17 @@ export const headbandConfig = {
37
159
  };
38
160
  ```
39
161
 
162
+ Do not paste an `hb_adm_` admin key into this flow. The generated config is used
163
+ by a browser component, so the CLI only accepts scoped `hb_src_` search keys.
164
+ Keep admin keys in server-only environments for indexing, settings, and sync
165
+ jobs.
166
+
40
167
  **`components/headband-search.tsx`** (or `src/components/` if your project uses a `src/` directory) -- A ready-to-use search component:
41
168
 
42
169
  ```tsx
43
170
  "use client";
44
171
 
45
- import {
46
- headband,
47
- HeadbandProvider,
48
- SearchBox,
49
- Hits,
50
- Stats,
51
- } from "@headband/react";
172
+ import { headband, HeadbandProvider, SearchBox, Hits, Stats } from "@headband/react";
52
173
  import { headbandConfig } from "../headband.config";
53
174
 
54
175
  const client = headband(headbandConfig.url, headbandConfig.searchKey);