@hasna/statusline 0.0.5 → 0.0.6

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
@@ -355,6 +355,16 @@ function sessionStateFile(env = process.env) {
355
355
  }
356
356
  return null;
357
357
  }
358
+ function liveAccountEmail(env) {
359
+ const stateFile = sessionStateFile(env);
360
+ return stateFile ? str(readJson(stateFile)?.oauthAccount?.emailAddress) : null;
361
+ }
362
+ function occupantMatchesLiveLogin(occupant, env) {
363
+ const live = liveAccountEmail(env);
364
+ if (!live)
365
+ return true;
366
+ return occupant.email != null && occupant.email === live;
367
+ }
358
368
  async function sessionAccount(env = process.env, tool) {
359
369
  const configDir = sessionConfigDir(env);
360
370
  const unresolved = { configDir, profile: null, tool: null, source: null };
@@ -364,7 +374,7 @@ async function sessionAccount(env = process.env, tool) {
364
374
  const name = str(entry?.name);
365
375
  const owner = name ? { configDir, profile: name, tool: str(entry?.tool), source: "registry" } : layoutProfile(paths.profiles, configDir, env) ?? unresolved;
366
376
  const occupant = switchedOccupant(configDir);
367
- if (occupant)
377
+ if (occupant && occupantMatchesLiveLogin(occupant, env))
368
378
  return { configDir, profile: occupant.profile, tool: owner.tool, source: "switched" };
369
379
  return owner;
370
380
  } catch {
@@ -373,8 +383,7 @@ async function sessionAccount(env = process.env, tool) {
373
383
  }
374
384
  async function sessionAccountEmail(env = process.env, tool) {
375
385
  try {
376
- const stateFile = sessionStateFile(env);
377
- const live = stateFile ? str(readJson(stateFile)?.oauthAccount?.emailAddress) : null;
386
+ const live = liveAccountEmail(env);
378
387
  if (live)
379
388
  return live;
380
389
  const configDir = sessionConfigDir(env);
@@ -710,7 +719,7 @@ async function renderLine(ctx, cfg) {
710
719
  // package.json
711
720
  var package_default = {
712
721
  name: "@hasna/statusline",
713
- version: "0.0.5",
722
+ version: "0.0.6",
714
723
  description: "Tiny composable statusline CLI for AI coding agents \u2014 pre-built toggleable segments for Claude Code, with a provider model for others",
715
724
  license: "Apache-2.0",
716
725
  type: "module",
@@ -1216,6 +1225,8 @@ async function runCli(argv = process.argv.slice(2)) {
1216
1225
  return;
1217
1226
  }
1218
1227
  case "enable": {
1228
+ if (!args.length)
1229
+ throw new Error("usage: statusline enable <segment> [segment...]");
1219
1230
  let result;
1220
1231
  try {
1221
1232
  result = enableSegments(args, loadConfig());
@@ -1229,6 +1240,8 @@ order: ${result.config.segments.join(", ")}`);
1229
1240
  return;
1230
1241
  }
1231
1242
  case "disable": {
1243
+ if (!args.length)
1244
+ throw new Error("usage: statusline disable <segment> [segment...]");
1232
1245
  let result;
1233
1246
  try {
1234
1247
  result = disableSegments(args, loadConfig());
package/dist/index.js CHANGED
@@ -354,6 +354,16 @@ function sessionStateFile(env = process.env) {
354
354
  }
355
355
  return null;
356
356
  }
357
+ function liveAccountEmail(env) {
358
+ const stateFile = sessionStateFile(env);
359
+ return stateFile ? str(readJson(stateFile)?.oauthAccount?.emailAddress) : null;
360
+ }
361
+ function occupantMatchesLiveLogin(occupant, env) {
362
+ const live = liveAccountEmail(env);
363
+ if (!live)
364
+ return true;
365
+ return occupant.email != null && occupant.email === live;
366
+ }
357
367
  async function sessionAccount(env = process.env, tool) {
358
368
  const configDir = sessionConfigDir(env);
359
369
  const unresolved = { configDir, profile: null, tool: null, source: null };
@@ -363,7 +373,7 @@ async function sessionAccount(env = process.env, tool) {
363
373
  const name = str(entry?.name);
364
374
  const owner = name ? { configDir, profile: name, tool: str(entry?.tool), source: "registry" } : layoutProfile(paths.profiles, configDir, env) ?? unresolved;
365
375
  const occupant = switchedOccupant(configDir);
366
- if (occupant)
376
+ if (occupant && occupantMatchesLiveLogin(occupant, env))
367
377
  return { configDir, profile: occupant.profile, tool: owner.tool, source: "switched" };
368
378
  return owner;
369
379
  } catch {
@@ -372,8 +382,7 @@ async function sessionAccount(env = process.env, tool) {
372
382
  }
373
383
  async function sessionAccountEmail(env = process.env, tool) {
374
384
  try {
375
- const stateFile = sessionStateFile(env);
376
- const live = stateFile ? str(readJson(stateFile)?.oauthAccount?.emailAddress) : null;
385
+ const live = liveAccountEmail(env);
377
386
  if (live)
378
387
  return live;
379
388
  const configDir = sessionConfigDir(env);
@@ -709,7 +718,7 @@ async function renderLine(ctx, cfg) {
709
718
  // package.json
710
719
  var package_default = {
711
720
  name: "@hasna/statusline",
712
- version: "0.0.5",
721
+ version: "0.0.6",
713
722
  description: "Tiny composable statusline CLI for AI coding agents \u2014 pre-built toggleable segments for Claude Code, with a provider model for others",
714
723
  license: "Apache-2.0",
715
724
  type: "module",
package/dist/mcp/index.js CHANGED
@@ -355,6 +355,16 @@ function sessionStateFile(env = process.env) {
355
355
  }
356
356
  return null;
357
357
  }
358
+ function liveAccountEmail(env) {
359
+ const stateFile = sessionStateFile(env);
360
+ return stateFile ? str(readJson(stateFile)?.oauthAccount?.emailAddress) : null;
361
+ }
362
+ function occupantMatchesLiveLogin(occupant, env) {
363
+ const live = liveAccountEmail(env);
364
+ if (!live)
365
+ return true;
366
+ return occupant.email != null && occupant.email === live;
367
+ }
358
368
  async function sessionAccount(env = process.env, tool) {
359
369
  const configDir = sessionConfigDir(env);
360
370
  const unresolved = { configDir, profile: null, tool: null, source: null };
@@ -364,7 +374,7 @@ async function sessionAccount(env = process.env, tool) {
364
374
  const name = str(entry?.name);
365
375
  const owner = name ? { configDir, profile: name, tool: str(entry?.tool), source: "registry" } : layoutProfile(paths.profiles, configDir, env) ?? unresolved;
366
376
  const occupant = switchedOccupant(configDir);
367
- if (occupant)
377
+ if (occupant && occupantMatchesLiveLogin(occupant, env))
368
378
  return { configDir, profile: occupant.profile, tool: owner.tool, source: "switched" };
369
379
  return owner;
370
380
  } catch {
@@ -373,8 +383,7 @@ async function sessionAccount(env = process.env, tool) {
373
383
  }
374
384
  async function sessionAccountEmail(env = process.env, tool) {
375
385
  try {
376
- const stateFile = sessionStateFile(env);
377
- const live = stateFile ? str(readJson(stateFile)?.oauthAccount?.emailAddress) : null;
386
+ const live = liveAccountEmail(env);
378
387
  if (live)
379
388
  return live;
380
389
  const configDir = sessionConfigDir(env);
@@ -710,7 +719,7 @@ async function renderLine(ctx, cfg) {
710
719
  // package.json
711
720
  var package_default = {
712
721
  name: "@hasna/statusline",
713
- version: "0.0.5",
722
+ version: "0.0.6",
714
723
  description: "Tiny composable statusline CLI for AI coding agents \u2014 pre-built toggleable segments for Claude Code, with a provider model for others",
715
724
  license: "Apache-2.0",
716
725
  type: "module",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/statusline",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "Tiny composable statusline CLI for AI coding agents \u2014 pre-built toggleable segments for Claude Code, with a provider model for others",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",