@bragduck/cli 2.36.3 → 2.37.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 CHANGED
@@ -212,8 +212,6 @@ bragduck config set autoVersionCheck false
212
212
  - `defaultCommitDays` - Default days to scan (1-365, default: 30)
213
213
  - `autoVersionCheck` - Automatic version checking (true/false, default: true)
214
214
 
215
- **Note:** The API base URL is set to `https://api.bragduck.com` by default. You can override it using the `API_BASE_URL` environment variable if needed for custom deployments.
216
-
217
215
  #### `bragduck logout`
218
216
 
219
217
  Clear stored credentials from your system.
@@ -276,8 +274,6 @@ Configuration is stored in `~/.config/bragduck/config.json` (or equivalent on yo
276
274
  | `defaultCommitDays` | number | `30` | Default days to scan (1-365) |
277
275
  | `autoVersionCheck` | boolean | `true` | Automatic version checking |
278
276
 
279
- **API Base URL:** The CLI connects to `https://api.bragduck.com` by default. For custom deployments, set the `API_BASE_URL` environment variable.
280
-
281
277
  ### Credentials Storage
282
278
 
283
279
  Credentials are encrypted and stored at:
@@ -38,7 +38,8 @@ var init_constants = __esm({
38
38
  SOURCE_PRIORITY: "sourcePriority",
39
39
  JIRA_INSTANCE: "jiraInstance",
40
40
  CONFLUENCE_INSTANCE: "confluenceInstance",
41
- GITLAB_INSTANCE: "gitlabInstance"
41
+ GITLAB_INSTANCE: "gitlabInstance",
42
+ DEFAULT_COMPANY: "defaultCompany"
42
43
  };
43
44
  DEFAULT_CONFIG = {
44
45
  defaultCommitDays: 30,
@@ -47,7 +48,8 @@ var init_constants = __esm({
47
48
  sourcePriority: void 0,
48
49
  jiraInstance: void 0,
49
50
  confluenceInstance: void 0,
50
- gitlabInstance: void 0
51
+ gitlabInstance: void 0,
52
+ defaultCompany: void 0
51
53
  };
52
54
  OAUTH_CONFIG = {
53
55
  CLIENT_ID: "bragduck-cli",
@@ -1475,7 +1477,7 @@ var init_api_service = __esm({
1475
1477
  logger.debug("Token refreshed, retrying request");
1476
1478
  throw new Error("RETRY_WITH_NEW_TOKEN");
1477
1479
  } catch (error) {
1478
- if (error.message === "RETRY_WITH_NEW_TOKEN") {
1480
+ if (error instanceof Error && error.message === "RETRY_WITH_NEW_TOKEN") {
1479
1481
  throw error;
1480
1482
  }
1481
1483
  throw new TokenExpiredError(
@@ -1512,13 +1514,15 @@ var init_api_service = __esm({
1512
1514
  try {
1513
1515
  return await this.client(url, options);
1514
1516
  } catch (error) {
1515
- if (error.message === "RETRY_WITH_NEW_TOKEN") {
1517
+ if (error instanceof Error && error.message === "RETRY_WITH_NEW_TOKEN") {
1516
1518
  logger.debug("Retrying request with refreshed token");
1517
1519
  return await this.client(url, options);
1518
1520
  }
1519
- if (error.name === "FetchError" || error.code === "ECONNREFUSED") {
1521
+ const err = error instanceof Error ? error : new Error(String(error));
1522
+ const errCode = "code" in err ? err.code : void 0;
1523
+ if (err.name === "FetchError" || errCode === "ECONNREFUSED") {
1520
1524
  throw new NetworkError("Failed to connect to Bragduck API", {
1521
- originalError: error.message,
1525
+ originalError: err.message,
1522
1526
  baseURL: this.baseURL
1523
1527
  });
1524
1528
  }
@@ -1800,9 +1804,10 @@ var AtlassianAuthService = class {
1800
1804
  logger.debug("Atlassian token exchange successful");
1801
1805
  return response;
1802
1806
  } catch (error) {
1803
- logger.debug(`Atlassian token exchange failed: ${error.message}`);
1807
+ const message = error instanceof Error ? error.message : String(error);
1808
+ logger.debug(`Atlassian token exchange failed: ${message}`);
1804
1809
  throw new AtlassianError("Failed to exchange Atlassian authorization code", {
1805
- originalError: error.message
1810
+ originalError: message
1806
1811
  });
1807
1812
  }
1808
1813
  }
@@ -1824,9 +1829,10 @@ var AtlassianAuthService = class {
1824
1829
  logger.debug(`Found ${resources.length} accessible resource(s)`);
1825
1830
  return resources;
1826
1831
  } catch (error) {
1827
- logger.debug(`Failed to fetch accessible resources: ${error.message}`);
1832
+ const message = error instanceof Error ? error.message : String(error);
1833
+ logger.debug(`Failed to fetch accessible resources: ${message}`);
1828
1834
  throw new AtlassianError("Failed to fetch Atlassian Cloud sites", {
1829
- originalError: error.message
1835
+ originalError: message
1830
1836
  });
1831
1837
  }
1832
1838
  }
@@ -6968,8 +6974,7 @@ async function syncSingleService(sourceType, options, TOTAL_STEPS, sharedDays, s
6968
6974
  date: originalCommit?.date || (/* @__PURE__ */ new Date()).toISOString(),
6969
6975
  commit_url: originalCommit?.url || "",
6970
6976
  impactLevel: refined.suggested_impactLevel,
6971
- typeId: refined.suggested_typeId,
6972
- impact_score: refined.suggested_impactLevel,
6977
+ typeKey: refined.suggested_type_key,
6973
6978
  impactDescription: refined.impact_description,
6974
6979
  impact_description: refined.impact_description,
6975
6980
  attachments: originalCommit?.url ? [originalCommit.url] : [],
@@ -7549,6 +7554,32 @@ async function listCommand(options = {}) {
7549
7554
  if (!isAuthenticated) {
7550
7555
  process.exit(1);
7551
7556
  }
7557
+ const subSpinner = createValidateSpinner("Checking subscription...");
7558
+ subSpinner.start();
7559
+ let subscriptionStatus;
7560
+ try {
7561
+ subscriptionStatus = await apiService.getSubscriptionStatus();
7562
+ } catch (error) {
7563
+ failSpinner(subSpinner, "Failed to check subscription");
7564
+ throw error;
7565
+ }
7566
+ if (subscriptionStatus.tier === "FREE") {
7567
+ failSpinner(subSpinner, "Free plan \u2014 upgrade to use the CLI");
7568
+ logger.log("");
7569
+ logger.log(
7570
+ boxen7(
7571
+ theme.warning("CLI Access Requires Subscription") + "\n\nThe BragDuck CLI is available for Plus and Pro subscribers.\nUpgrade now to unlock:\n\n \u2022 List and manage your brags from the terminal\n \u2022 Automatic work item scanning\n \u2022 AI-powered brag generation\n\n" + colors.highlight("Upgrade at: https://bragduck.com/app/settings/plans"),
7572
+ {
7573
+ ...boxStyles.warning,
7574
+ padding: 1,
7575
+ margin: 1
7576
+ }
7577
+ )
7578
+ );
7579
+ logger.log("");
7580
+ return;
7581
+ }
7582
+ subSpinner.stop();
7552
7583
  const limit = options.limit || 50;
7553
7584
  const offset = options.offset || 0;
7554
7585
  const tags = options.tags ? options.tags.split(",").map((t) => t.trim()) : void 0;
@@ -7638,12 +7669,31 @@ function formatBragsTable(brags) {
7638
7669
  colors.info(repository)
7639
7670
  ]);
7640
7671
  });
7641
- return table.toString();
7672
+ const links = formatBragLinks(brags);
7673
+ return table.toString() + (links ? "\n\n" + links : "");
7674
+ }
7675
+ function formatBragLinks(brags) {
7676
+ const lines = brags.filter((brag) => brag.url || brag.goalIds && brag.goalIds.length > 0).map((brag) => {
7677
+ const parts = [` ${colors.white(brag.title)}`];
7678
+ if (brag.url) {
7679
+ parts.push(` ${colors.info(brag.url)}`);
7680
+ }
7681
+ if (brag.goalIds && brag.goalIds.length > 0) {
7682
+ parts.push(` ${colors.dim("Linked to key result:")} ${colors.primary(brag.goalIds[0])}`);
7683
+ }
7684
+ return parts.join("\n");
7685
+ });
7686
+ if (lines.length === 0) return "";
7687
+ return colors.primary("Brag links:") + "\n" + lines.join("\n\n");
7642
7688
  }
7643
7689
  function formatBragsOneline(brags) {
7644
7690
  return brags.map((brag) => {
7645
7691
  const date = formatDate(brag.date);
7646
- return `${colors.highlight(date)} ${colors.white(brag.title)}`;
7692
+ const urlLine = brag.url ? `
7693
+ ${colors.info(brag.url)}` : "";
7694
+ const goalLine = brag.goalIds && brag.goalIds.length > 0 ? `
7695
+ ${colors.dim("Linked to key result:")} ${colors.primary(brag.goalIds[0])}` : "";
7696
+ return `${colors.highlight(date)} ${colors.white(brag.title)}${urlLine}${goalLine}`;
7647
7697
  }).join("\n");
7648
7698
  }
7649
7699
  function truncateText(text, maxLength) {
@@ -7899,7 +7949,7 @@ Must be a valid hostname (e.g., company.atlassian.net, gitlab.company.com)`
7899
7949
  }
7900
7950
  }
7901
7951
  function getConfigHint(error) {
7902
- if (error.name === "ValidationError") {
7952
+ if (error instanceof Error && error.name === "ValidationError") {
7903
7953
  return 'Run "bragduck config list" to see all available configuration keys';
7904
7954
  }
7905
7955
  return 'Run "bragduck config --help" for usage information';