@growrk/cli 4.9.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.
package/README.md ADDED
@@ -0,0 +1,173 @@
1
+ # @growrk/cli
2
+
3
+ `growrk` — the command-line interface for the **GroWrk v4 API**. It's a thin HTTP
4
+ client over the same tool core that powers the REST API and the MCP server, so
5
+ the CLI, `curl`, and an AI agent all reach the identical operations.
6
+
7
+ ```
8
+ growrk CLI ──HTTP──> https://ai.growrk.com/v4/{resource} ──> GroWrk
9
+ ```
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ npm install -g @growrk/cli
15
+ growrk --version
16
+ ```
17
+
18
+ > Requires Node.js >= 24.
19
+
20
+ ## Authentication
21
+
22
+ Every request is authenticated with a per-user API key (prefix `grk_sk_`) sent as
23
+ the `X-API-KEY` header. One key works across the REST API, the CLI, and MCP.
24
+
25
+ ```bash
26
+ # Interactive login (prompts for the API key and an account name)
27
+ growrk auth login
28
+
29
+ # Non-interactive
30
+ growrk auth login --api-key grk_sk_... --environment prod --name production
31
+
32
+ # Show the resolved identity + access for the active key
33
+ growrk auth status
34
+
35
+ # Remove a stored account
36
+ growrk auth logout --name production
37
+ ```
38
+
39
+ Credentials resolve in this order: `--api-key` flag → `GROWRK_API_KEY` env var →
40
+ the active account in `~/.growrk/config.yml` (multiple named accounts supported).
41
+
42
+ ### Getting an API key
43
+
44
+ 1. In the GroWrk app, open **Developers → API Keys**.
45
+ 2. **Create API Key** → pick a company + app.
46
+ 3. Select the **Capabilities** the key should carry (e.g. `mcp:orders:read`,
47
+ `mcp:orders:write`, `mcp:employees:read`). These govern what the key can do on
48
+ the REST API and CLI; the key acts as you across every company you administer.
49
+ 4. Copy the raw key (shown once) and pass it to `growrk auth login`.
50
+
51
+ ## Commands
52
+
53
+ Commands are grouped by resource: `growrk <resource> <action> [id] [flags]`. Run
54
+ `growrk <resource> <action> --help` to see the exact flags for any action (they're
55
+ generated from the shared tool schema, so they always match the API).
56
+
57
+ ### orders
58
+
59
+ ```bash
60
+ growrk orders list --status shipped --limit 10 # GET /v4/orders
61
+ growrk orders get <orderId> # GET /v4/orders/:id
62
+ growrk orders create \ # POST /v4/orders
63
+ --order-type "New Hire" --employee-id emp_123 --product-ids macbook-pro-14,dock
64
+ growrk orders history <orderId> # GET /v4/orders/:id/history
65
+ growrk orders tracking <orderId> # GET /v4/orders/:id/tracking
66
+ growrk orders sla <orderId> # GET /v4/orders/:id/sla
67
+ growrk orders validate --order-type Deployment \ # POST /v4/orders/validate
68
+ --employee-id emp_123 --product-ids p1
69
+ growrk orders add-accessory <orderId> ... # POST /v4/orders/:id/accessories
70
+ ```
71
+
72
+ ### employees
73
+
74
+ ```bash
75
+ growrk employees list # GET /v4/employees
76
+ growrk employees get <employeeId> # GET /v4/employees/:id
77
+ growrk employees create ... # POST /v4/employees
78
+ growrk employees update <employeeId> --job-title Eng # PATCH /v4/employees/:id
79
+ growrk employees devices <employeeId> # GET /v4/employees/:id/devices
80
+ ```
81
+
82
+ ### inventory & devices
83
+
84
+ ```bash
85
+ growrk inventory search ... # GET /v4/inventory
86
+ growrk devices options # GET /v4/devices/options
87
+ growrk devices suggestions --country us # GET /v4/devices/suggestions
88
+ ```
89
+
90
+ ### me
91
+
92
+ ```bash
93
+ growrk me # GET /v4/me — your identity + access
94
+ ```
95
+
96
+ ## Global options
97
+
98
+ | Flag | Description |
99
+ |-----------------------|-------------------------------------------------------------------|
100
+ | `--api-key <key>` | Override the stored API key |
101
+ | `--api-url <url>` | Override the API base URL |
102
+ | `--environment <env>` | Target environment (`prod`, `io`, `local`) |
103
+ | `--format <fmt>` | Output format: `json`, `table`, `text` (default: `table`) |
104
+ | `--allow-localhost` | Allow `http://localhost` for local development |
105
+ | `--help` | Show help |
106
+ | `--version` | Show the CLI version |
107
+
108
+ ### Environments
109
+
110
+ | Name | URL | Notes |
111
+ |---------|---------------------------|------------------------------|
112
+ | `prod` | `https://ai.growrk.com` | Default |
113
+ | `io` | `https://io.growrk.com` | Alias of prod (pre-cutover) |
114
+ | `local` | `http://localhost:3001` | Requires `--allow-localhost` |
115
+
116
+ ```bash
117
+ growrk orders list --environment prod
118
+ ```
119
+
120
+ Any other target is reached with `--api-url`:
121
+
122
+ ```bash
123
+ growrk orders list --api-url https://your-host.example.com
124
+ ```
125
+
126
+ A stored account can also carry its own `apiUrl`
127
+ (`growrk auth login --api-url <url> --name sandbox`), which becomes the active
128
+ account only if it is your first one.
129
+
130
+ The base URL resolves in this order:
131
+
132
+ ```
133
+ --api-url → --environment → GROWRK_ENVIRONMENT → the account's environment
134
+ → GROWRK_API_URL → the account's apiUrl → https://ai.growrk.com
135
+ ```
136
+
137
+ `GROWRK_API_URL` sits near the end, so it is ignored if the active account
138
+ already has an `environment` — use `--api-url` when you need to be certain.
139
+
140
+ ## Output formats
141
+
142
+ | Format | Description |
143
+ |---------|------------------------------------------------------|
144
+ | `table` | Aligned columns for the terminal (default) |
145
+ | `json` | Full JSON envelope with `ok`, `data`, `meta` |
146
+ | `text` | Plain text, suitable for piping |
147
+
148
+ ```bash
149
+ growrk orders list --format json | jq '.data.orders[0].id'
150
+ ```
151
+
152
+ ## The same API, three ways
153
+
154
+ The CLI is one of three surfaces over the same tool core:
155
+
156
+ ```bash
157
+ # REST
158
+ curl https://ai.growrk.com/v4/orders -H "X-API-KEY: grk_sk_..."
159
+
160
+ # CLI
161
+ growrk orders list
162
+
163
+ # MCP (Streamable HTTP) — OAuth 2.1, or X-API-KEY
164
+ POST https://ai.growrk.com/mcp
165
+ ```
166
+
167
+ ## Development
168
+
169
+ ```bash
170
+ pnpm build # bundle with tsup
171
+ pnpm dev # watch mode
172
+ pnpm test # vitest
173
+ ```
package/bin/growrk.mjs ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ // Thin, committed launcher for the `growrk` bin.
3
+ //
4
+ // pnpm links bins during install BEFORE workspace `prepare` scripts run, and
5
+ // `pnpm cleanup` wipes `dist/` — so pointing `bin` directly at the tsup output
6
+ // (`dist/cli.mjs`) makes pnpm warn "Failed to create bin … ENOENT" on a fresh
7
+ // install until `prepare` rebuilds it. This launcher always exists in the repo
8
+ // (and in the published `files`), so the bin link never fails; it just defers
9
+ // to the real CLI built by tsup.
10
+ import('../dist/cli.mjs').catch((err) => {
11
+ console.error('[growrk] CLI build not found — run `pnpm -F @growrk/cli build`.')
12
+ console.error(err?.message ?? err)
13
+ process.exit(1)
14
+ })
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export { }