tokentracker-cli 0.14.0 → 0.14.2

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.
@@ -73,9 +73,59 @@ function relaunchWithProxyEnvIfNeeded({
73
73
  });
74
74
  }
75
75
 
76
+ function pickProxyUrl(env = process.env) {
77
+ return (
78
+ env.HTTPS_PROXY ||
79
+ env.https_proxy ||
80
+ env.HTTP_PROXY ||
81
+ env.http_proxy ||
82
+ env.ALL_PROXY ||
83
+ env.all_proxy ||
84
+ null
85
+ );
86
+ }
87
+
88
+ // Node's built-in NODE_USE_ENV_PROXY support only landed in v22.21 / v24.5.
89
+ // For older runtimes (including the v22.14 we historically embedded in the
90
+ // macOS app, and the v22.16 a community user hit on Discussion #68) the env
91
+ // var is silently ignored and fetch() bypasses the proxy. Setting an undici
92
+ // ProxyAgent dispatcher at startup gives us proxy support on every Node ≥ 18
93
+ // regardless of the env-proxy flag.
94
+ function applyUndiciProxyIfNeeded({
95
+ env = process.env,
96
+ setGlobalDispatcher,
97
+ ProxyAgent,
98
+ } = {}) {
99
+ const proxyUrl = pickProxyUrl(env);
100
+ if (!proxyUrl) return null;
101
+
102
+ let setter = setGlobalDispatcher;
103
+ let Agent = ProxyAgent;
104
+ if (!setter || !Agent) {
105
+ try {
106
+ // eslint-disable-next-line global-require
107
+ const undici = require("undici");
108
+ setter = setter || undici.setGlobalDispatcher;
109
+ Agent = Agent || undici.ProxyAgent;
110
+ } catch (_e) {
111
+ return null;
112
+ }
113
+ }
114
+ if (typeof setter !== "function" || typeof Agent !== "function") return null;
115
+
116
+ try {
117
+ setter(new Agent(proxyUrl));
118
+ return proxyUrl;
119
+ } catch (_e) {
120
+ return null;
121
+ }
122
+ }
123
+
76
124
  module.exports = {
77
125
  hasProxyEnv,
78
126
  parseMacProxyOutput,
127
+ pickProxyUrl,
79
128
  resolveSystemProxyEnv,
80
129
  relaunchWithProxyEnvIfNeeded,
130
+ applyUndiciProxyIfNeeded,
81
131
  };
@@ -1871,7 +1871,10 @@ function deriveProjectKeyFromRef(projectRef) {
1871
1871
  const parsed = new URL(projectRef);
1872
1872
  const segments = parsed.pathname.split("/").filter(Boolean);
1873
1873
  if (segments.length < 2) return null;
1874
- return `${segments[0]}/${segments[1]}`;
1874
+ // GitHub paths are always owner/repo, but GitLab supports nested groups
1875
+ // (group/subgroup/.../repo). Preserve the full path so nested-group repos
1876
+ // don't collapse to the first two segments.
1877
+ return segments.join("/");
1875
1878
  } catch (_e) {
1876
1879
  return null;
1877
1880
  }
@@ -5944,4 +5947,7 @@ module.exports = {
5944
5947
  totalsKey,
5945
5948
  claudeMessageDedupKey,
5946
5949
  groupBucketKey,
5950
+ // Exposed for regression tests covering nested-group remote URLs.
5951
+ canonicalizeProjectRef,
5952
+ deriveProjectKeyFromRef,
5947
5953
  };