vellum-cli 0.3.2 → 0.3.4
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 +2 -4
- package/dist/index.js +19 -32
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -39,11 +39,9 @@ env vars:
|
|
|
39
39
|
| Flag | Env var | Description |
|
|
40
40
|
| ------------ | ---------------- | -------------------------------------------- |
|
|
41
41
|
| `--url` | `VELLUM_URL` | Server base URL (default `https://vellumai.app`) |
|
|
42
|
-
| `--api-key` | `VELLUM_API_KEY` | Shared owner/agent key (`X-Api-Key`) |
|
|
43
42
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
`vellum login` token is used.
|
|
43
|
+
The CLI always uses the stored `vellum login` token. Commands are scoped to
|
|
44
|
+
the logged-in page owner; the CLI does not accept the shared server API key.
|
|
47
45
|
|
|
48
46
|
## Commands
|
|
49
47
|
|
package/dist/index.js
CHANGED
|
@@ -15,13 +15,10 @@ function resolveBaseUrl(flags) {
|
|
|
15
15
|
return normalizeUrl(flags.url ?? process.env.VELLUM_URL ?? DEFAULT_URL);
|
|
16
16
|
}
|
|
17
17
|
async function resolveCredential(flags, baseUrl) {
|
|
18
|
-
const apiKey = flags.apiKey ?? process.env.VELLUM_API_KEY;
|
|
19
|
-
if (apiKey)
|
|
20
|
-
return { apiKey };
|
|
21
18
|
const token = await loadToken(baseUrl);
|
|
22
19
|
if (token)
|
|
23
20
|
return { token };
|
|
24
|
-
throw new ConfigError(`Not logged in to ${baseUrl}. Run \`vellum login
|
|
21
|
+
throw new ConfigError(`Not logged in to ${baseUrl}. Run \`vellum login\`.`);
|
|
25
22
|
}
|
|
26
23
|
function storePath() {
|
|
27
24
|
const xdg = process.env.XDG_CONFIG_HOME;
|
|
@@ -204,12 +201,11 @@ Usage:
|
|
|
204
201
|
vellum ${verb} <page-id> [options]
|
|
205
202
|
|
|
206
203
|
${verb === "archive" ? `Archiving keeps the bytes, versions, comments, and URLs intact — new
|
|
207
|
-
versions and comments are paused until you unarchive.
|
|
208
|
-
versions and comments.
|
|
204
|
+
versions and comments are paused until you unarchive. Page owner only.` : `Unarchiving restores the page to the gallery and re-opens it for new
|
|
205
|
+
versions and comments. Page owner only.`}
|
|
209
206
|
|
|
210
207
|
Options:
|
|
211
208
|
--url <url> Server base URL (env: VELLUM_URL)
|
|
212
|
-
--api-key <key> Shared API key (env: VELLUM_API_KEY)
|
|
213
209
|
--json Print the raw JSON response
|
|
214
210
|
-h, --help Show this help`;
|
|
215
211
|
}
|
|
@@ -219,7 +215,6 @@ async function run(verb, argv) {
|
|
|
219
215
|
allowPositionals: true,
|
|
220
216
|
options: {
|
|
221
217
|
url: { type: "string" },
|
|
222
|
-
"api-key": { type: "string" },
|
|
223
218
|
json: { type: "boolean", default: false },
|
|
224
219
|
help: { type: "boolean", short: "h", default: false }
|
|
225
220
|
}
|
|
@@ -235,7 +230,7 @@ async function run(verb, argv) {
|
|
|
235
230
|
console.error(help(verb));
|
|
236
231
|
return 1;
|
|
237
232
|
}
|
|
238
|
-
const flags = { url: values.url
|
|
233
|
+
const flags = { url: values.url };
|
|
239
234
|
const baseUrl = resolveBaseUrl(flags);
|
|
240
235
|
const credential = await resolveCredential(flags, baseUrl);
|
|
241
236
|
const client2 = new VellumClient({ baseUrl, ...credential });
|
|
@@ -249,7 +244,11 @@ async function run(verb, argv) {
|
|
|
249
244
|
return 0;
|
|
250
245
|
} catch (err) {
|
|
251
246
|
if (err instanceof VellumApiError && err.status === 401) {
|
|
252
|
-
console.error(`Error:
|
|
247
|
+
console.error(`Error: not logged in. Run \`vellum login\` as the page owner.`);
|
|
248
|
+
return 1;
|
|
249
|
+
}
|
|
250
|
+
if (err instanceof VellumApiError && err.status === 403) {
|
|
251
|
+
console.error(`Error: you don't own ${pageId}, so you can't ${verb} it.`);
|
|
253
252
|
return 1;
|
|
254
253
|
}
|
|
255
254
|
if (err instanceof VellumApiError && err.status === 404) {
|
|
@@ -268,19 +267,18 @@ function unarchiveCommand(argv) {
|
|
|
268
267
|
|
|
269
268
|
// src/commands/list.ts
|
|
270
269
|
import { parseArgs as parseArgs2 } from "node:util";
|
|
271
|
-
var HELP = `vellum list — list your artifacts
|
|
270
|
+
var HELP = `vellum list — list your artifacts
|
|
272
271
|
|
|
273
272
|
Usage:
|
|
274
273
|
vellum list [options]
|
|
275
274
|
|
|
276
|
-
|
|
277
|
-
|
|
275
|
+
Lists the pages you own (log in with \`vellum login\`). By default only live
|
|
276
|
+
pages are shown; use --archived for archived-only, or --all for both.
|
|
278
277
|
|
|
279
278
|
Options:
|
|
280
279
|
--archived Show only archived pages
|
|
281
280
|
--all Show both live and archived pages
|
|
282
281
|
--url <url> Server base URL (env: VELLUM_URL)
|
|
283
|
-
--api-key <key> Shared API key (env: VELLUM_API_KEY)
|
|
284
282
|
--json Print the raw JSON response
|
|
285
283
|
-h, --help Show this help`;
|
|
286
284
|
function cell(value, width) {
|
|
@@ -308,7 +306,6 @@ async function listCommand(argv) {
|
|
|
308
306
|
archived: { type: "boolean", default: false },
|
|
309
307
|
all: { type: "boolean", default: false },
|
|
310
308
|
url: { type: "string" },
|
|
311
|
-
"api-key": { type: "string" },
|
|
312
309
|
json: { type: "boolean", default: false },
|
|
313
310
|
help: { type: "boolean", short: "h", default: false }
|
|
314
311
|
}
|
|
@@ -317,7 +314,7 @@ async function listCommand(argv) {
|
|
|
317
314
|
console.log(HELP);
|
|
318
315
|
return 0;
|
|
319
316
|
}
|
|
320
|
-
const flags = { url: values.url
|
|
317
|
+
const flags = { url: values.url };
|
|
321
318
|
const baseUrl = resolveBaseUrl(flags);
|
|
322
319
|
const credential = await resolveCredential(flags, baseUrl);
|
|
323
320
|
const client2 = new VellumClient({ baseUrl, ...credential });
|
|
@@ -343,7 +340,7 @@ ${pages.length} page${pages.length === 1 ? "" : "s"}${suffix}`);
|
|
|
343
340
|
return 0;
|
|
344
341
|
} catch (err) {
|
|
345
342
|
if (err instanceof VellumApiError && err.status === 401) {
|
|
346
|
-
console.error("Error:
|
|
343
|
+
console.error("Error: not authenticated. Run `vellum login` as the page owner.");
|
|
347
344
|
return 1;
|
|
348
345
|
}
|
|
349
346
|
throw err;
|
|
@@ -484,7 +481,6 @@ Options:
|
|
|
484
481
|
--version <n> Pin to a specific version number (default: current)
|
|
485
482
|
--force Post even if the quote isn't found in the version
|
|
486
483
|
--url <url> Server base URL (env: VELLUM_URL)
|
|
487
|
-
--api-key <key> Shared API key (env: VELLUM_API_KEY)
|
|
488
484
|
--json Print the raw JSON response
|
|
489
485
|
-h, --help Show this help`;
|
|
490
486
|
async function readStdin() {
|
|
@@ -518,7 +514,6 @@ async function markupCommand(argv) {
|
|
|
518
514
|
version: { type: "string" },
|
|
519
515
|
force: { type: "boolean", default: false },
|
|
520
516
|
url: { type: "string" },
|
|
521
|
-
"api-key": { type: "string" },
|
|
522
517
|
json: { type: "boolean", default: false },
|
|
523
518
|
help: { type: "boolean", short: "h", default: false }
|
|
524
519
|
}
|
|
@@ -552,7 +547,7 @@ async function markupCommand(argv) {
|
|
|
552
547
|
return 1;
|
|
553
548
|
}
|
|
554
549
|
}
|
|
555
|
-
const flags = { url: values.url
|
|
550
|
+
const flags = { url: values.url };
|
|
556
551
|
const baseUrl = resolveBaseUrl(flags);
|
|
557
552
|
const credential = await resolveCredential(flags, baseUrl);
|
|
558
553
|
const client2 = new VellumClient({ baseUrl, ...credential });
|
|
@@ -598,7 +593,6 @@ Usage:
|
|
|
598
593
|
Options:
|
|
599
594
|
--page-id <id> Append a new version to an existing page
|
|
600
595
|
--url <url> Server base URL (env: VELLUM_URL)
|
|
601
|
-
--api-key <key> Shared API key (env: VELLUM_API_KEY)
|
|
602
596
|
--json Print the raw JSON response
|
|
603
597
|
-h, --help Show this help`;
|
|
604
598
|
async function readStdin2() {
|
|
@@ -614,7 +608,6 @@ async function pushCommand(argv) {
|
|
|
614
608
|
options: {
|
|
615
609
|
"page-id": { type: "string" },
|
|
616
610
|
url: { type: "string" },
|
|
617
|
-
"api-key": { type: "string" },
|
|
618
611
|
json: { type: "boolean", default: false },
|
|
619
612
|
help: { type: "boolean", short: "h", default: false }
|
|
620
613
|
}
|
|
@@ -629,7 +622,7 @@ async function pushCommand(argv) {
|
|
|
629
622
|
console.error("Error: no HTML provided (empty file or stdin).");
|
|
630
623
|
return 1;
|
|
631
624
|
}
|
|
632
|
-
const flags = { url: values.url
|
|
625
|
+
const flags = { url: values.url };
|
|
633
626
|
const baseUrl = resolveBaseUrl(flags);
|
|
634
627
|
const credential = await resolveCredential(flags, baseUrl);
|
|
635
628
|
const client2 = new VellumClient({ baseUrl, ...credential });
|
|
@@ -646,7 +639,7 @@ async function pushCommand(argv) {
|
|
|
646
639
|
// package.json
|
|
647
640
|
var package_default = {
|
|
648
641
|
name: "vellum-cli",
|
|
649
|
-
version: "0.3.
|
|
642
|
+
version: "0.3.4",
|
|
650
643
|
description: "The vellum CLI — publish agent-authored HTML artifacts to a Vellum server.",
|
|
651
644
|
type: "module",
|
|
652
645
|
license: "MIT",
|
|
@@ -700,14 +693,12 @@ Usage:
|
|
|
700
693
|
|
|
701
694
|
Options:
|
|
702
695
|
--url <url> Server base URL (env: VELLUM_URL)
|
|
703
|
-
--api-key <key> Shared API key (env: VELLUM_API_KEY)
|
|
704
696
|
-h, --help Show this help`;
|
|
705
697
|
async function whoamiCommand(argv) {
|
|
706
698
|
const { values } = parseArgs7({
|
|
707
699
|
args: argv,
|
|
708
700
|
options: {
|
|
709
701
|
url: { type: "string" },
|
|
710
|
-
"api-key": { type: "string" },
|
|
711
702
|
help: { type: "boolean", short: "h", default: false }
|
|
712
703
|
}
|
|
713
704
|
});
|
|
@@ -716,11 +707,7 @@ async function whoamiCommand(argv) {
|
|
|
716
707
|
return 0;
|
|
717
708
|
}
|
|
718
709
|
const baseUrl = resolveBaseUrl({ url: values.url });
|
|
719
|
-
const credential = await resolveCredential({ url: values.url
|
|
720
|
-
if ("apiKey" in credential) {
|
|
721
|
-
console.log(`Authenticated to ${baseUrl} with a shared API key (owner).`);
|
|
722
|
-
return 0;
|
|
723
|
-
}
|
|
710
|
+
const credential = await resolveCredential({ url: values.url }, baseUrl);
|
|
724
711
|
const client2 = new VellumClient({ baseUrl, token: credential.token });
|
|
725
712
|
const { email } = await client2.whoami();
|
|
726
713
|
console.log(`${email ?? "(no email on record)"} — ${baseUrl}`);
|
|
@@ -738,7 +725,7 @@ Commands:
|
|
|
738
725
|
logout Remove this machine's stored CLI token
|
|
739
726
|
whoami Show the identity the CLI is authenticated as
|
|
740
727
|
push Create an artifact (page) from HTML (file or stdin)
|
|
741
|
-
list List your
|
|
728
|
+
list List artifacts owned by your logged-in identity
|
|
742
729
|
markup Pin a comment to a passage of a document
|
|
743
730
|
archive Archive a page (read-only, hidden from the gallery)
|
|
744
731
|
unarchive Restore an archived page to live
|