@hasna/statusline 0.0.3 → 0.0.4

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/dist/cli.js CHANGED
@@ -1,36 +1,6 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- var __create = Object.create;
4
- var __getProtoOf = Object.getPrototypeOf;
5
3
  var __defProp = Object.defineProperty;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- function __accessProp(key) {
9
- return this[key];
10
- }
11
- var __toESMCache_node;
12
- var __toESMCache_esm;
13
- var __toESM = (mod, isNodeMode, target) => {
14
- var canCache = mod != null && typeof mod === "object";
15
- if (canCache) {
16
- var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
17
- var cached = cache.get(mod);
18
- if (cached)
19
- return cached;
20
- }
21
- target = mod != null ? __create(__getProtoOf(mod)) : {};
22
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
23
- for (let key of __getOwnPropNames(mod))
24
- if (!__hasOwnProp.call(to, key))
25
- __defProp(to, key, {
26
- get: __accessProp.bind(mod, key),
27
- enumerable: true
28
- });
29
- if (canCache)
30
- cache.set(mod, to);
31
- return to;
32
- };
33
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
34
4
  var __returnValue = (v) => v;
35
5
  function __exportSetter(name, newValue) {
36
6
  this[name] = __returnValue.bind(null, newValue);
@@ -402,6 +372,18 @@ async function sessionAccountEmail(env = process.env, tool) {
402
372
  }
403
373
  }
404
374
 
375
+ // src/settings.ts
376
+ import { readFileSync as readFileSync4 } from "fs";
377
+ import { join as join3 } from "path";
378
+ function sessionFastMode(env = process.env) {
379
+ try {
380
+ const raw = readFileSync4(join3(sessionConfigDir(env), "settings.json"), "utf8");
381
+ return JSON.parse(raw)?.fastMode === true;
382
+ } catch {
383
+ return false;
384
+ }
385
+ }
386
+
405
387
  // src/segments/index.ts
