@commissionsight/cli 0.1.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/LICENSE +21 -0
- package/README.md +248 -0
- package/bin/cs.mjs +2 -0
- package/dist/commands/admin.d.ts +7 -0
- package/dist/commands/admin.js +409 -0
- package/dist/commands/auth.d.ts +7 -0
- package/dist/commands/auth.js +107 -0
- package/dist/commands/batch.d.ts +2 -0
- package/dist/commands/batch.js +68 -0
- package/dist/commands/billing.d.ts +6 -0
- package/dist/commands/billing.js +75 -0
- package/dist/commands/carrier.d.ts +6 -0
- package/dist/commands/carrier.js +111 -0
- package/dist/commands/completion.d.ts +6 -0
- package/dist/commands/completion.js +56 -0
- package/dist/commands/context.d.ts +6 -0
- package/dist/commands/context.js +73 -0
- package/dist/commands/file.d.ts +6 -0
- package/dist/commands/file.js +97 -0
- package/dist/commands/job.d.ts +2 -0
- package/dist/commands/job.js +186 -0
- package/dist/commands/member.d.ts +5 -0
- package/dist/commands/member.js +91 -0
- package/dist/commands/meta.d.ts +7 -0
- package/dist/commands/meta.js +36 -0
- package/dist/commands/rate.d.ts +5 -0
- package/dist/commands/rate.js +69 -0
- package/dist/commands/registry.d.ts +14 -0
- package/dist/commands/registry.js +56 -0
- package/dist/commands/report.d.ts +2 -0
- package/dist/commands/report.js +168 -0
- package/dist/commands/session.d.ts +5 -0
- package/dist/commands/session.js +21 -0
- package/dist/commands/team.d.ts +5 -0
- package/dist/commands/team.js +61 -0
- package/dist/commands/upload.d.ts +85 -0
- package/dist/commands/upload.js +111 -0
- package/dist/commands/webhook.d.ts +5 -0
- package/dist/commands/webhook.js +56 -0
- package/dist/commands/workspace.d.ts +8 -0
- package/dist/commands/workspace.js +65 -0
- package/dist/config/schema.d.ts +21 -0
- package/dist/config/schema.js +33 -0
- package/dist/config/store.d.ts +17 -0
- package/dist/config/store.js +74 -0
- package/dist/context.d.ts +22 -0
- package/dist/context.js +100 -0
- package/dist/errors.d.ts +37 -0
- package/dist/errors.js +70 -0
- package/dist/globals.d.ts +10 -0
- package/dist/globals.js +38 -0
- package/dist/io.d.ts +28 -0
- package/dist/io.js +28 -0
- package/dist/lib/batch.d.ts +52 -0
- package/dist/lib/batch.js +0 -0
- package/dist/lib/confirm.d.ts +2 -0
- package/dist/lib/confirm.js +23 -0
- package/dist/lib/file.d.ts +6 -0
- package/dist/lib/file.js +43 -0
- package/dist/lib/input.d.ts +2 -0
- package/dist/lib/input.js +35 -0
- package/dist/lib/paginate.d.ts +33 -0
- package/dist/lib/paginate.js +47 -0
- package/dist/lib/period.d.ts +15 -0
- package/dist/lib/period.js +43 -0
- package/dist/lib/poll.d.ts +14 -0
- package/dist/lib/poll.js +17 -0
- package/dist/lib/resolve.d.ts +30 -0
- package/dist/lib/resolve.js +81 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +17 -0
- package/dist/output/color.d.ts +26 -0
- package/dist/output/color.js +37 -0
- package/dist/output/csv.d.ts +25 -0
- package/dist/output/csv.js +119 -0
- package/dist/output/envelope.d.ts +29 -0
- package/dist/output/envelope.js +66 -0
- package/dist/output/help.d.ts +7 -0
- package/dist/output/help.js +57 -0
- package/dist/output/print.d.ts +14 -0
- package/dist/output/print.js +70 -0
- package/dist/output/schema-tree.d.ts +32 -0
- package/dist/output/schema-tree.js +33 -0
- package/dist/router.d.ts +6 -0
- package/dist/router.js +267 -0
- package/dist/types.d.ts +66 -0
- package/dist/types.js +1 -0
- package/dist/util.d.ts +11 -0
- package/dist/util.js +39 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +41 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) CommissionSight
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
# @commissionsight/cli
|
|
2
|
+
|
|
3
|
+
Command-line interface for the [CommissionSight](https://commissionsight.com) API
|
|
4
|
+
— authentication, workspace selection, and statement uploads for **any carrier,
|
|
5
|
+
any period, in any workspace**. A thin, faithful wrapper over
|
|
6
|
+
[`@commissionsight/sdk`](https://www.npmjs.com/package/@commissionsight/sdk).
|
|
7
|
+
|
|
8
|
+
It is designed to be driven by **humans and by AI coding agents** (Claude Code,
|
|
9
|
+
Cursor, etc.) running locally: every command is fully non-interactive, supports
|
|
10
|
+
machine-readable `--json` output, and returns deterministic exit codes.
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install -g @commissionsight/cli
|
|
14
|
+
cs --version
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Binaries: `cs` (and the alias `commissionsight`). Requires **Node ≥ 20**.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Quick start
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# 1. Authenticate (token issued by CommissionSight; piped, never in argv)
|
|
25
|
+
printf '%s' "$COMMISSIONSIGHT_TOKEN" | cs auth login --token-stdin
|
|
26
|
+
cs auth status # verifies via me()
|
|
27
|
+
|
|
28
|
+
# 2. Pick a workspace (only needed on multi-workspace accounts)
|
|
29
|
+
cs workspace list
|
|
30
|
+
cs workspace use "Main Book"
|
|
31
|
+
|
|
32
|
+
# 3. Upload a statement — any carrier, any period, any workspace
|
|
33
|
+
cs upload ./aetna-2026-05.xlsx --carrier aetna --period 2026-05 --wait --results --json
|
|
34
|
+
|
|
35
|
+
# 4. Bulk upload a folder (idempotent, resumable, mixed carriers/periods)
|
|
36
|
+
cs upload batch ./statements --workspace "Main Book" --wait --report ./ingest.json
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Using this CLI from an AI agent (Claude Code, etc.)
|
|
42
|
+
|
|
43
|
+
This section is the contract an autonomous agent should rely on. Everything here
|
|
44
|
+
is stable and machine-checkable.
|
|
45
|
+
|
|
46
|
+
### 1. Discover the surface programmatically — don't guess
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
cs schema --json
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Returns the **entire** command/flag tree as JSON: every command, its positional
|
|
53
|
+
args (with `required`/`variadic`), and every option (`type`, `short`, `desc`,
|
|
54
|
+
`choices`, `default`). Parse this instead of memorizing commands. Shape:
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"ok": true,
|
|
59
|
+
"data": {
|
|
60
|
+
"name": "cs",
|
|
61
|
+
"version": "0.1.0",
|
|
62
|
+
"globalOptions": [ { "flag": "json", "type": "boolean", "desc": "…" }, … ],
|
|
63
|
+
"commands": [
|
|
64
|
+
{
|
|
65
|
+
"command": "upload",
|
|
66
|
+
"path": ["upload"],
|
|
67
|
+
"summary": "Upload a statement for a carrier + period",
|
|
68
|
+
"args": [ { "name": "file", "required": true, "variadic": false } ],
|
|
69
|
+
"options": [ { "flag": "carrier", "type": "string", "desc": "…" }, … ]
|
|
70
|
+
},
|
|
71
|
+
…
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 2. Always pass `--json` — parse only stdout
|
|
78
|
+
|
|
79
|
+
In `--json` mode, **stdout carries exactly one JSON value: the envelope.** All
|
|
80
|
+
human chrome (spinners, progress, warnings) goes to **stderr**. So an agent can
|
|
81
|
+
safely `JSON.parse(stdout)` without stripping anything.
|
|
82
|
+
|
|
83
|
+
- **Success** (exit 0):
|
|
84
|
+
```json
|
|
85
|
+
{ "ok": true, "data": <command result> }
|
|
86
|
+
```
|
|
87
|
+
- **Failure** (nonzero exit):
|
|
88
|
+
```json
|
|
89
|
+
{ "ok": false, "error": { "status": 409, "code": "period_exists", "message": "…", "body": { … } } }
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`error.code` is a stable slug derived from the API's problem+json body
|
|
93
|
+
(`period_exists`, `already_retracted`, …) or `null`. Branch on `error.code` /
|
|
94
|
+
`error.status`, not on `message` text.
|
|
95
|
+
|
|
96
|
+
### 3. Use exit codes for control flow
|
|
97
|
+
|
|
98
|
+
| Code | Meaning | Typical agent reaction |
|
|
99
|
+
|---|---|---|
|
|
100
|
+
| 0 | Success | continue |
|
|
101
|
+
| 1 | Unexpected/internal error (incl. a job that finished `failed`) | inspect `error.message`; surface to user |
|
|
102
|
+
| 2 | Usage error (bad flags/args) | fix the invocation |
|
|
103
|
+
| 3 | Auth error (401/403) | token missing/invalid/insufficient — re-auth |
|
|
104
|
+
| 4 | Not found (404) | the id/ref doesn't exist |
|
|
105
|
+
| 5 | Conflict (409), e.g. `period_exists` | retry with `--replace` |
|
|
106
|
+
| 6 | Validation (400/422) | inputs rejected; read `error.body` |
|
|
107
|
+
| 7 | Rate limited (429) | back off and retry |
|
|
108
|
+
| 124 | Timeout (`--wait` exceeded `--timeout`) | poll again or raise `--timeout` |
|
|
109
|
+
|
|
110
|
+
### 4. Stay non-interactive
|
|
111
|
+
|
|
112
|
+
- **Token**: prefer `COMMISSIONSIGHT_TOKEN` in the environment, or
|
|
113
|
+
`--token-stdin` (pipe it). Avoid `--token <t>` — it lands in process listings
|
|
114
|
+
and shell history.
|
|
115
|
+
- **Destructive ops** (`file retract|purge`, `team remove`, `rate delete`,
|
|
116
|
+
`webhook delete`, `admin … purge-files`, `admin user delete`) require `--yes`
|
|
117
|
+
/ `-y` when there's no TTY. Without it they exit `2` and perform nothing.
|
|
118
|
+
- **Carrier refs** accept an id, slug, or case-insensitive name; an ambiguous
|
|
119
|
+
name exits `2` and lists candidates on stderr.
|
|
120
|
+
- **Periods** are `--period YYYY-MM` (or `--year` + `--month`).
|
|
121
|
+
|
|
122
|
+
### 5. Idempotency makes retries safe
|
|
123
|
+
|
|
124
|
+
`cs upload` derives an idempotency key per file
|
|
125
|
+
(`<context>-<carrierSlug>-<period>-<sha8(file)>`). Re-running the same upload or
|
|
126
|
+
the same `upload batch` is safe and **resumable**: already-ingested
|
|
127
|
+
carrier+periods come back as `skipped`, not duplicated. Override with
|
|
128
|
+
`--idempotency-key` if you need to.
|
|
129
|
+
|
|
130
|
+
### 6. Recipes
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# Upload and block until scored, get rows back as JSON in one call
|
|
134
|
+
cs upload ./uhc-2026-05.csv --carrier uhc --period 2026-05 \
|
|
135
|
+
--wait --results --json
|
|
136
|
+
# → data.upload.{jobId,fileId}, data.results[] (scored ResultRows)
|
|
137
|
+
|
|
138
|
+
# Handle "period already exists" deterministically
|
|
139
|
+
cs upload ./aetna-2026-05.xlsx --carrier aetna --period 2026-05 --json
|
|
140
|
+
# exit 5 + error.code=period_exists → re-run with --replace:
|
|
141
|
+
cs upload ./aetna-2026-05.xlsx --carrier aetna --period 2026-05 --replace --json
|
|
142
|
+
|
|
143
|
+
# Bulk ingest a directory, keep going past failures, write a machine report
|
|
144
|
+
cs upload batch ./statements --continue-on-error --report ./out.json --json
|
|
145
|
+
# data.{total,uploaded,replaced,skipped,failed,unmatched,outcomes[]}
|
|
146
|
+
|
|
147
|
+
# Pull a full month rollup as JSON, or export rows as CSV
|
|
148
|
+
cs report rollup --period 2026-05 --json
|
|
149
|
+
cs job results <jobId> --all --csv -o ./scored.csv
|
|
150
|
+
|
|
151
|
+
# Export exception (rejected) rows for a job
|
|
152
|
+
cs job exceptions <jobId> -o ./exceptions.csv # exit 4 if none/purged
|
|
153
|
+
|
|
154
|
+
# Audit a single member across every period
|
|
155
|
+
cs member journey <memberRefId> --json
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### 7. Multiple environments
|
|
159
|
+
|
|
160
|
+
Contexts bundle a base URL + token + default workspace. Switch with
|
|
161
|
+
`--context <name>` on any command, or set the active one:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
cs context add staging --base-url https://staging.api.commissionsight.com/v1
|
|
165
|
+
printf '%s' "$STAGING_TOKEN" | cs context add staging --token-stdin
|
|
166
|
+
cs context use staging
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Authentication & config
|
|
172
|
+
|
|
173
|
+
Auth is a per-account **API bearer token** issued by CommissionSight (there is no
|
|
174
|
+
email/password login in the API). Token resolution precedence (highest first):
|
|
175
|
+
|
|
176
|
+
1. `--token <t>` (discouraged — visible in shell history)
|
|
177
|
+
2. `--token-file <path>` / `--token-stdin` (preferred for scripts)
|
|
178
|
+
3. `COMMISSIONSIGHT_TOKEN` env var
|
|
179
|
+
4. active context token in the config file
|
|
180
|
+
|
|
181
|
+
Config lives at `${XDG_CONFIG_HOME:-~/.config}/commissionsight/config.json`
|
|
182
|
+
(dir `0700`, file `0600`). The token is never printed — `auth status` shows a
|
|
183
|
+
masked suffix (`…a1b2`). `--base-url` / `COMMISSIONSIGHT_BASE_URL` override the
|
|
184
|
+
API base (default `https://api.commissionsight.com/v1`).
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Global flags
|
|
189
|
+
|
|
190
|
+
| Flag | Purpose |
|
|
191
|
+
|---|---|
|
|
192
|
+
| `--json` (or `CS_OUTPUT=json`) | Emit only the envelope on stdout |
|
|
193
|
+
| `--quiet` / `-q` | Suppress human chrome |
|
|
194
|
+
| `--no-color` (or `NO_COLOR`) | Disable ANSI color |
|
|
195
|
+
| `--yes` / `-y` | Assume "yes" for destructive confirmations |
|
|
196
|
+
| `--token` / `--token-file` / `--token-stdin` | Token sources |
|
|
197
|
+
| `--base-url <url>` | Override API base URL |
|
|
198
|
+
| `--context <name>` | Use a named config context |
|
|
199
|
+
| `--help` / `-h`, `--version` / `-V` | Help / version |
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Command reference
|
|
204
|
+
|
|
205
|
+
100 commands across these groups (run `cs <group> --help`, or `cs schema --json`
|
|
206
|
+
for the full machine-readable tree).
|
|
207
|
+
|
|
208
|
+
| Group | Commands |
|
|
209
|
+
|---|---|
|
|
210
|
+
| **Session** | `whoami` · `health` · `version` · `schema` · `completion bash\|zsh\|fish` |
|
|
211
|
+
| **Auth** | `auth login` · `auth status` · `auth logout` · `auth token issue` |
|
|
212
|
+
| **Context** | `context list\|current\|use\|add\|remove` |
|
|
213
|
+
| **Workspace** | `workspace list` · `workspace create <name>` · `workspace use <name\|id>` |
|
|
214
|
+
| **Carrier** | `carrier list` · `carrier get` · `carrier config list\|get\|create\|test\|infer` |
|
|
215
|
+
| **Upload** | `upload <file>` · `upload batch <target>` |
|
|
216
|
+
| **File** | `file list\|get\|rescore\|retract\|purge\|rescore-stale` |
|
|
217
|
+
| **Job** | `job list\|get\|wait\|results\|deltas\|exceptions\|retry` |
|
|
218
|
+
| **Member / Policy** | `member list\|get\|timeline\|journey\|last-seen` · `policy journey` |
|
|
219
|
+
| **Team / Audit** | `team list\|invite\|remove` · `audit list` |
|
|
220
|
+
| **Reports** | `report rollup\|compare\|attrition\|attrition-series\|data-quality\|chargebacks` |
|
|
221
|
+
| **Rates** | `rate list\|set\|delete` |
|
|
222
|
+
| **Webhooks** | `webhook list\|create\|delete` |
|
|
223
|
+
| **Billing** | `billing get\|preview\|update` |
|
|
224
|
+
| **Admin** | `admin account *` · `admin token *` · `admin carrier *` · `admin user *` · `admin job *` · `admin allowlist add` · `admin metrics\|logs\|revenue\|cron-runs` |
|
|
225
|
+
|
|
226
|
+
List commands accept `--limit`, `--all` (auto-paginate), and `--offset` or
|
|
227
|
+
`--cursor` as appropriate; result/report commands accept `--csv` (with `-o` to
|
|
228
|
+
write a file). Reports take `--period`/`--carrier`/`--from`/`--to` as listed in
|
|
229
|
+
`--help`.
|
|
230
|
+
|
|
231
|
+
### Notes & limitations
|
|
232
|
+
|
|
233
|
+
- **Workspace creation** (`cs workspace create <name>`) requires
|
|
234
|
+
`@commissionsight/sdk` **≥ 2.3.0** (`createWorkspace` → `POST /workspaces`).
|
|
235
|
+
The command is capability-gated: on an older SDK it fails with a clear,
|
|
236
|
+
actionable message instead of silently no-opping.
|
|
237
|
+
- **Report workspace scoping**: the API documents an optional `?workspaceId` on
|
|
238
|
+
reports, but the SDK's report methods do not yet accept it, so `cs report *`
|
|
239
|
+
omits `--workspace`. As a thin wrapper the CLI never bypasses the SDK; this
|
|
240
|
+
lands when the SDK exposes the parameter.
|
|
241
|
+
- **Stripe payment-method / setup-intent** flows are web-app only and out of
|
|
242
|
+
scope; use `cs billing get/preview/update` for billing details.
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## License
|
|
247
|
+
|
|
248
|
+
MIT © CommissionSight
|
package/bin/cs.mjs
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admin namespace (plan §6.12) — maps the entire `client.admin.*` surface 1:1.
|
|
3
|
+
* Every call is wrapped by `adminGate`, which turns a 401/403 into exit 3 with
|
|
4
|
+
* an "admin token required" message so non-admin tokens fail clearly.
|
|
5
|
+
*/
|
|
6
|
+
import type { Cmd } from '../types.js';
|
|
7
|
+
export declare function adminCommands(): Cmd[];
|