@tenderprompt/cli 0.1.14 → 0.1.15

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 CHANGED
@@ -16,6 +16,7 @@ npm install -g @tenderprompt/cli
16
16
  Then run:
17
17
 
18
18
  ```bash
19
+ tender --version
19
20
  tender capabilities --json
20
21
  ```
21
22
 
@@ -25,6 +26,8 @@ Use the CLI to work with Tender Apps from a local checkout or coding-agent
25
26
  session:
26
27
 
27
28
  - sign in with a bounded device token and optional artifact scope
29
+ - print the installed CLI package version with `tender --version`, `tender -v`,
30
+ or `tender version --json`
28
31
  - list, create, and rename apps
29
32
  - bootstrap a local app checkout with Tender project context
30
33
  - configure the Tender artifact Git remote and credential helper
@@ -48,6 +51,7 @@ interactive prompts unless the command is explicitly an auth flow.
48
51
  ## Typical Flow
49
52
 
50
53
  ```bash
54
+ tender --version
51
55
  tender capabilities --json
52
56
 
53
57
  tender auth login --device --profile edit-preview --artifact artifact_123 --ttl 7d
@@ -120,6 +124,7 @@ indexing the accepted commit after upstream Git accepts the push.
120
124
  ## Useful Commands
121
125
 
122
126
  ```bash
127
+ tender --version
123
128
  tender capabilities --json
124
129
  tender app list --json
125
130
  tender app create --name "Exit Intent Widget" --json
package/bin/tender.js CHANGED
@@ -1,14 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { runTenderCli } from "../dist/index.js";
4
-
5
- function shouldReadEntrypointStdin(args) {
6
- return (
7
- args[0] === "artifacts" &&
8
- args[1] === "git" &&
9
- args[2] === "credential"
10
- );
11
- }
3
+ import { runTenderCli, shouldReadEntrypointStdin } from "../dist/index.js";
12
4
 
13
5
  async function readEntrypointStdin() {
14
6
  if (process.stdin.isTTY) {
package/dist/index.d.ts CHANGED
@@ -19,4 +19,5 @@ type TenderCommandResult = {
19
19
  stderr: string;
20
20
  };
21
21
  export declare function runTenderCli(args: string[], io?: TenderCliIo, runtime?: TenderCliRuntime): Promise<number>;
22
+ export declare function shouldReadEntrypointStdin(args: string[]): boolean;
22
23
  export {};
package/dist/index.js CHANGED
@@ -55,12 +55,14 @@ class TenderCliDbApiError extends Error {
55
55
  reasonCode;
56
56
  scope;
57
57
  example;
58
- constructor(message, reasonCode, scope, example) {
58
+ nextAction;
59
+ constructor(message, reasonCode, scope, example, nextAction = null) {
59
60
  super(message);
60
61
  this.name = "TenderCliDbApiError";
61
62
  this.reasonCode = reasonCode;
62
63
  this.scope = scope;
63
64
  this.example = example;
65
+ this.nextAction = nextAction;
64
66
  }
65
67
  }
66
68
  const DEFAULT_PROFILE_NAME = "default";
@@ -73,6 +75,8 @@ function rootHelp() {
73
75
  return `Usage: tender <command> [options]
74
76
 
75
77
  Commands:
78
+ tender --version
79
+ Show the installed Tender CLI version
76
80
  tender capabilities --json
77
81
  Describe the CLI command surface for coding agents
78
82
  tender auth login --device
@@ -126,6 +130,7 @@ Commands:
126
130
  Regenerate src/env.d.ts from app.json and bindings
127
131
 
128
132
  Examples:
133
+ tender --version
129
134
  tender capabilities --json
130
135
  tender auth login --device --profile edit-preview --artifact artifact_123 --ttl 7d
131
136
  tender auth status --json
@@ -315,6 +320,17 @@ copying long command lists into skill prompts.
315
320
  Examples:
316
321
  tender capabilities --json`;
317
322
  }
323
+ function versionHelp() {
324
+ return `Usage: tender --version
325
+ tender -v
326
+ tender version [--json]
327
+
328
+ Prints the installed Tender CLI package version.
329
+
330
+ Examples:
331
+ tender --version
332
+ tender version --json`;
333
+ }
318
334
  function analyticsHelp() {
319
335
  return `Usage: tender app analytics <command> <app-id> [options]
320
336
 
@@ -858,6 +874,7 @@ function tenderCliCapabilities() {
858
874
  discovery: {
859
875
  primary: "npm exec --yes @tenderprompt/cli@latest -- capabilities --json",
860
876
  layeredHelp: [
877
+ "tender --version",
861
878
  "tender --help",
862
879
  "tender auth --help",
863
880
  "tender app --help",
@@ -960,6 +977,18 @@ function tenderCliCapabilities() {
960
977
  },
961
978
  ],
962
979
  commands: [
980
+ {
981
+ command: "tender --version",
982
+ purpose: "Print the installed Tender CLI package version.",
983
+ requiresAuth: false,
984
+ writes: false,
985
+ },
986
+ {
987
+ command: "tender version --json",
988
+ purpose: "Print the installed Tender CLI package version in a stable JSON shape.",
989
+ requiresAuth: false,
990
+ writes: false,
991
+ },
963
992
  {
964
993
  command: "tender capabilities --json",
965
994
  purpose: "Discover this CLI surface in a machine-readable shape.",
@@ -1091,6 +1120,19 @@ function runCapabilities(command, io) {
1091
1120
  }
1092
1121
  return 0;
1093
1122
  }
1123
+ function runVersion(command, io) {
1124
+ if (command.json) {
1125
+ io.stdout(JSON.stringify({
1126
+ ok: true,
1127
+ name: CLI_PACKAGE_NAME,
1128
+ version: CLI_PACKAGE_VERSION,
1129
+ }, null, 2));
1130
+ }
1131
+ else {
1132
+ io.stdout(CLI_PACKAGE_VERSION);
1133
+ }
1134
+ return 0;
1135
+ }
1094
1136
  function normalizeBaseUrl(value) {
1095
1137
  return (value ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
1096
1138
  }
@@ -2595,6 +2637,20 @@ function parseCapabilitiesArgs(args) {
2595
2637
  }
2596
2638
  return { command: "capabilities", json };
2597
2639
  }
2640
+ function parseVersionArgs(args) {
2641
+ if (args.includes("--help") || args.includes("-h")) {
2642
+ return { command: "help", topic: "version" };
2643
+ }
2644
+ let json = false;
2645
+ for (const arg of args) {
2646
+ if (arg === "--json") {
2647
+ json = true;
2648
+ continue;
2649
+ }
2650
+ throw new TenderCliUsageError(`Unknown version option: ${arg}`);
2651
+ }
2652
+ return { command: "version", json };
2653
+ }
2598
2654
  function parseBindingId(value) {
2599
2655
  if (!value || value.startsWith("-")) {
2600
2656
  throw new TenderCliUsageError("--id requires a binding id.");
@@ -3746,6 +3802,12 @@ function parseTenderArgs(args) {
3746
3802
  if (args.length === 0 || args[0] === "--help" || args[0] === "-h") {
3747
3803
  return { command: "help", topic: "root" };
3748
3804
  }
3805
+ if (args[0] === "--version" || args[0] === "-v") {
3806
+ return parseVersionArgs(args.slice(1));
3807
+ }
3808
+ if (args[0] === "version") {
3809
+ return parseVersionArgs(args.slice(1));
3810
+ }
3749
3811
  if (args[0] === "capabilities") {
3750
3812
  return parseCapabilitiesArgs(args.slice(1));
3751
3813
  }
@@ -4345,6 +4407,9 @@ async function requestDbApi(input) {
4345
4407
  const message = (typeof payload?.message === "string" && payload.message) ||
4346
4408
  (typeof payload?.reasonCode === "string" && payload.reasonCode) ||
4347
4409
  `App database request failed with HTTP ${response.status}.`;
4410
+ const nextAction = typeof payload?.nextAction === "string" && payload.nextAction
4411
+ ? payload.nextAction
4412
+ : null;
4348
4413
  const example = dbCorrectedExample(input.artifactId, input.dbPath);
4349
4414
  throw new TenderCliDbApiError([
4350
4415
  message,
@@ -4354,7 +4419,10 @@ async function requestDbApi(input) {
4354
4419
  ].join("\n"), reasonCode, {
4355
4420
  artifactId: input.artifactId,
4356
4421
  surface: `db/${input.dbPath}`,
4357
- }, example);
4422
+ ...(input.scopeEnvironment ?? input.environment
4423
+ ? { environment: input.scopeEnvironment ?? input.environment }
4424
+ : {}),
4425
+ }, example, nextAction);
4358
4426
  }
4359
4427
  return payload;
4360
4428
  }
@@ -6770,6 +6838,7 @@ async function runDbQuery(command, io, runtime) {
6770
6838
  baseUrl: credentials.baseUrl,
6771
6839
  token: credentials.token,
6772
6840
  fetcher: runtime.fetcher ?? fetch,
6841
+ scopeEnvironment: command.environment,
6773
6842
  body,
6774
6843
  });
6775
6844
  const rows = Array.isArray(payload.rows) ? payload.rows : [];
@@ -7270,15 +7339,20 @@ function exampleForError(error, args, command) {
7270
7339
  const artifactId = artifactIdForError(args, command) ?? "artifact_123";
7271
7340
  return dbPath ? dbCorrectedExample(artifactId, dbPath) : null;
7272
7341
  }
7342
+ function nextActionForError(error) {
7343
+ return error instanceof TenderCliDbApiError ? error.nextAction : null;
7344
+ }
7273
7345
  function cliErrorPayload(error, args, command) {
7274
7346
  const scope = scopeForError(error, args, command);
7275
7347
  const example = exampleForError(error, args, command);
7348
+ const nextAction = nextActionForError(error);
7276
7349
  return {
7277
7350
  ok: false,
7278
7351
  command: commandNameForError(args, command),
7279
7352
  reasonCode: cliErrorCode(error),
7280
7353
  message: cliErrorMessage(error),
7281
7354
  ...(scope ? { scope } : {}),
7355
+ ...(nextAction ? { nextAction } : {}),
7282
7356
  ...(example ? { example } : {}),
7283
7357
  };
7284
7358
  }
@@ -7293,6 +7367,9 @@ export async function runTenderCli(args, io = {
7293
7367
  if (command.topic === "capabilities") {
7294
7368
  io.stdout(capabilitiesHelp());
7295
7369
  }
7370
+ else if (command.topic === "version") {
7371
+ io.stdout(versionHelp());
7372
+ }
7296
7373
  else if (command.topic === "auth login") {
7297
7374
  io.stdout(authLoginHelp());
7298
7375
  }
@@ -7439,6 +7516,9 @@ export async function runTenderCli(args, io = {
7439
7516
  if (command.command === "capabilities") {
7440
7517
  return runCapabilities(command, io);
7441
7518
  }
7519
+ if (command.command === "version") {
7520
+ return runVersion(command, io);
7521
+ }
7442
7522
  if (command.command === "auth login") {
7443
7523
  return await runAuthLogin(command, io, runtime);
7444
7524
  }
@@ -7575,7 +7655,7 @@ const currentFile = fileURLToPath(import.meta.url);
7575
7655
  function hasFlagValue(args, flag, value) {
7576
7656
  return args.some((arg, index) => (arg === flag && args[index + 1] === value) || arg === `${flag}=${value}`);
7577
7657
  }
7578
- function shouldReadEntrypointStdin(args) {
7658
+ export function shouldReadEntrypointStdin(args) {
7579
7659
  return (args[0] === "app" &&
7580
7660
  ((args[1] === "git" && args[2] === "credential") ||
7581
7661
  (args[1] === "analytics" && hasFlagValue(args, "--spec", "-")) ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenderprompt/cli",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "tender": "bin/tender.js"