406
388
  function friendlyModel(id) {
407
389
  let tag = null;
@@ -421,7 +403,7 @@ function friendlyModel(id) {
421
403
  var dir = (ctx) => ctx.cwd || process.cwd();
422
404
  function modelName(ctx) {
423
405
  if (ctx.model?.displayName)
424
- return ctx.model.displayName;
406
+ return ctx.model.displayName.toLowerCase();
425
407
  return ctx.model?.id ? friendlyModel(ctx.model.id).name : null;
426
408
  }
427
409
  function limitPercent(pct) {
@@ -515,12 +497,19 @@ var segments = [
515
497
  if (!name)
516
498
  return null;
517
499
  if (ctx.effort)
518
- return `${name} (${ctx.effort})`;
500
+ return `${name} (${ctx.effort.toLowerCase()})`;
519
501
  if (ctx.thinking)
520
502
  return `${name} (thinking)`;
521
503
  return name;
522
504
  }
523
505
  },
506
+ {
507
+ id: "fast-mode",
508
+ description: `Shows "fast" when fast mode is on for this session's config dir`,
509
+ defaultEnabled: false,
510
+ color: "yellow",
511
+ render: () => sessionFastMode(process.env) ? "fast" : null
512
+ },
524
513
  {
525
514
  id: "auth-profile",
526
515
  description: "Account profile this session runs as (omitted when unmanaged)",
@@ -648,6 +637,12 @@ var segments = [
648
637
  description: "Session identifier (short)",
649
638
  defaultEnabled: false,
650
639
  render: (ctx) => ctx.sessionId ? ctx.sessionId.split("-")[0] : null
640
+ },
641
+ {
642
+ id: "newline",
643
+ description: "Row break \u2014 segments after it render on the next line",
644
+ defaultEnabled: false,
645
+ render: () => null
651
646
  }
652
647
  ];
653
648
  function getSegment(id) {
@@ -678,23 +673,28 @@ function paint(segment, text, ctx) {
678
673
  }
679
674
  async function renderLine(ctx, cfg) {
680
675
  const colorize = colorsEnabled(cfg);
681
- const parts = [];
676
+ const rows = [[]];
682
677
  for (const id of cfg.segments) {
678
+ if (id === "newline") {
679
+ rows.push([]);
680
+ continue;
681
+ }
683
682
  const segment = getSegment(id);
684
683
  if (!segment)
685
684
  continue;
686
685
  try {
687
686
  const out = await segment.render(ctx);
688
687
  if (out)
689
- parts.push(colorize ? paint(segment, out, ctx) : out);
688
+ rows[rows.length - 1].push(colorize ? paint(segment, out, ctx) : out);
690
689
  } catch {}
691
690
  }
692
- return parts.join(cfg.separator);
691
+ return rows.map((parts) => parts.join(cfg.separator)).filter((row) => row.length > 0).join(`
692
+ `);
693
693
  }
694
694
  // package.json
695
695
  var package_default = {
696
696
  name: "@hasna/statusline",
697
- version: "0.0.3",
697
+ version: "0.0.4",
698
698
  description: "Tiny composable statusline CLI for AI coding agents \u2014 pre-built toggleable segments for Claude Code, with a provider model for others",
699
699
  license: "Apache-2.0",
700
700
  type: "module",
@@ -754,28 +754,28 @@ var package_default = {
754
754
  bun: ">=1.0.0"
755
755
  },
756
756
  dependencies: {
757
- "@modelcontextprotocol/sdk": "^1.12.1",
758
- zod: "^3.25.76"
757
+ "@modelcontextprotocol/sdk": "1.12.1",
758
+ zod: "3.25.76"
759
759
  },
760
760
  devDependencies: {
761
761
  "@types/bun": "^1.2.4",
762
- typescript: "^5.7.3"
762
+ typescript: "5.9.3"
763
763
  }
764
764
  };
765
765
  // src/install.ts
766
- import { copyFileSync, existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "fs";
766
+ import { copyFileSync, existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync5, writeFileSync as writeFileSync2 } from "fs";
767
767
  import { homedir as homedir3 } from "os";
768
- import { dirname as dirname2, join as join3, resolve as resolve2 } from "path";
768
+ import { dirname as dirname2, join as join4, resolve as resolve2 } from "path";
769
769
  function defaultSettingsPath(env) {
770
- return join3(env.HOME || homedir3(), ".claude", "settings.json");
770
+ return join4(env.HOME || homedir3(), ".claude", "settings.json");
771
771
  }
772
772
  function claudeSettingsPath(env = process.env) {
773
773
  const home2 = env.HOME || homedir3();
774
774
  const raw = env.CLAUDE_CONFIG_DIR?.trim();
775
775
  if (!raw)
776
776
  return defaultSettingsPath(env);
777
- const configDir = raw === "~" || raw.startsWith("~/") ? join3(home2, raw.slice(1)) : raw;
778
- return join3(configDir, "settings.json");
777
+ const configDir = raw === "~" || raw.startsWith("~/") ? join4(home2, raw.slice(1)) : raw;
778
+ return join4(configDir, "settings.json");
779
779
  }
780
780
  function installClaude(settingsPath, env = process.env) {
781
781
  const target = settingsPath ?? claudeSettingsPath(env);
@@ -783,7 +783,7 @@ function installClaude(settingsPath, env = process.env) {
783
783
  let settings = {};
784
784
  if (existsSync4(target)) {
785
785
  try {
786
- settings = JSON.parse(readFileSync4(target, "utf8"));
786
+ settings = JSON.parse(readFileSync5(target, "utf8"));
787
787
  } catch (error) {
788
788
  throw new Error(`${target} is not valid JSON \u2014 fix or move it first`);
789
789
  }
package/dist/index.js CHANGED
@@ -1,35 +1,5 @@
1
1
  // @bun
2
- var __create = Object.create;
3
- var __getProtoOf = Object.getPrototypeOf;
4
2
  var __defProp = Object.defineProperty;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- function __accessProp(key) {
8
- return this[key];
9
- }
10
- var __toESMCache_node;
11
- var __toESMCache_esm;
12
- var __toESM = (mod, isNodeMode, target) => {
13
- var canCache = mod != null && typeof mod === "object";
14
- if (canCache) {
15
- var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
- var cached = cache.get(mod);
17
- if (cached)
18
- return cached;
19
- }
20
- target = mod != null ? __create(__getProtoOf(mod)) : {};
21
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
- for (let key of __getOwnPropNames(mod))
23
- if (!__hasOwnProp.call(to, key))
24
- __defProp(to, key, {
25
- get: __accessProp.bind(mod, key),
26
- enumerable: true
27
- });
28
- if (canCache)
29
- cache.set(mod, to);
30
- return to;
31
- };
32
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
33
3
  var __returnValue = (v) => v;
34
4
  function __exportSetter(name, newValue) {
35
5
  this[name] = __returnValue.bind(null, newValue);
@@ -401,6 +371,18 @@ async function sessionAccountEmail(env = process.env, tool) {
401
371
  }
402
372
  }
403
373
 
374
+ // src/settings.ts
375
+ import { readFileSync as readFileSync4 } from "fs";
376
+ import { join as join3 } from "path";
377
+ function sessionFastMode(env = process.env) {
378
+ try {
379
+ const raw = readFileSync4(join3(sessionConfigDir(env), "settings.json"), "utf8");
380
+ return JSON.parse(raw)?.fastMode === true;
381
+ } catch {
382
+ return false;
383
+ }
384
+ }
385
+
404
386
  // src/segments/index.ts
405
387
  function friendlyModel(id) {
406
388
  let tag = null;
@@ -420,7 +402,7 @@ function friendlyModel(id) {
420
402
  var dir = (ctx) => ctx.cwd || process.cwd();
421
403
  function modelName(ctx) {
422
404
  if (ctx.model?.displayName)
423
- return ctx.model.displayName;
405
+ return ctx.model.displayName.toLowerCase();
424
406
  return ctx.model?.id ? friendlyModel(ctx.model.id).name : null;
425
407
  }
426
408
  function limitPercent(pct) {
@@ -514,12 +496,19 @@ var segments = [
514
496
  if (!name)
515
497
  return null;
516
498
  if (ctx.effort)
517
- return `${name} (${ctx.effort})`;
499
+ return `${name} (${ctx.effort.toLowerCase()})`;
518
500
  if (ctx.thinking)
519
501
  return `${name} (thinking)`;
520
502
  return name;
521
503
  }
522
504
  },
505
+ {
506
+ id: "fast-mode",
507
+ description: `Shows "fast" when fast mode is on for this session's config dir`,
508
+ defaultEnabled: false,
509
+ color: "yellow",
510
+ render: () => sessionFastMode(process.env) ? "fast" : null
511
+ },
523
512
  {
524
513
  id: "auth-profile",
525
514
  description: "Account profile this session runs as (omitted when unmanaged)",
@@ -647,6 +636,12 @@ var segments = [
647
636
  description: "Session identifier (short)",
648
637
  defaultEnabled: false,
649
638
  render: (ctx) => ctx.sessionId ? ctx.sessionId.split("-")[0] : null
639
+ },
640
+ {
641
+ id: "newline",
642
+ description: "Row break \u2014 segments after it render on the next line",
643
+ defaultEnabled: false,
644
+ render: () => null
650
645
  }
651
646
  ];
652
647
  function getSegment(id) {
@@ -677,23 +672,28 @@ function paint(segment, text, ctx) {
677
672
  }
678
673
  async function renderLine(ctx, cfg) {
679
674
  const colorize = colorsEnabled(cfg);
680
- const parts = [];
675
+ const rows = [[]];
681
676
  for (const id of cfg.segments) {
677
+ if (id === "newline") {
678
+ rows.push([]);
679
+ continue;
680
+ }
682
681
  const segment = getSegment(id);
683
682
  if (!segment)
684
683
  continue;
685
684
  try {
686
685
  const out = await segment.render(ctx);
687
686
  if (out)
688
- parts.push(colorize ? paint(segment, out, ctx) : out);
687
+ rows[rows.length - 1].push(colorize ? paint(segment, out, ctx) : out);
689
688
  } catch {}
690
689
  }
691
- return parts.join(cfg.separator);
690
+ return rows.map((parts) => parts.join(cfg.separator)).filter((row) => row.length > 0).join(`
691
+ `);
692
692
  }
693
693
  // package.json
694
694
  var package_default = {
695
695
  name: "@hasna/statusline",
696
- version: "0.0.3",
696
+ version: "0.0.4",
697
697
  description: "Tiny composable statusline CLI for AI coding agents \u2014 pre-built toggleable segments for Claude Code, with a provider model for others",
698
698
  license: "Apache-2.0",
699
699
  type: "module",
@@ -753,28 +753,28 @@ var package_default = {
753
753
  bun: ">=1.0.0"
754
754
  },
755
755
  dependencies: {
756
- "@modelcontextprotocol/sdk": "^1.12.1",
757
- zod: "^3.25.76"
756
+ "@modelcontextprotocol/sdk": "1.12.1",
757
+ zod: "3.25.76"
758
758
  },
759
759
  devDependencies: {
760
760
  "@types/bun": "^1.2.4",
761
- typescript: "^5.7.3"
761
+ typescript: "5.9.3"
762
762
  }
763
763
  };
764
764
  // src/install.ts
765
- import { copyFileSync, existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "fs";
765
+ import { copyFileSync, existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync5, writeFileSync as writeFileSync2 } from "fs";
766
766
  import { homedir as homedir3 } from "os";
767
- import { dirname as dirname2, join as join3, resolve as resolve2 } from "path";
767
+ import { dirname as dirname2, join as join4, resolve as resolve2 } from "path";
768
768
  function defaultSettingsPath(env) {
769
- return join3(env.HOME || homedir3(), ".claude", "settings.json");
769
+ return join4(env.HOME || homedir3(), ".claude", "settings.json");
770
770
  }
771
771
  function claudeSettingsPath(env = process.env) {
772
772
  const home2 = env.HOME || homedir3();
773
773
  const raw = env.CLAUDE_CONFIG_DIR?.trim();
774
774
  if (!raw)
775
775
  return defaultSettingsPath(env);
776
- const configDir = raw === "~" || raw.startsWith("~/") ? join3(home2, raw.slice(1)) : raw;
777
- return join3(configDir, "settings.json");
776
+ const configDir = raw === "~" || raw.startsWith("~/") ? join4(home2, raw.slice(1)) : raw;
777
+ return join4(configDir, "settings.json");
778
778
  }
779
779
  function installClaude(settingsPath, env = process.env) {
780
780
  const target = settingsPath ?? claudeSettingsPath(env);
@@ -782,7 +782,7 @@ function installClaude(settingsPath, env = process.env) {
782
782
  let settings = {};
783
783
  if (existsSync4(target)) {
784
784
  try {
785
- settings = JSON.parse(readFileSync4(target, "utf8"));
785
+ settings = JSON.parse(readFileSync5(target, "utf8"));
786
786
  } catch (error) {
787
787
  throw new Error(`${target} is not valid JSON \u2014 fix or move it first`);
788
788
  }