commet 1.5.0 → 1.7.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 (2) hide show
  1. package/dist/index.js +134 -158
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ var import_commander11 = require("commander");
30
30
  // package.json
31
31
  var package_default = {
32
32
  name: "commet",
33
- version: "1.5.0",
33
+ version: "1.7.0",
34
34
  description: "Commet CLI - Manage your billing platform from the command line",
35
35
  bin: {
36
36
  commet: "./bin/commet"
@@ -164,12 +164,7 @@ function clearProjectConfig() {
164
164
  }
165
165
 
166
166
  // src/utils/api.ts
167
- function getBaseURL(environment) {
168
- if (environment === "production") {
169
- return "https://commet.co";
170
- }
171
- return "https://sandbox.commet.co";
172
- }
167
+ var BASE_URL = "https://commet.co";
173
168
  async function apiRequest(endpoint, options = {}) {
174
169
  const auth = loadAuth();
175
170
  if (!auth) {
@@ -200,17 +195,34 @@ async function apiRequest(endpoint, options = {}) {
200
195
  }
201
196
 
202
197
  // src/utils/login-flow.ts
203
- var import_chalk = __toESM(require("chalk"));
198
+ var import_chalk2 = __toESM(require("chalk"));
204
199
  var import_open = __toESM(require("open"));
205
200
  var import_ora = __toESM(require("ora"));
201
+
202
+ // src/utils/prompt-theme.ts
203
+ var import_chalk = __toESM(require("chalk"));
204
+ var commetColor = import_chalk.default.hex("#e8a07c");
205
+ var promptTheme = {
206
+ prefix: commetColor("\u276F"),
207
+ style: {
208
+ answer: commetColor,
209
+ message: import_chalk.default.bold,
210
+ error: import_chalk.default.red,
211
+ help: import_chalk.default.dim,
212
+ highlight: commetColor.bold,
213
+ description: import_chalk.default.dim,
214
+ defaultAnswer: import_chalk.default.dim
215
+ }
216
+ };
217
+
218
+ // src/utils/login-flow.ts
206
219
  function sleep(ms) {
207
220
  return new Promise((resolve3) => setTimeout(resolve3, ms));
208
221
  }
209
- async function performLogin(environment) {
210
- const baseURL = getBaseURL(environment);
222
+ async function performLogin() {
211
223
  const spinner = (0, import_ora.default)("Initiating login flow...").start();
212
224
  try {
213
- const deviceResponse = await fetch(`${baseURL}/api/auth/device/code`, {
225
+ const deviceResponse = await fetch(`${BASE_URL}/api/auth/device/code`, {
214
226
  method: "POST",
215
227
  headers: { "Content-Type": "application/json" },
216
228
  body: JSON.stringify({
@@ -230,16 +242,16 @@ async function performLogin(environment) {
230
242
  interval = 5
231
243
  } = deviceData;
232
244
  spinner.stop();
233
- console.log(import_chalk.default.bold("\n\u{1F510} Commet CLI Login\n"));
245
+ console.log(import_chalk2.default.bold("\n\u{1F510} Commet CLI Login\n"));
234
246
  console.log("Visit the following URL in your browser:");
235
- console.log(import_chalk.default.cyan.underline(verification_uri_complete));
247
+ console.log(commetColor.underline(verification_uri_complete));
236
248
  console.log("\nOr enter this code manually:");
237
- console.log(import_chalk.default.bold.green(` ${user_code}`));
238
- console.log(import_chalk.default.dim("\nOpening browser...\n"));
249
+ console.log(import_chalk2.default.bold.green(` ${user_code}`));
250
+ console.log(import_chalk2.default.dim("\nOpening browser...\n"));
239
251
  try {
240
252
  await (0, import_open.default)(verification_uri_complete);
241
253
  } catch {
242
- console.log(import_chalk.default.yellow("\u26A0 Could not open browser automatically."));
254
+ console.log(import_chalk2.default.yellow("\u26A0 Could not open browser automatically."));
243
255
  }
244
256
  const pollSpinner = (0, import_ora.default)("Waiting for authorization...").start();
245
257
  let pollingInterval = interval;
@@ -249,7 +261,7 @@ async function performLogin(environment) {
249
261
  attempts++;
250
262
  await sleep(pollingInterval * 1e3);
251
263
  try {
252
- const tokenResponse = await fetch(`${baseURL}/api/auth/device/token`, {
264
+ const tokenResponse = await fetch(`${BASE_URL}/api/auth/device/token`, {
253
265
  method: "POST",
254
266
  headers: { "Content-Type": "application/json" },
255
267
  body: JSON.stringify({
@@ -261,8 +273,7 @@ async function performLogin(environment) {
261
273
  const tokenData = await tokenResponse.json();
262
274
  if (tokenData.access_token) {
263
275
  const authConfig = {
264
- token: tokenData.access_token,
265
- environment
276
+ token: tokenData.access_token
266
277
  };
267
278
  if (tokenData.refresh_token) {
268
279
  authConfig.refreshToken = tokenData.refresh_token;
@@ -304,23 +315,6 @@ async function performLogin(environment) {
304
315
  }
305
316
  }
306
317
 
307
- // src/utils/prompt-theme.ts
308
- var import_chalk2 = __toESM(require("chalk"));
309
- var commetColor = import_chalk2.default.hex("#5BC0B0");
310
- var promptTheme = {
311
- prefix: commetColor("\u276F"),
312
- style: {
313
- answer: commetColor,
314
- message: import_chalk2.default.bold,
315
- error: import_chalk2.default.red,
316
- help: import_chalk2.default.dim,
317
- highlight: commetColor.bold,
318
- // Selected option in mint
319
- description: import_chalk2.default.dim,
320
- defaultAnswer: import_chalk2.default.dim
321
- }
322
- };
323
-
324
318
  // src/commands/create.ts
325
319
  var GITHUB_REPO = "commet-labs/commet";
326
320
  var TEMPLATES = [
@@ -462,27 +456,29 @@ function copyEnvExample(dest) {
462
456
  fs2.copyFileSync(examplePath, envPath);
463
457
  }
464
458
  }
465
- function writeApiKeyToEnv(dest, apiKey, environment) {
459
+ function writeApiKeyToEnv(dest, apiKey) {
466
460
  const envPath = path2.join(dest, ".env");
467
461
  if (!fs2.existsSync(envPath)) return;
468
462
  let content = fs2.readFileSync(envPath, "utf-8");
469
463
  content = content.replace(/COMMET_API_KEY=.*/, `COMMET_API_KEY=${apiKey}`);
470
- content = content.replace(
471
- /COMMET_ENVIRONMENT=.*/,
472
- `COMMET_ENVIRONMENT=${environment}`
473
- );
474
464
  fs2.writeFileSync(envPath, content);
475
465
  }
476
- function linkProject(dest, orgId, orgName, environment) {
466
+ function linkProject(dest, orgId, orgName) {
477
467
  const commetDir = path2.join(dest, ".commet");
478
468
  fs2.mkdirSync(commetDir, { recursive: true });
479
469
  fs2.writeFileSync(
480
470
  path2.join(commetDir, "config.json"),
481
- JSON.stringify({ orgId, orgName, environment }, null, 2),
471
+ JSON.stringify({ orgId, orgName, mode: "sandbox" }, null, 2),
482
472
  "utf8"
483
473
  );
484
474
  }
485
- async function askSkills() {
475
+ function isInteractive() {
476
+ return process.stdin.isTTY === true;
477
+ }
478
+ async function resolveSkills(opts) {
479
+ if (typeof opts.skills === "boolean") return opts.skills;
480
+ if (opts.yes) return true;
481
+ if (!isInteractive()) return false;
486
482
  try {
487
483
  return await (0, import_prompts.confirm)({
488
484
  message: `Add ${commetColor("agent skills")}?`,
@@ -513,7 +509,7 @@ async function installSkills(projectRoot) {
513
509
  var createCommand = new import_commander.Command("create").description("Create a new Commet app from a template").argument("[name]", "Project name").option(
514
510
  "-t, --template <template>",
515
511
  "Template to use (fixed, seats, metered, credits, balance-ai, balance-fixed)"
516
- ).option("--ref <ref>", "Git ref to fetch templates from", "main").option("--list", "List available templates").action(async (argName, opts) => {
512
+ ).option("--org <slug>", "Organization slug or ID (skips selection)").option("--skills", "Install agent skills").option("--no-skills", "Skip agent skills installation").option("-y, --yes", "Accept defaults for optional prompts").option("--ref <ref>", "Git ref to fetch templates from", "main").option("--list", "List available templates").action(async (argName, opts) => {
517
513
  if (opts.list) {
518
514
  console.log(import_chalk3.default.bold("\nAvailable templates:\n"));
519
515
  for (const t of TEMPLATES) {
@@ -525,16 +521,23 @@ var createCommand = new import_commander.Command("create").description("Create a
525
521
  return;
526
522
  }
527
523
  let projectName = argName;
528
- try {
529
- if (!projectName) {
524
+ if (!projectName) {
525
+ if (!isInteractive()) {
526
+ console.log(import_chalk3.default.red("\u2717 Project name is required"));
527
+ console.log(
528
+ import_chalk3.default.dim("Pass as positional argument: commet create <name>")
529
+ );
530
+ return;
531
+ }
532
+ try {
530
533
  projectName = await (0, import_prompts.input)({
531
534
  message: "Project name:",
532
535
  theme: promptTheme
533
536
  });
537
+ } catch {
538
+ console.log(import_chalk3.default.yellow("\n\u26A0 Cancelled"));
539
+ return;
534
540
  }
535
- } catch {
536
- console.log(import_chalk3.default.yellow("\n\u26A0 Cancelled"));
537
- return;
538
541
  }
539
542
  const dest = path2.resolve(projectName);
540
543
  if (fs2.existsSync(dest)) {
@@ -544,65 +547,64 @@ var createCommand = new import_commander.Command("create").description("Create a
544
547
  return;
545
548
  }
546
549
  if (!authExists()) {
547
- let environment;
548
- try {
549
- environment = await (0, import_prompts.select)({
550
- message: "Environment:",
551
- choices: [
552
- {
553
- name: `Sandbox ${import_chalk3.default.dim("(Development)")}`,
554
- value: "sandbox"
555
- },
556
- { name: "Production", value: "production" }
557
- ],
558
- default: "sandbox",
559
- theme: promptTheme
560
- });
561
- } catch {
562
- console.log(import_chalk3.default.yellow("\n\u26A0 Cancelled"));
550
+ if (!isInteractive()) {
551
+ console.log(import_chalk3.default.red("\u2717 Not authenticated"));
552
+ console.log(import_chalk3.default.dim("Run `commet login` first"));
563
553
  return;
564
554
  }
565
- const loggedIn = await performLogin(environment);
555
+ const loggedIn = await performLogin();
566
556
  if (!loggedIn) {
567
557
  return;
568
558
  }
569
559
  }
570
- const auth = loadAuth();
571
- const baseURL = getBaseURL(auth.environment);
572
- if (auth.environment !== "sandbox") {
573
- console.log(
574
- import_chalk3.default.red(
575
- "\u2717 `commet create` is only available in sandbox environment"
576
- )
577
- );
578
- console.log(
579
- import_chalk3.default.dim("Run `commet logout` and login to sandbox to use templates")
580
- );
581
- return;
582
- }
583
- const orgsSpinner = (0, import_ora2.default)("Fetching organizations...").start();
584
- const orgsResult = await apiRequest(`${baseURL}/api/cli/organizations`);
560
+ const orgsSpinner = (0, import_ora2.default)("Fetching sandbox organizations...").start();
561
+ const orgsResult = await apiRequest(`${BASE_URL}/api/cli/organizations`);
585
562
  if (orgsResult.error || !orgsResult.data) {
586
563
  orgsSpinner.fail("Failed to fetch organizations");
587
564
  console.log(import_chalk3.default.dim(orgsResult.error));
588
565
  return;
589
566
  }
590
- const { organizations } = orgsResult.data;
567
+ const organizations = orgsResult.data.organizations.filter(
568
+ (org) => org.mode === "sandbox"
569
+ );
591
570
  orgsSpinner.stop();
592
571
  if (organizations.length === 0) {
593
- console.log(import_chalk3.default.yellow("\u26A0 No organizations found"));
572
+ console.log(import_chalk3.default.yellow("\u26A0 No sandbox organizations found"));
594
573
  console.log(
595
574
  import_chalk3.default.dim("Create an organization at https://commet.co first")
596
575
  );
597
576
  return;
598
577
  }
599
578
  let selectedOrg;
600
- if (organizations.length === 1) {
579
+ if (opts.org) {
580
+ const match = organizations.find(
581
+ (org) => org.slug === opts.org || org.id === opts.org
582
+ );
583
+ if (!match) {
584
+ console.log(import_chalk3.default.red(`\u2717 Organization "${opts.org}" not found`));
585
+ console.log(
586
+ import_chalk3.default.dim(
587
+ `Available: ${organizations.map((o) => o.slug).join(", ")}`
588
+ )
589
+ );
590
+ return;
591
+ }
592
+ selectedOrg = match;
593
+ } else if (organizations.length === 1) {
601
594
  selectedOrg = organizations[0];
602
595
  } else {
596
+ if (!isInteractive()) {
597
+ console.log(import_chalk3.default.red("\u2717 Organization is required"));
598
+ console.log(
599
+ import_chalk3.default.dim(
600
+ `Pass --org=<slug>. Available: ${organizations.map((o) => o.slug).join(", ")}`
601
+ )
602
+ );
603
+ return;
604
+ }
603
605
  try {
604
606
  const orgId = await (0, import_prompts.select)({
605
- message: "Organization:",
607
+ message: "Sandbox organization:",
606
608
  choices: organizations.map((org) => ({
607
609
  name: `${org.name} ${import_chalk3.default.dim(`(${org.slug})`)}`,
608
610
  value: org.id
@@ -623,8 +625,17 @@ var createCommand = new import_commander.Command("create").description("Create a
623
625
  );
624
626
  return;
625
627
  }
626
- try {
627
- if (!template) {
628
+ if (!template) {
629
+ if (!isInteractive()) {
630
+ console.log(import_chalk3.default.red("\u2717 Template is required"));
631
+ console.log(
632
+ import_chalk3.default.dim(
633
+ `Pass --template=<name>. Available: ${TEMPLATES.map((t) => t.name).join(", ")}`
634
+ )
635
+ );
636
+ return;
637
+ }
638
+ try {
628
639
  const selected = await (0, import_prompts.select)({
629
640
  message: "Billing model:",
630
641
  choices: TEMPLATES.map((t) => ({
@@ -634,12 +645,12 @@ var createCommand = new import_commander.Command("create").description("Create a
634
645
  theme: promptTheme
635
646
  });
636
647
  template = TEMPLATES.find((t) => t.name === selected);
648
+ } catch {
649
+ console.log(import_chalk3.default.yellow("\n\u26A0 Cancelled"));
650
+ return;
637
651
  }
638
- } catch {
639
- console.log(import_chalk3.default.yellow("\n\u26A0 Cancelled"));
640
- return;
641
652
  }
642
- const shouldInstallSkills = await askSkills();
653
+ const shouldInstallSkills = await resolveSkills(opts);
643
654
  const downloadSpinner = (0, import_ora2.default)("Downloading template...").start();
644
655
  try {
645
656
  await downloadTemplate(template.dir, dest, opts.ref);
@@ -675,7 +686,7 @@ var createCommand = new import_commander.Command("create").description("Create a
675
686
  return;
676
687
  }
677
688
  const planSpinner = (0, import_ora2.default)("Creating plans...").start();
678
- const templateResult = await apiRequest(`${baseURL}/api/cli/templates`, {
689
+ const templateResult = await apiRequest(`${BASE_URL}/api/cli/templates`, {
679
690
  method: "POST",
680
691
  body: JSON.stringify({
681
692
  templateId: template.templateId,
@@ -691,7 +702,7 @@ var createCommand = new import_commander.Command("create").description("Create a
691
702
  );
692
703
  }
693
704
  const keySpinner = (0, import_ora2.default)("Creating API key...").start();
694
- const keyResult = await apiRequest(`${baseURL}/api/cli/api-keys`, {
705
+ const keyResult = await apiRequest(`${BASE_URL}/api/cli/api-keys`, {
695
706
  method: "POST",
696
707
  body: JSON.stringify({
697
708
  organizationId: selectedOrg.id,
@@ -703,21 +714,21 @@ var createCommand = new import_commander.Command("create").description("Create a
703
714
  console.log(import_chalk3.default.dim(keyResult.error));
704
715
  console.log(import_chalk3.default.dim("You can create one manually in the dashboard"));
705
716
  } else {
706
- writeApiKeyToEnv(dest, keyResult.data.apiKey, auth.environment);
717
+ writeApiKeyToEnv(dest, keyResult.data.apiKey);
707
718
  keySpinner.succeed("API key created and saved to .env");
708
719
  }
709
- linkProject(dest, selectedOrg.id, selectedOrg.name, auth.environment);
720
+ linkProject(dest, selectedOrg.id, selectedOrg.name);
710
721
  if (shouldInstallSkills) {
711
722
  await installSkills(dest);
712
723
  }
713
724
  console.log(import_chalk3.default.green(`
714
725
  \u2713 Created ${projectName}`));
715
726
  console.log(import_chalk3.default.dim(` Template: ${template.name}`));
716
- console.log(import_chalk3.default.dim(` Organization: ${selectedOrg.name}`));
727
+ console.log(import_chalk3.default.dim(` Organization: ${selectedOrg.name} \xB7 sandbox`));
717
728
  console.log();
718
- console.log(` ${import_chalk3.default.cyan("cd")} ${projectName}`);
719
- console.log(` ${import_chalk3.default.cyan("npm install")}`);
720
- console.log(` ${import_chalk3.default.cyan("npm run dev")}`);
729
+ console.log(` ${commetColor("cd")} ${projectName}`);
730
+ console.log(` ${commetColor("npm install")}`);
731
+ console.log(` ${commetColor("npm run dev")}`);
721
732
  console.log();
722
733
  });
723
734
 
@@ -747,7 +758,7 @@ var infoCommand = new import_commander2.Command("info").description("Display inf
747
758
  console.log(import_chalk4.default.green("\nProject: Linked \u2713"));
748
759
  console.log(import_chalk4.default.dim(" Organization:"), projectConfig.orgName);
749
760
  console.log(import_chalk4.default.dim(" Organization ID:"), projectConfig.orgId);
750
- console.log(import_chalk4.default.dim(" Environment:"), projectConfig.environment);
761
+ console.log(import_chalk4.default.dim(" Mode:"), projectConfig.mode);
751
762
  console.log(
752
763
  import_chalk4.default.dim("\nRun `commet pull` to generate type definitions\n")
753
764
  );
@@ -803,7 +814,7 @@ var linkCommand = new import_commander3.Command("link").description("Link this p
803
814
  const config = loadProjectConfig();
804
815
  console.log(import_chalk5.default.yellow("\u26A0 This project is already linked"));
805
816
  console.log(
806
- import_chalk5.default.dim(`Organization: ${config?.orgName} (${config?.environment})`)
817
+ import_chalk5.default.dim(`Organization: ${config?.orgName} \xB7 ${config?.mode}`)
807
818
  );
808
819
  console.log(
809
820
  import_chalk5.default.dim(
@@ -813,15 +824,8 @@ var linkCommand = new import_commander3.Command("link").description("Link this p
813
824
  return;
814
825
  }
815
826
  const spinner = (0, import_ora3.default)("Fetching organizations...").start();
816
- const auth = loadAuth();
817
- if (!auth) {
818
- spinner.fail("Authentication error");
819
- console.log(import_chalk5.default.red("\u2717 Could not load authentication"));
820
- return;
821
- }
822
- const baseURL = getBaseURL(auth.environment);
823
827
  const result = await apiRequest(
824
- `${baseURL}/api/cli/organizations`
828
+ `${BASE_URL}/api/cli/organizations`
825
829
  );
826
830
  if (result.error || !result.data) {
827
831
  spinner.fail("Failed to fetch organizations");
@@ -843,7 +847,7 @@ var linkCommand = new import_commander3.Command("link").description("Link this p
843
847
  orgId = await (0, import_prompts2.select)({
844
848
  message: "Select organization:",
845
849
  choices: organizations.map((org) => ({
846
- name: `${org.name} ${import_chalk5.default.dim(`(${org.slug})`)}`,
850
+ name: `${org.name} ${import_chalk5.default.dim(`(${org.slug}) \xB7 ${org.mode}`)}`,
847
851
  value: org.id
848
852
  })),
849
853
  theme: promptTheme
@@ -860,12 +864,13 @@ var linkCommand = new import_commander3.Command("link").description("Link this p
860
864
  saveProjectConfig({
861
865
  orgId: selectedOrg.id,
862
866
  orgName: selectedOrg.name,
863
- environment: auth.environment
867
+ mode: selectedOrg.mode
864
868
  });
865
869
  const gitignoreResult = updateGitignore(".commet/");
866
870
  console.log(import_chalk5.default.green("\n\u2713 Project linked successfully"));
867
- console.log(import_chalk5.default.dim(`Organization: ${selectedOrg.name}`));
868
- console.log(import_chalk5.default.dim(`Environment: ${auth.environment}`));
871
+ console.log(
872
+ import_chalk5.default.dim(`Organization: ${selectedOrg.name} \xB7 ${selectedOrg.mode}`)
873
+ );
869
874
  if (gitignoreResult.success) {
870
875
  console.log(import_chalk5.default.green("\u2713 Updated .gitignore"));
871
876
  } else {
@@ -909,9 +914,8 @@ var listCommand = new import_commander4.Command("list").description("List featur
909
914
  return;
910
915
  }
911
916
  const spinner = (0, import_ora4.default)(`Fetching ${type}...`).start();
912
- const baseURL = getBaseURL(projectConfig.environment);
913
917
  const result = await apiRequest(
914
- `${baseURL}/api/cli/types?orgId=${projectConfig.orgId}`
918
+ `${BASE_URL}/api/cli/types?orgId=${projectConfig.orgId}`
915
919
  );
916
920
  if (result.error || !result.data) {
917
921
  spinner.fail(`Failed to fetch ${type}`);
@@ -983,7 +987,6 @@ var listCommand = new import_commander4.Command("list").description("List featur
983
987
  });
984
988
 
985
989
  // src/commands/login.ts
986
- var import_prompts3 = require("@inquirer/prompts");
987
990
  var import_chalk7 = __toESM(require("chalk"));
988
991
  var import_commander5 = require("commander");
989
992
  var loginCommand = new import_commander5.Command("login").description("Authenticate with Commet").action(async () => {
@@ -996,28 +999,7 @@ var loginCommand = new import_commander5.Command("login").description("Authentic
996
999
  );
997
1000
  return;
998
1001
  }
999
- let environment;
1000
- try {
1001
- environment = await (0, import_prompts3.select)({
1002
- message: "Select environment to login:",
1003
- choices: [
1004
- {
1005
- name: `Sandbox ${import_chalk7.default.dim("(Development)")}`,
1006
- value: "sandbox"
1007
- },
1008
- {
1009
- name: "Production",
1010
- value: "production"
1011
- }
1012
- ],
1013
- default: "sandbox",
1014
- theme: promptTheme
1015
- });
1016
- } catch {
1017
- console.log(import_chalk7.default.yellow("\n\u26A0 Login cancelled"));
1018
- return;
1019
- }
1020
- const success = await performLogin(environment);
1002
+ const success = await performLogin();
1021
1003
  if (success) {
1022
1004
  console.log(import_chalk7.default.green("\n\u2713 Authentication complete"));
1023
1005
  console.log(
@@ -1169,9 +1151,8 @@ var pullCommand = new import_commander7.Command("pull").description("Pull type d
1169
1151
  return;
1170
1152
  }
1171
1153
  const spinner = (0, import_ora5.default)("Fetching type definitions...").start();
1172
- const baseURL = getBaseURL(projectConfig.environment);
1173
1154
  const result = await apiRequest(
1174
- `${baseURL}/api/cli/types?orgId=${projectConfig.orgId}`
1155
+ `${BASE_URL}/api/cli/types?orgId=${projectConfig.orgId}`
1175
1156
  );
1176
1157
  if (result.error || !result.data) {
1177
1158
  spinner.fail("Failed to fetch types");
@@ -1241,7 +1222,7 @@ Output: ${outputPath}`));
1241
1222
  });
1242
1223
 
1243
1224
  // src/commands/switch.ts
1244
- var import_prompts4 = require("@inquirer/prompts");
1225
+ var import_prompts3 = require("@inquirer/prompts");
1245
1226
  var import_chalk10 = __toESM(require("chalk"));
1246
1227
  var import_commander8 = require("commander");
1247
1228
  var import_ora6 = __toESM(require("ora"));
@@ -1259,15 +1240,8 @@ var switchCommand = new import_commander8.Command("switch").description("Switch
1259
1240
  return;
1260
1241
  }
1261
1242
  const spinner = (0, import_ora6.default)("Fetching organizations...").start();
1262
- const auth = loadAuth();
1263
- if (!auth) {
1264
- spinner.fail("Authentication error");
1265
- console.log(import_chalk10.default.red("\u2717 Could not load authentication"));
1266
- return;
1267
- }
1268
- const baseURL = getBaseURL(auth.environment);
1269
1243
  const result = await apiRequest(
1270
- `${baseURL}/api/cli/organizations`
1244
+ `${BASE_URL}/api/cli/organizations`
1271
1245
  );
1272
1246
  if (result.error || !result.data) {
1273
1247
  spinner.fail("Failed to fetch organizations");
@@ -1283,10 +1257,10 @@ var switchCommand = new import_commander8.Command("switch").description("Switch
1283
1257
  spinner.stop();
1284
1258
  let orgId;
1285
1259
  try {
1286
- orgId = await (0, import_prompts4.select)({
1260
+ orgId = await (0, import_prompts3.select)({
1287
1261
  message: "Select organization:",
1288
1262
  choices: organizations.map((org) => ({
1289
- name: `${org.name} ${import_chalk10.default.dim(`(${org.slug})`)}`,
1263
+ name: `${org.name} ${import_chalk10.default.dim(`(${org.slug}) \xB7 ${org.mode}`)}`,
1290
1264
  value: org.id
1291
1265
  })),
1292
1266
  theme: promptTheme
@@ -1303,12 +1277,13 @@ var switchCommand = new import_commander8.Command("switch").description("Switch
1303
1277
  saveProjectConfig({
1304
1278
  orgId: selectedOrg.id,
1305
1279
  orgName: selectedOrg.name,
1306
- environment: auth.environment
1280
+ mode: selectedOrg.mode
1307
1281
  });
1308
1282
  console.log(import_chalk10.default.green("\n\u2713 Switched organization successfully!"));
1309
- console.log(import_chalk10.default.dim("\nNew configuration:"));
1310
- console.log(import_chalk10.default.dim(` Organization: ${selectedOrg.name}`));
1311
- console.log(import_chalk10.default.dim(` Environment: ${auth.environment}`));
1283
+ console.log(
1284
+ import_chalk10.default.dim(`
1285
+ Organization: ${selectedOrg.name} \xB7 ${selectedOrg.mode}`)
1286
+ );
1312
1287
  console.log(
1313
1288
  import_chalk10.default.dim(
1314
1289
  "\nRun `commet pull` to update TypeScript types for this organization"
@@ -1348,7 +1323,7 @@ var whoamiCommand = new import_commander10.Command("whoami").description("Displa
1348
1323
  if (projectConfig) {
1349
1324
  console.log(import_chalk12.default.bold("\nProject:"));
1350
1325
  console.log(import_chalk12.default.dim("Organization:"), projectConfig.orgName);
1351
- console.log(import_chalk12.default.dim("Environment:"), projectConfig.environment);
1326
+ console.log(import_chalk12.default.dim("Mode:"), projectConfig.mode);
1352
1327
  } else {
1353
1328
  console.log(import_chalk12.default.yellow("\n\u26A0 No project linked"));
1354
1329
  console.log(
@@ -1379,7 +1354,8 @@ try {
1379
1354
  program.parse(process.argv);
1380
1355
  } catch (error) {
1381
1356
  if (error instanceof Error) {
1382
- if (error.message.includes("outputHelp")) {
1357
+ const code = error.code;
1358
+ if (code === "commander.version" || code === "commander.help" || code === "commander.helpDisplayed") {
1383
1359
  process.exit(0);
1384
1360
  }
1385
1361
  console.error(import_chalk13.default.red("Error:"), error.message);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "commet",
3
- "version": "1.5.0",
3
+ "version": "1.7.0",
4
4
  "description": "Commet CLI - Manage your billing platform from the command line",
5
5
  "bin": {
6
6
  "commet": "./bin/commet"