copilot-statusline 0.1.7 → 0.1.9

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
@@ -87,23 +87,24 @@ The interactive configuration tool provides a terminal UI where you can:
87
87
 
88
88
  > 💡 **Tip:** Your settings are automatically saved to `~/.config/copilot-statusline/settings.json`
89
89
 
90
- ### Copilot CLI config.json format
90
+ ### Copilot CLI Integration
91
91
 
92
- When you install from the TUI, copilot-statusline writes a `statusLine` command object to your Copilot CLI config:
92
+ When you install from the TUI, copilot-statusline creates a launcher script at `~/.copilot/statusline.sh` that uses `bunx`/`npx` to always run the latest version — **no manual upgrades needed**.
93
+
94
+ It also writes to your Copilot CLI config:
93
95
 
94
96
  ```json
97
+ // ~/.copilot/config.json
95
98
  {
96
99
  "statusLine": {
97
100
  "type": "command",
98
- "command": "npx -y copilot-statusline@latest",
101
+ "command": "/Users/you/.copilot/statusline.sh",
99
102
  "padding": 0
100
103
  }
101
104
  }
102
105
  ```
103
106
 
104
- Other supported command values:
105
- - `bunx -y copilot-statusline@latest`
106
- - `copilot-statusline` (for global installs)
107
+ > 💡 **Auto-upgrade:** The launcher script runs `bunx -y copilot-statusline@latest` (or `npx` if you used npm to run the TUI) under the hood, so you always get the latest version automatically.
107
108
 
108
109
  **Settings location:** `~/.copilot/config.json` (or use `--config-dir` with Copilot CLI to change)
109
110
 
@@ -513,7 +514,7 @@ opus-4.6 | 3x | Ctx: 18.0% | Reqs: 3 | Session: <1m ⎇ main
513
514
  ### Setup
514
515
 
515
516
  ```bash
516
- git clone https://github.com/user/copilot-statusline.git
517
+ git clone https://github.com/EncodeTS/copilot-statusline.git
517
518
  cd copilot-statusline
518
519
  bun install
519
520
  ```
@@ -52574,7 +52574,6 @@ import { execSync } from "child_process";
52574
52574
  import * as fs3 from "fs";
52575
52575
  import * as os4 from "os";
52576
52576
  import * as path2 from "path";
52577
- var __dirname = "/Users/ts/workspace/active/statusline/copilot_statusline/src/utils";
52578
52577
  function getCopilotConfigDir() {
52579
52578
  return path2.join(os4.homedir(), ".copilot");
52580
52579
  }
