@staff0rd/assist 0.123.0 → 0.124.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 +54 -26
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { Command } from "commander";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@staff0rd/assist",
9
- version: "0.123.0",
9
+ version: "0.124.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -8573,10 +8573,12 @@ function run2(name, args) {
8573
8573
  }
8574
8574
 
8575
8575
  // src/commands/statusLine.ts
8576
+ import chalk84 from "chalk";
8577
+
8578
+ // src/commands/buildLimitsSegment.ts
8576
8579
  import chalk83 from "chalk";
8577
- function formatNumber(num) {
8578
- return num.toLocaleString("en-US");
8579
- }
8580
+ var FIVE_HOUR_SECONDS = 5 * 3600;
8581
+ var SEVEN_DAY_SECONDS = 7 * 86400;
8580
8582
  function formatTimeLeft(resetsAt) {
8581
8583
  const seconds = Math.max(0, resetsAt - Math.floor(Date.now() / 1e3));
8582
8584
  const days = Math.floor(seconds / 86400);
@@ -8586,29 +8588,55 @@ function formatTimeLeft(resetsAt) {
8586
8588
  if (hours > 0) return `${hours}h ${minutes}m`;
8587
8589
  return `${minutes}m`;
8588
8590
  }
8589
- function colorizePercent(pct) {
8591
+ function projectUsage(pct, resetsAt, windowSeconds) {
8592
+ if (resetsAt == null) return void 0;
8593
+ const now = Math.floor(Date.now() / 1e3);
8594
+ const timeRemaining = Math.max(0, resetsAt - now);
8595
+ const elapsed = Math.max(0, windowSeconds - timeRemaining) / windowSeconds;
8596
+ if (elapsed < 0.05) return void 0;
8597
+ return pct / elapsed;
8598
+ }
8599
+ function colorizeRateLimit(pct, resetsAt, windowSeconds) {
8590
8600
  const label2 = `${Math.round(pct)}%`;
8591
- if (pct > 80) return chalk83.red(label2);
8592
- if (pct > 40) return chalk83.yellow(label2);
8593
- return label2;
8601
+ const projected = projectUsage(pct, resetsAt, windowSeconds);
8602
+ if (projected == null) return chalk83.green(label2);
8603
+ if (projected > 100) return chalk83.red(label2);
8604
+ if (projected > 75) return chalk83.yellow(label2);
8605
+ return chalk83.green(label2);
8594
8606
  }
8595
- function formatLimit(limit, fallbackLabel) {
8596
- const label2 = limit.resets_at ? formatTimeLeft(limit.resets_at) : fallbackLabel;
8597
- return `${colorizePercent(limit.used_percentage)} (${label2})`;
8607
+ function formatLimit(pct, resetsAt, windowSeconds, fallbackLabel) {
8608
+ const timeLabel = resetsAt ? formatTimeLeft(resetsAt) : fallbackLabel;
8609
+ return `${colorizeRateLimit(pct, resetsAt, windowSeconds)} (${timeLabel})`;
8598
8610
  }
8599
8611
  function buildLimitsSegment(rateLimits) {
8600
8612
  const fiveHrPct = rateLimits?.five_hour?.used_percentage;
8601
8613
  const sevenDayPct = rateLimits?.seven_day?.used_percentage;
8602
8614
  if (fiveHrPct == null || sevenDayPct == null) return "";
8603
- const fiveHr = {
8604
- used_percentage: fiveHrPct,
8605
- resets_at: rateLimits?.five_hour?.resets_at
8606
- };
8607
- const sevenDay = {
8608
- used_percentage: sevenDayPct,
8609
- resets_at: rateLimits?.seven_day?.resets_at
8610
- };
8611
- return ` | Limits - ${formatLimit(fiveHr, "5h")}, ${formatLimit(sevenDay, "7d")}`;
8615
+ const fiveHr = formatLimit(
8616
+ fiveHrPct,
8617
+ rateLimits?.five_hour?.resets_at,
8618
+ FIVE_HOUR_SECONDS,
8619
+ "5h"
8620
+ );
8621
+ const sevenDay = formatLimit(
8622
+ sevenDayPct,
8623
+ rateLimits?.seven_day?.resets_at,
8624
+ SEVEN_DAY_SECONDS,
8625
+ "7d"
8626
+ );
8627
+ return ` | Limits - ${fiveHr}, ${sevenDay}`;
8628
+ }
8629
+
8630
+ // src/commands/statusLine.ts
8631
+ chalk84.level = 3;
8632
+ function formatNumber(num) {
8633
+ return num.toLocaleString("en-US");
8634
+ }
8635
+ function colorizePercent(pct) {
8636
+ const label2 = `${Math.round(pct)}%`;
8637
+ if (pct > 80) return chalk84.red(label2);
8638
+ if (pct > 40) return chalk84.yellow(label2);
8639
+ return label2;
8612
8640
  }
8613
8641
  async function statusLine() {
8614
8642
  const inputData = await readStdin();
@@ -8630,7 +8658,7 @@ import { fileURLToPath as fileURLToPath7 } from "url";
8630
8658
  // src/commands/sync/syncClaudeMd.ts
8631
8659
  import * as fs22 from "fs";
8632
8660
  import * as path40 from "path";
8633
- import chalk84 from "chalk";
8661
+ import chalk85 from "chalk";
8634
8662
  async function syncClaudeMd(claudeDir, targetBase) {
8635
8663
  const source = path40.join(claudeDir, "CLAUDE.md");
8636
8664
  const target = path40.join(targetBase, "CLAUDE.md");
@@ -8639,12 +8667,12 @@ async function syncClaudeMd(claudeDir, targetBase) {
8639
8667
  const targetContent = fs22.readFileSync(target, "utf-8");
8640
8668
  if (sourceContent !== targetContent) {
8641
8669
  console.log(
8642
- chalk84.yellow("\n\u26A0\uFE0F Warning: CLAUDE.md differs from existing file")
8670
+ chalk85.yellow("\n\u26A0\uFE0F Warning: CLAUDE.md differs from existing file")
8643
8671
  );
8644
8672
  console.log();
8645
8673
  printDiff(targetContent, sourceContent);
8646
8674
  const confirm = await promptConfirm(
8647
- chalk84.red("Overwrite existing CLAUDE.md?"),
8675
+ chalk85.red("Overwrite existing CLAUDE.md?"),
8648
8676
  false
8649
8677
  );
8650
8678
  if (!confirm) {
@@ -8660,7 +8688,7 @@ async function syncClaudeMd(claudeDir, targetBase) {
8660
8688
  // src/commands/sync/syncSettings.ts
8661
8689
  import * as fs23 from "fs";
8662
8690
  import * as path41 from "path";
8663
- import chalk85 from "chalk";
8691
+ import chalk86 from "chalk";
8664
8692
  async function syncSettings(claudeDir, targetBase, options2) {
8665
8693
  const source = path41.join(claudeDir, "settings.json");
8666
8694
  const target = path41.join(targetBase, "settings.json");
@@ -8676,14 +8704,14 @@ async function syncSettings(claudeDir, targetBase, options2) {
8676
8704
  if (mergedContent !== normalizedTarget) {
8677
8705
  if (!options2?.yes) {
8678
8706
  console.log(
8679
- chalk85.yellow(
8707
+ chalk86.yellow(
8680
8708
  "\n\u26A0\uFE0F Warning: settings.json differs from existing file"
8681
8709
  )
8682
8710
  );
8683
8711
  console.log();
8684
8712
  printDiff(targetContent, mergedContent);
8685
8713
  const confirm = await promptConfirm(
8686
- chalk85.red("Overwrite existing settings.json?"),
8714
+ chalk86.red("Overwrite existing settings.json?"),
8687
8715
  false
8688
8716
  );
8689
8717
  if (!confirm) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.123.0",
3
+ "version": "0.124.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {