claude-limitline 1.3.0 → 1.4.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 (3) hide show
  1. package/README.md +10 -9
  2. package/dist/index.js +19 -76
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -123,7 +123,7 @@ Create a `claude-limitline.json` file in your Claude config directory (`~/.claud
123
123
  | `weekly.displayStyle` | `"bar"` or `"text"` | `"text"` |
124
124
  | `weekly.barWidth` | Width of progress bar in characters | `10` |
125
125
  | `weekly.showWeekProgress` | Show week progress percentage | `true` |
126
- | `weekly.viewMode` | `"simple"`, `"detailed"`, or `"smart"` | `"simple"` |
126
+ | `weekly.viewMode` | `"simple"` or `"smart"` | `"simple"` |
127
127
  | `budget.pollInterval` | Minutes between API calls | `15` |
128
128
  | `budget.warningThreshold` | Percentage to trigger warning color | `80` |
129
129
  | `theme` | Color theme name | `"dark"` |
@@ -132,15 +132,16 @@ Create a `claude-limitline.json` file in your Claude config directory (`~/.claud
132
132
 
133
133
  ### Weekly View Modes
134
134
 
135
- The weekly segment supports three view modes for displaying usage limits:
135
+ The weekly segment supports two view modes for displaying usage limits:
136
+
137
+ ![Mode Preview](imgs/mode-preview.png)
136
138
 
137
139
  | Mode | Description | Example |
138
140
  |------|-------------|---------|
139
141
  | `simple` | Shows overall weekly usage only (default) | `○ 47% (wk 85%)` |
140
- | `detailed` | Shows overall, Opus, and Sonnet usage side by side | `○47% ◈15% ◇7%` |
141
- | `smart` | Shows the most restrictive (bottleneck) limit with indicator | `○47%▲ (wk 85%)` |
142
+ | `smart` | Model-aware: shows Sonnet + Overall when using Sonnet | `◇7% \| ○47% (wk 85%)` |
142
143
 
143
- **Note:** Model-specific limits (Opus/Sonnet) are only available on certain subscription tiers. When a model-specific limit is not available, it will be hidden from the display.
144
+ **Note:** Model-specific limits (Opus/Sonnet) are only available on certain subscription tiers. Smart mode shows only overall usage when using Opus/Haiku, and shows both Sonnet and overall when using Sonnet.
144
145
 
145
146
  ### Available Themes
146
147
 
@@ -190,7 +191,7 @@ npm run dev # Watch mode
190
191
 
191
192
  ## Testing
192
193
 
193
- The project uses [Vitest](https://vitest.dev/) for testing with 166 tests covering config loading, themes, segments, utilities, and rendering.
194
+ The project uses [Vitest](https://vitest.dev/) for testing with 164 tests covering config loading, themes, segments, utilities, and rendering.
194
195
 
195
196
  ```bash
196
197
  npm test # Run tests once
@@ -205,13 +206,13 @@ npm run test:coverage # Coverage report
205
206
  | `src/config/loader.test.ts` | 7 | Config loading, merging, fallbacks |
206
207
  | `src/themes/index.test.ts` | 37 | Theme retrieval, color validation |
207
208
  | `src/segments/block.test.ts` | 8 | Block segment, time calculations |
208
- | `src/segments/weekly.test.ts` | 10 | Weekly segment, week progress |
209
- | `src/utils/oauth.test.ts` | 10 | API responses, caching |
209
+ | `src/segments/weekly.test.ts` | 13 | Weekly segment, week progress |
210
+ | `src/utils/oauth.test.ts` | 13 | API responses, caching, trends |
210
211
  | `src/utils/claude-hook.test.ts` | 21 | Model name formatting |
211
212
  | `src/utils/environment.test.ts` | 20 | Git branch, directory detection |
212
213
  | `src/utils/terminal.test.ts` | 13 | Terminal width, ANSI handling |
213
214
  | `src/utils/logger.test.ts` | 8 | Debug/error logging |
214
- | `src/renderer.test.ts` | 21 | Segment rendering, ordering |
215
+ | `src/renderer.test.ts` | 24 | Segment rendering, ordering, view modes |
215
216
 
216
217
  ## Debug Mode
217
218
 
package/dist/index.js CHANGED
@@ -806,94 +806,39 @@ var Renderer = class {
806
806
  colors: this.theme.weekly
807
807
  };
808
808
  }
809
- renderWeeklyDetailed(ctx) {
809
+ renderWeeklySmart(ctx) {
810
810
  const info = ctx.weeklyInfo;
811
811
  const overallIcon = this.usePowerline ? this.symbols.weekly : "All";
812
- const opusIcon = this.usePowerline ? this.symbols.opus : "Op";
813
812
  const sonnetIcon = this.usePowerline ? this.symbols.sonnet : "So";
814
- const parts = [];
815
- if (info.percentUsed !== null) {
816
- const trend = this.getTrendSymbol(ctx.trendInfo?.sevenDayTrend ?? null);
817
- parts.push(`${overallIcon}${Math.round(info.percentUsed)}%${trend}`);
818
- }
819
- if (info.opusPercentUsed !== null) {
820
- const trend = this.getTrendSymbol(ctx.trendInfo?.sevenDayOpusTrend ?? null);
821
- parts.push(`${opusIcon}${Math.round(info.opusPercentUsed)}%${trend}`);
822
- }
823
- if (info.sonnetPercentUsed !== null) {
824
- const trend = this.getTrendSymbol(ctx.trendInfo?.sevenDaySonnetTrend ?? null);
825
- parts.push(`${sonnetIcon}${Math.round(info.sonnetPercentUsed)}%${trend}`);
826
- }
827
- if (parts.length === 0) {
813
+ const showWeekProgress = this.config.weekly?.showWeekProgress ?? true;
814
+ const currentModel = ctx.envInfo.model?.toLowerCase() ?? "";
815
+ const isSonnet = currentModel.includes("sonnet");
816
+ if (isSonnet && info.sonnetPercentUsed !== null && info.percentUsed !== null) {
817
+ const sonnetTrend = this.getTrendSymbol(ctx.trendInfo?.sevenDaySonnetTrend ?? null);
818
+ const overallTrend = this.getTrendSymbol(ctx.trendInfo?.sevenDayTrend ?? null);
819
+ let text2 = `${sonnetIcon}${Math.round(info.sonnetPercentUsed)}%${sonnetTrend} | ${overallIcon}${Math.round(info.percentUsed)}%${overallTrend}`;
820
+ if (showWeekProgress && !ctx.compact) {
821
+ text2 += ` (wk ${info.weekProgressPercent}%)`;
822
+ }
823
+ const maxPercent = Math.max(info.sonnetPercentUsed, info.percentUsed);
824
+ const colors2 = this.getColorsForPercent(maxPercent, this.theme.weekly);
828
825
  return {
829
- text: ` ${overallIcon} -- `,
830
- colors: this.theme.weekly
826
+ text: ` ${text2} `,
827
+ colors: colors2
831
828
  };
832
829
  }
833
- const separator = ctx.compact ? " " : " ";
834
- const text = parts.join(separator);
835
- const maxPercent = Math.max(
836
- info.percentUsed ?? 0,
837
- info.opusPercentUsed ?? 0,
838
- info.sonnetPercentUsed ?? 0
839
- );
840
- const colors = this.getColorsForPercent(maxPercent, this.theme.weekly);
841
- return {
842
- text: ` ${text} `,
843
- colors
844
- };
845
- }
846
- renderWeeklySmart(ctx) {
847
- const info = ctx.weeklyInfo;
848
- const overallIcon = this.usePowerline ? this.symbols.weekly : "All";
849
- const opusIcon = this.usePowerline ? this.symbols.opus : "Op";
850
- const sonnetIcon = this.usePowerline ? this.symbols.sonnet : "So";
851
- const limits = [];
852
- if (info.percentUsed !== null) {
853
- limits.push({
854
- name: "all",
855
- icon: overallIcon,
856
- percent: info.percentUsed,
857
- trend: ctx.trendInfo?.sevenDayTrend ?? null,
858
- colors: this.theme.weekly
859
- });
860
- }
861
- if (info.opusPercentUsed !== null) {
862
- limits.push({
863
- name: "opus",
864
- icon: opusIcon,
865
- percent: info.opusPercentUsed,
866
- trend: ctx.trendInfo?.sevenDayOpusTrend ?? null,
867
- colors: this.theme.opus
868
- });
869
- }
870
- if (info.sonnetPercentUsed !== null) {
871
- limits.push({
872
- name: "sonnet",
873
- icon: sonnetIcon,
874
- percent: info.sonnetPercentUsed,
875
- trend: ctx.trendInfo?.sevenDaySonnetTrend ?? null,
876
- colors: this.theme.sonnet
877
- });
878
- }
879
- if (limits.length === 0) {
830
+ if (info.percentUsed === null) {
880
831
  return {
881
832
  text: ` ${overallIcon} -- `,
882
833
  colors: this.theme.weekly
883
834
  };
884
835
  }
885
- const bottleneck = limits.reduce((a, b) => a.percent >= b.percent ? a : b);
886
- const trend = this.getTrendSymbol(bottleneck.trend);
887
- const bottleneckIndicator = limits.length > 1 ? this.symbols.bottleneck : "";
888
- let text = `${bottleneck.icon}${Math.round(bottleneck.percent)}%${trend}`;
889
- if (bottleneckIndicator && !ctx.compact) {
890
- text += bottleneckIndicator;
891
- }
892
- const showWeekProgress = this.config.weekly?.showWeekProgress ?? true;
836
+ const trend = this.getTrendSymbol(ctx.trendInfo?.sevenDayTrend ?? null);
837
+ let text = `${overallIcon}${Math.round(info.percentUsed)}%${trend}`;
893
838
  if (showWeekProgress && !ctx.compact) {
894
839
  text += ` (wk ${info.weekProgressPercent}%)`;
895
840
  }
896
- const colors = this.getColorsForPercent(bottleneck.percent, bottleneck.colors);
841
+ const colors = this.getColorsForPercent(info.percentUsed, this.theme.weekly);
897
842
  return {
898
843
  text: ` ${text} `,
899
844
  colors
@@ -905,8 +850,6 @@ var Renderer = class {
905
850
  }
906
851
  const viewMode = this.config.weekly?.viewMode ?? "simple";
907
852
  switch (viewMode) {
908
- case "detailed":
909
- return this.renderWeeklyDetailed(ctx);
910
853
  case "smart":
911
854
  return this.renderWeeklySmart(ctx);
912
855
  case "simple":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-limitline",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "A statusline for Claude Code showing real-time usage limits and weekly tracking",
5
5
  "main": "dist/index.js",
6
6
  "bin": {