@@ -52618,28 +52617,6 @@ function isInstalled() {
52618
52617
  function isKnownCommand(command) {
52619
52618
  return command.includes("copilot-statusline") || command.includes("statusline.sh") || command.includes("statusline.cmd");
52620
52619
  }
52621
- function findJsPath() {
52622
- const bunGlobal = path2.join(os4.homedir(), ".bun", "install", "global", "node_modules", "copilot-statusline", "dist", "copilot-statusline.js");
52623
- if (fs3.existsSync(bunGlobal)) {
52624
- return bunGlobal;
52625
- }
52626
- try {
52627
- const npmRoot = execSync("npm root -g", { encoding: "utf-8" }).trim();
52628
- const npmGlobal = path2.join(npmRoot, "copilot-statusline", "dist", "copilot-statusline.js");
52629
- if (fs3.existsSync(npmGlobal)) {
52630
- return npmGlobal;
52631
- }
52632
- } catch {}
52633
- const localDist = path2.resolve(__dirname, "..", "..", "dist", "copilot-statusline.js");
52634
- if (fs3.existsSync(localDist)) {
52635
- return localDist;
52636
- }
52637
- const bundledPath = path2.resolve(__dirname, "copilot-statusline.js");
52638
- if (fs3.existsSync(bundledPath)) {
52639
- return bundledPath;
52640
- }
52641
- return null;
52642
- }
52643
52620
  function findRuntime() {
52644
52621
  const isBunRuntime = typeof Bun !== "undefined" || process.env.BUN_INSTALL !== undefined || (process.argv[0] ?? "").includes("bun");
52645
52622
  if (isBunRuntime) {
@@ -52651,38 +52628,34 @@ function findRuntime() {
52651
52628
  } catch {}
52652
52629
  return "node";
52653
52630
  }
52654
- function generateUnixScript(jsPath) {
52631
+ function generateUnixScript() {
52655
52632
  const runtime = findRuntime();
52633
+ const runner = runtime === "bun" ? "bunx" : "npx";
52656
52634
  return `#!/bin/bash
52657
52635
  # copilot-statusline — auto-generated launcher
52636
+ # Uses ${runner} to always run the latest version.
52658
52637
  # Buffers stdin because Copilot CLI closes the pipe before slow runtimes start.
52659
- JS="${jsPath}"
52660
- RT="${runtime}"
52661
52638
  if [ -t 0 ]; then
52662
- exec "$RT" "$JS" "$@"
52639
+ exec ${runner} -y copilot-statusline@latest "$@"
52663
52640
  else
52664
52641
  INPUT=$(cat)
52665
- echo "$INPUT" | exec "$RT" "$JS" "$@"
52642
+ echo "$INPUT" | exec ${runner} -y copilot-statusline@latest "$@"
52666
52643
  fi
52667
52644
  `;
52668
52645
  }
52669
- function generateWindowsScript(jsPath) {
52646
+ function generateWindowsScript() {
52670
52647
  const runtime = findRuntime();
52648
+ const runner = runtime === "bun" ? "bunx" : "npx";
52671
52649
  return `@echo off\r
52672
- set "RT=${runtime}"\r
52673
- "%RT%" "${jsPath}" %*\r
52650
+ ${runner} -y copilot-statusline@latest %*\r
52674
52651
  `;
52675
52652
  }
52676
52653
  function installStatusLine() {
52677
- const jsPath = findJsPath();
52678
- if (!jsPath) {
52679
- throw new Error("Could not find copilot-statusline.js. Install globally first: bun install -g copilot-statusline");
52680
- }
52681
52654
  const scriptPath = getScriptPath();
52682
52655
  if (process.platform === "win32") {
52683
- fs3.writeFileSync(scriptPath, generateWindowsScript(jsPath));
52656
+ fs3.writeFileSync(scriptPath, generateWindowsScript());
52684
52657
  } else {
52685
- fs3.writeFileSync(scriptPath, generateUnixScript(jsPath));
52658
+ fs3.writeFileSync(scriptPath, generateUnixScript());
52686
52659
  fs3.chmodSync(scriptPath, 493);
52687
52660
  }
52688
52661
  const config2 = loadCopilotConfig() ?? {};
@@ -52940,7 +52913,7 @@ import { execSync as execSync3 } from "child_process";
52940
52913
  import * as fs5 from "fs";
52941
52914
  import * as path4 from "path";
52942
52915
  var __dirname = "/Users/ts/workspace/active/statusline/copilot_statusline/src/utils";
52943
- var PACKAGE_VERSION = "0.1.7";
52916
+ var PACKAGE_VERSION = "0.1.9";
52944
52917
  function getPackageVersion() {
52945
52918
  if (/^\d+\.\d+\.\d+/.test(PACKAGE_VERSION)) {
52946
52919
  return PACKAGE_VERSION;
@@ -54103,15 +54076,17 @@ function getContextWindowMetrics(data) {
54103
54076
  }
54104
54077
  const rawUsedPercentage = toFiniteNonNegativeNumber(contextWindow.used_percentage);
54105
54078
  const rawRemainingPercentage = toFiniteNonNegativeNumber(contextWindow.remaining_percentage);
54079
+ const usedTokensFromRemaining = windowSize !== null && remainingTokens !== null ? windowSize - remainingTokens : null;
54106
54080
  const usedTokensFromPercentage = rawUsedPercentage !== null && windowSize !== null ? rawUsedPercentage / 100 * windowSize : null;
54107
- const usedTokens = currentUsageTotalTokens ?? usedTokensFromPercentage;
54081
+ const usedTokens = usedTokensFromRemaining ?? usedTokensFromPercentage ?? currentUsageTotalTokens;
54108
54082
  const usedPercentage = rawUsedPercentage !== null ? clampPercentage(rawUsedPercentage) : usedTokens !== null && windowSize !== null && windowSize > 0 ? clampPercentage(usedTokens / windowSize * 100) : null;
54109
54083
  const remainingPercentage = rawRemainingPercentage !== null ? clampPercentage(rawRemainingPercentage) : usedPercentage !== null ? 100 - usedPercentage : null;
54110
54084
  const totalTokens = currentUsageTotalTokens ?? toFiniteNonNegativeNumber(contextWindow.total_tokens) ?? (totalInputTokens !== null && totalOutputTokens !== null ? totalInputTokens + totalOutputTokens : null);
54085
+ const contextLengthFromAuthoritative = usedTokensFromRemaining ?? usedTokensFromPercentage;
54111
54086
  return {
54112
54087
  windowSize,
54113
54088
  usedTokens,
54114
- contextLengthTokens: contextLengthTokens ?? usedTokens,
54089
+ contextLengthTokens: contextLengthFromAuthoritative ?? contextLengthTokens ?? usedTokens,
54115
54090
  usedPercentage,
54116
54091
  remainingPercentage,
54117
54092
  totalInputTokens,
@@ -54525,17 +54500,14 @@ class ContextBarWidget {
54525
54500
  render(item, context, settings) {
54526
54501
  const displayMode = getDisplayMode(item);
54527
54502
  const barWidth = displayMode === "progress" ? 32 : 16;
54528
- const powerlineMode = settings.powerline?.enabled === true;
54503
+ const powerlineMode = settings.powerline.enabled;
54529
54504
  if (context.isPreview) {
54530
54505
  const previewDisplay = `${makeUsageProgressBar(25, barWidth, powerlineMode)} 50k/200k (25%)`;
54531
54506
  return item.rawValue ? previewDisplay : `Context: ${previewDisplay}`;
54532
54507
  }
54533
54508
  const contextWindowMetrics = getContextWindowMetrics(context.data);
54534
- let total = contextWindowMetrics.windowSize;
54509
+ const total = contextWindowMetrics.windowSize;
54535
54510
  const used = contextWindowMetrics.contextLengthTokens;
54536
- if (total === null) {
54537
- total = contextWindowMetrics.windowSize;
54538
- }
54539
54511
  if (used === null || total === null || total <= 0) {
54540
54512
  return null;
54541
54513
  }
@@ -62905,11 +62877,9 @@ var App2 = () => {
62905
62877
  const [powerlineFontStatus, setPowerlineFontStatus] = import_react45.useState({ installed: false });
62906
62878
  const [installingFonts, setInstallingFonts] = import_react45.useState(false);
62907
62879
  const [fontInstallMessage, setFontInstallMessage] = import_react45.useState(null);
62908
- const [existingStatusLine, setExistingStatusLine] = import_react45.useState(null);
62909
62880
  const [flashMessage, setFlashMessage] = import_react45.useState(null);
62910
62881
  const [previewIsTruncated, setPreviewIsTruncated] = import_react45.useState(false);
62911
62882
  import_react45.useEffect(() => {
62912
- setExistingStatusLine(getExistingStatusLine());
62913
62883
  loadSettings().then((loadedSettings) => {
62914
62884
  source_default.level = loadedSettings.colorLevel;
62915
62885
  setSettings(loadedSettings);
@@ -62978,7 +62948,6 @@ A launcher script will be created at ~/.copilot/statusline.sh`;
62978
62948
  try {
62979
62949
  installStatusLine();
62980
62950
  setIsCopilotInstalled(true);
62981
- setExistingStatusLine(getExistingStatusLine());
62982
62951
  setFlashMessage({ text: "✓ Installed to Copilot CLI", color: "green" });
62983
62952
  } catch (e) {
62984
62953
  const errorMsg = e instanceof Error ? e.message : String(e);
@@ -63003,7 +62972,6 @@ A launcher script will be created at ~/.copilot/statusline.sh`;
63003
62972
  action: async () => {
63004
62973
  uninstallStatusLine();
63005
62974
  setIsCopilotInstalled(false);
63006
- setExistingStatusLine(null);
63007
62975
  setScreen("main");
63008
62976
  setConfirmDialog(null);
63009
62977
  return Promise.resolve();
@@ -63257,9 +63225,7 @@ var CopilotPayloadSchema = exports_external.object({
63257
63225
  id: exports_external.string().nullable().optional(),
63258
63226
  display_name: exports_external.string().nullable().optional()
63259
63227
  }).optional(),
63260
- workspace: exports_external.object({
63261
- current_dir: exports_external.string().optional()
63262
- }).optional(),
63228
+ workspace: exports_external.object({ current_dir: exports_external.string().optional() }).optional(),
63263
63229
  version: exports_external.string().optional(),
63264
63230
  cost: exports_external.object({
63265
63231
  total_api_duration_ms: exports_external.number().optional(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "copilot-statusline",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "A customizable status line formatter for GitHub Copilot CLI — based on ccstatusline",
5
5
  "module": "src/copilot-statusline.ts",
6
6
  "type": "module",
@@ -28,8 +28,8 @@
28
28
  "chalk": "^5.5.0",
29
29
  "eslint": "^10.0.0",
30
30
  "eslint-import-resolver-typescript": "^4.4.4",
31
- "eslint-plugin-import": "^2.32.0",
32
31
  "eslint-plugin-import-newlines": "^2.0.0",
32
+ "eslint-plugin-import-x": "^4.16.2",
33
33
  "eslint-plugin-react": "^7.37.5",
34
34
  "eslint-plugin-react-hooks": "^7.0.1",
35
35
  "globals": "^17.3.0",
@@ -55,8 +55,16 @@
55
55
  "powerline",
56
56
  "developer-tools"
57
57
  ],
58
- "author": "",
58
+ "author": "EncodeTS (https://github.com/EncodeTS)",
59
59
  "license": "MIT",
60
+ "repository": {
61
+ "type": "git",
62
+ "url": "https://github.com/EncodeTS/copilot-statusline.git"
63
+ },
64
+ "homepage": "https://github.com/EncodeTS/copilot-statusline",
65
+ "bugs": {
66
+ "url": "https://github.com/EncodeTS/copilot-statusline/issues"
67
+ },
60
68
  "engines": {
61
69
  "node": ">=14.0.0"
62
70
  },