@praeviso/code-env-switch 0.1.7 → 0.1.8

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.
@@ -40,6 +40,7 @@ function buildStatuslineResult(args, config, configPath) {
40
40
  const sessionId = (0, input_1.getSessionId)(stdinInput);
41
41
  const usageType = (0, type_1.normalizeType)(type || "");
42
42
  const stdinUsageTotals = (0, usage_2.getUsageTotalsFromInput)(stdinInput, usageType);
43
+ const shouldSyncUsageFromSessions = args.syncUsage && !stdinUsageTotals;
43
44
  const model = (0, utils_1.firstNonEmpty)(args.model, process.env.CODE_ENV_MODEL, (0, input_1.getModelFromInput)(stdinInput));
44
45
  const modelProvider = (0, utils_1.firstNonEmpty)(process.env.CODE_ENV_MODEL_PROVIDER, (0, input_1.getModelProviderFromInput)(stdinInput));
45
46
  (0, debug_1.appendStatuslineDebug)(configPath, {
@@ -86,7 +87,7 @@ function buildStatuslineResult(args, config, configPath) {
86
87
  usage.inputTokens !== null ||
87
88
  usage.outputTokens !== null;
88
89
  const stdinUsage = (0, usage_2.normalizeInputUsage)((0, input_1.getInputUsage)(stdinInput, usageType));
89
- const recordsUsage = (0, usage_2.resolveUsageFromRecords)(config, configPath, type, profileKey, profileName, args.syncUsage);
90
+ const recordsUsage = (0, usage_2.resolveUsageFromRecords)(config, configPath, type, profileKey, profileName, shouldSyncUsageFromSessions);
90
91
  let finalUsage = hasExplicitUsage ? usage : null;
91
92
  if (!finalUsage && args.syncUsage && recordsUsage) {
92
93
  finalUsage = recordsUsage;
@@ -131,12 +132,12 @@ function buildStatuslineResult(args, config, configPath) {
131
132
  }
132
133
  else {
133
134
  const sessionCostFromRecords = sessionId
134
- ? (0, usage_1.readUsageSessionCost)(config, configPath, type, sessionId, args.syncUsage)
135
+ ? (0, usage_1.readUsageSessionCost)(config, configPath, type, sessionId, shouldSyncUsageFromSessions)
135
136
  : null;
136
137
  sessionCost =
137
138
  sessionCostFromRecords !== null && sessionCostFromRecords !== void 0 ? sessionCostFromRecords : (sessionUsage ? (0, pricing_1.calculateUsageCost)(sessionUsage, pricing) : null);
138
139
  }
139
- const costIndex = (0, usage_1.readUsageCostIndex)(config, configPath, args.syncUsage);
140
+ const costIndex = (0, usage_1.readUsageCostIndex)(config, configPath, shouldSyncUsageFromSessions);
140
141
  const costTotals = costIndex
141
142
  ? (0, usage_1.resolveUsageCostForProfile)(costIndex, type, profileKey, profileName)
142
143
  : null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@praeviso/code-env-switch",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Switch between Claude Code and Codex environment variables from a single CLI",
5
5
  "bin": {
6
6
  "codenv": "bin/index.js"
@@ -99,6 +99,8 @@ export function buildStatuslineResult(
99
99
  const sessionId = getSessionId(stdinInput);
100
100
  const usageType = normalizeType(type || "");
101
101
  const stdinUsageTotals = getUsageTotalsFromInput(stdinInput, usageType);
102
+ const shouldSyncUsageFromSessions =
103
+ args.syncUsage && !stdinUsageTotals;
102
104
  const model = firstNonEmpty(
103
105
  args.model,
104
106
  process.env.CODE_ENV_MODEL,
@@ -184,7 +186,7 @@ export function buildStatuslineResult(
184
186
  type,
185
187
  profileKey,
186
188
  profileName,
187
- args.syncUsage
189
+ shouldSyncUsageFromSessions
188
190
  );
189
191
 
190
192
  let finalUsage: StatuslineUsage | null = hasExplicitUsage ? usage : null;
@@ -236,14 +238,18 @@ export function buildStatuslineResult(
236
238
  configPath,
237
239
  type,
238
240
  sessionId,
239
- args.syncUsage
241
+ shouldSyncUsageFromSessions
240
242
  )
241
243
  : null;
242
244
  sessionCost =
243
245
  sessionCostFromRecords ??
244
246
  (sessionUsage ? calculateUsageCost(sessionUsage, pricing) : null);
245
247
  }
246
- const costIndex = readUsageCostIndex(config, configPath, args.syncUsage);
248
+ const costIndex = readUsageCostIndex(
249
+ config,
250
+ configPath,
251
+ shouldSyncUsageFromSessions
252
+ );
247
253
  const costTotals = costIndex
248
254
  ? resolveUsageCostForProfile(costIndex, type, profileKey, profileName)
249
255
  : null;