@hasna/statusline 0.0.4 → 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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Tiny, composable statusline CLI for AI coding agents. Pre-built segments you toggle
4
4
  on and off — machine name, project + branch, model, context remaining, session cost,
5
- and more — rendered as a single line for your agent's status bar.
5
+ and more — rendered as one or more rows in your agent's status bar.
6
6
 
7
7
  ```
8
8
  apple03 · statusline (main) · 12h · 1.2k · fable 5 [1m] · 90% left · $0.04
@@ -14,7 +14,7 @@ Built with [Bun](https://bun.sh) + TypeScript. The CLI renderer is dependency-li
14
14
 
15
15
  ```bash
16
16
  bun install -g @hasna/statusline
17
- statusline install claude # wires it into ~/.claude/settings.json
17
+ statusline install claude # wires it into the active Claude config dir
18
18
  ```
19
19
 
20
20
  That's it — Claude Code picks it up on the next status refresh (no restart needed).
@@ -22,7 +22,7 @@ That's it — Claude Code picks it up on the next status refresh (no restart nee
22
22
  ## Segments
23
23
 
24
24
  `statusline list` shows a compact, enabled-first summary of your segments (use
25
- `statusline list --all` for every row). The table below is the full catalog — all 18
25
+ `statusline list --all` for every row). The table below is the full catalog — all 26
26
26
  segment ids from `src/segments/index.ts`.
27
27
 
28
28
  `renderLine` walks your configured segment order, renders each one, and **drops**
@@ -39,7 +39,8 @@ anything that returns `null` or throws. A failed segment never breaks the host U
39
39
  | `current-dir` | off | Current working directory (basename) | `StatusContext.cwd` | never (always renders basename) | `open-statusline` |
40
40
  | `model` | off | Current model name (no context tag) | `StatusContext.model.id` via friendly formatter | no model id | `fable 5` |
41
41
  | `model-context` | on | Model name with context-size tag | same formatter, keeps `[tag]` suffix | no model id | `fable 5 [1m]` |
42
- | `model-with-reasoning` | off | Model name with its reasoning effort | `model.display_name` (or friendly id) + `effort.level`; falls back to `thinking.enabled`, which the host defaults to on | no model | `Fable (xhigh)` |
42
+ | `model-with-reasoning` | off | Model name with its reasoning effort | lowercased `model.display_name` (or friendly id) + `effort.level`; falls back to `thinking.enabled` when on | no model | `fable (xhigh)` |
43
+ | `fast-mode` | off | Fast-mode indicator | `fastMode` in this session's Claude config-dir `settings.json` | fast mode is off or settings are unavailable | `fast` |
43
44
  | `auth-profile` | off | Account profile this session runs as | this process's `CLAUDE_CONFIG_DIR`, resolved against the accounts registry | config dir is unmanaged and has no login | `account001` |
44
45
  | `auth-email` | off | Account email this session is logged in as | the agent's own login record for this config dir, else the registry | no login recorded | `dev@example.com` |
45
46
  | `five-hour-limit` | off | Percentage of the 5-hour rate limit used | `rate_limits.five_hour.used_percentage` | host reports no limit data | `5h:42%` |
@@ -49,11 +50,12 @@ anything that returns `null` or throws. A failed segment never breaks the host U
49
50
  | `context-remaining` | on | Percentage of context window remaining | transcript via `contextUsage` | transcript missing/unreadable | `90% left` |
50
51
  | `used-tokens` | off | Total tokens in the context window | transcript usage block (input + output) | transcript missing/unreadable | `102k tok` |
51
52
  | `cost` | on | Session cost in USD | `StatusContext.cost.totalCostUsd` | cost is zero or missing | `$1,234.50` |
52
- | `duration` | off | Session wall-clock duration | `StatusContext.cost.totalDurationMs` | duration missing | `1h30m` |
53
+ | `duration` | off | Session wall-clock duration | `StatusContext.cost.totalDurationMs` | duration is zero or missing | `1h30m` |
53
54
  | `lines-changed` | off | Lines added/removed this session | `cost.totalLinesAdded/Removed` | both zero | `+142/-18` |
54
55
  | `output-style` | off | Active output style | `StatusContext.outputStyle` | style is `default` or missing | `concise` |
55
56
  | `agent-version` | off | Host agent version | `StatusContext.version` | version missing | `v2.1.39` |
56
57
  | `session-id` | off | Session identifier (short) | first UUID segment of `sessionId` | no session id | `abc12345` |
58
+ | `newline` | off | Row break | renderer starts a new output row | always (the segment emits no text itself) | line break |
57
59
 
58
60
  ### Context segments and transcripts
59
61
 
@@ -103,7 +105,7 @@ registry knows about always wins.
103
105
  ### Colours
104
106
 
105
107
  Segments may declare a colour, applied by `renderLine` when colours are on
106
- (the default). The rate-limit segments escalate from yellow to red past 80%.
108
+ (the default). The rate-limit segments escalate from yellow to red at 80%.
107
109
 
108
110
  ```bash
109
111
  statusline colors off # or set "colors": false in the config
@@ -117,7 +119,7 @@ statusline colors off # or set "colors": false in the config
117
119
  enabled segments first, capped rows, and hints for the detail paths:
118
120
 
119
121
  ```
120
- Segments: 7 enabled / 18 total (showing 12 of 18)
122
+ Segments: 7 enabled / 26 total (showing 12 of 26)
121
123
  state default id
122
124
  on yes machine
123
125
  on yes project
@@ -130,7 +132,7 @@ off no project-name
130
132
  off no git-branch
131
133
  off no current-dir
132
134
  off no model
133
- off no context-used
135
+ off no model-with-reasoning
134
136
  Hint: use `--all` for all matching rows, `statusline show <id>` for details, `--verbose` for descriptions, `--json` for machines.
135
137
  ```
136
138
 
@@ -158,6 +160,8 @@ statusbar width.
158
160
 
159
161
  ```bash
160
162
  statusline list # compact segment summary
163
+ statusline search token --json # search ids/descriptions; list flags apply
164
+ statusline show model-context # show one segment in detail
161
165
  statusline enable used-tokens duration # turn segments on (appended at the end)
162
166
  statusline disable loc # turn segments off
163
167
  statusline colors off # drop ANSI colours
@@ -165,6 +169,8 @@ statusline order machine project model-context cost # exact order = enabled se
165
169
  statusline separator " | " # change the separator
166
170
  statusline preview # render a sample line from the current dir
167
171
  statusline reset # back to defaults
172
+ statusline install claude # update the active Claude settings file
173
+ statusline version # print the package version
168
174
  ```
169
175
 
170
176
  Config lives at `~/.config/statusline/config.json` (override with `$STATUSLINE_CONFIG`):
@@ -172,6 +178,7 @@ Config lives at `~/.config/statusline/config.json` (override with `$STATUSLINE_C
172
178
  ```json
173
179
  {
174
180
  "separator": " · ",
181
+ "colors": true,
175
182
  "segments": ["machine", "project", "commit-age", "loc", "model-context", "context-remaining", "cost"]
176
183
  }
177
184
  ```
@@ -197,7 +204,8 @@ ids to the end; `statusline disable` removes them.
197
204
 
198
205
  Claude Code pipes a JSON payload (cwd, model, session cost, transcript path, …) to the
199
206
  configured `statusLine` command on every status refresh. `statusline render` parses it,
200
- renders each enabled segment, drops anything unavailable, and prints one line. Segments
207
+ renders each enabled segment, drops anything unavailable, and prints one or more rows.
208
+ The `newline` segment starts a new row; empty rows are removed. Segments
201
209
  that need more than the payload offers (e.g. `context-remaining`) read the session
202
210
  transcript to compute it. A segment failure is never fatal — it's simply omitted.
203
211
 
@@ -220,9 +228,10 @@ const next = enableSegments(["duration"], config).config;
220
228
  saveConfig(next);
221
229
  ```
222
230
 
223
- Useful exports include `parseClaudeInput`, `renderLine`, `segments`, `getSegment`,
224
- `defaultConfig`, `loadConfig`, `saveConfig`, `configPath`, `previewStatusline`,
225
- `orderSegments`, `disableSegments`, `setSeparator`, and `installClaude`.
231
+ Useful exports include `parseClaudeInput`, `renderLine`, `renderStatusline`, `segments`,
232
+ `getSegment`, `listSegments`, `defaultConfig`, `loadConfig`, `saveConfig`, `configPath`,
233
+ `previewStatusline`, `enableSegments`, `disableSegments`, `orderSegments`,
234
+ `setSeparator`, `setColors`, `installClaude`, and the account, context, format, and Git helpers.
226
235
 
227
236
  ## MCP
228
237
 
@@ -232,7 +241,7 @@ Useful exports include `parseClaudeInput`, `renderLine`, `segments`, `getSegment
232
241
  statusline-mcp
233
242
  ```
234
243
 
235
- It exposes safe tools for `render_statusline`, `preview_statusline`,
244
+ It exposes safe tools for `statusline_health`, `render_statusline`, `preview_statusline`,
236
245
  `list_segments`, `get_config`, `update_config`, `enable_segments`,
237
246
  `disable_segments`, `order_segments`, and `reset_config`. Config mutation tools
238
247
  require `confirm_write: true`; every mutation tool supports `dry_run: true`.
@@ -250,8 +259,9 @@ bun install -g @hasna/statusline
250
259
  statusline install claude
251
260
  ```
252
261
 
253
- `installClaude()` writes to `$CLAUDE_CONFIG_DIR/settings.json`, falling back to
254
- `~/.claude/settings.json`. This matters for multi-account setups: when a session is
262
+ `installClaude()` writes to `$CLAUDE_CONFIG_DIR/settings.json` when the variable is
263
+ non-blank, falling back to `~/.claude/settings.json`. A leading `~/` in
264
+ `CLAUDE_CONFIG_DIR` is expanded against `$HOME`. This matters for multi-account setups: when a session is
255
265
  bound to an isolated config dir, `~/.claude/settings.json` is never read, so
256
266
  installing there wires up a statusline that silently never runs.
257
267
 
@@ -23,9 +23,11 @@ export interface SessionAccount {
23
23
  /**
24
24
  * How `profile` was resolved. `"layout"` means it was read off the dir path
25
25
  * rather than the registry, which is authoritative about the dir but can lag
26
- * a rename — see `layoutProfile`. Surfaced for diagnostics, not for display.
26
+ * a rename — see `layoutProfile`. `"switched"` means an in-place
27
+ * `switch-account` marker named another profile's account as the dir's
28
+ * current occupant. Surfaced for diagnostics, not for display.
27
29
  */
28
- source: "registry" | "layout" | null;
30
+ source: "registry" | "layout" | "switched" | null;
29
31
  }
30
32
  type Env = Record<string, string | undefined>;
31
33
  /** Config dir the current process is bound to, for settings and registry lookup. */
package/dist/cli.js CHANGED
@@ -243,6 +243,8 @@ var ACCOUNTS_HOME_ENV = "ACCOUNTS_HOME";
243
243
  var DEFAULT_ACCOUNTS_HOME = [".hasna", "accounts"];
244
244
  var STORE_FILE = "accounts.json";
245
245
  var PROFILES_SUBDIR = "profiles";
246
+ var AUTH_STATE_SUBDIR = ".accounts-auth";
247
+ var SWITCHED_ACCOUNT_MARKER_FILE = "switched-account.json";
246
248
  var STATE_FILE_PREFERRED = ".config.json";
247
249
  var STATE_FILE_PREFIX = ".claude";
248
250
  var STATE_FILE_SUFFIX = ".json";
@@ -329,6 +331,14 @@ function layoutProfile(profilesRoot, configDir, env) {
329
331
  return null;
330
332
  return { configDir, profile, tool, source: "layout" };
331
333
  }
334
+ function switchedOccupant(configDir) {
335
+ const raw = readJson(join2(configDir, AUTH_STATE_SUBDIR, SWITCHED_ACCOUNT_MARKER_FILE));
336
+ if (!raw)
337
+ return null;
338
+ const profile = str(raw.profile);
339
+ const email = str(raw.email);
340
+ return profile || email ? { profile, email } : null;
341
+ }
332
342
  function sessionConfigDir(env = process.env) {
333
343
  return canonical(str(env[CONFIG_DIR_ENV]) ?? join2(home(env), DEFAULT_CONFIG_SUBDIR), env);
334
344
  }
@@ -345,6 +355,16 @@ function sessionStateFile(env = process.env) {
345
355
  }
346
356
  return null;
347
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
+ }
348
368
  async function sessionAccount(env = process.env, tool) {
349
369
  const configDir = sessionConfigDir(env);
350
370
  const unresolved = { configDir, profile: null, tool: null, source: null };
@@ -352,21 +372,26 @@ async function sessionAccount(env = process.env, tool) {
352
372
  const paths = await accountsPaths(env);
353
373
  const entry = registryEntry(paths.store, configDir, env, tool);
354
374
  const name = str(entry?.name);
355
- if (name)
356
- return { configDir, profile: name, tool: str(entry?.tool), source: "registry" };
357
- return layoutProfile(paths.profiles, configDir, env) ?? unresolved;
375
+ const owner = name ? { configDir, profile: name, tool: str(entry?.tool), source: "registry" } : layoutProfile(paths.profiles, configDir, env) ?? unresolved;
376
+ const occupant = switchedOccupant(configDir);
377
+ if (occupant && occupantMatchesLiveLogin(occupant, env))
378
+ return { configDir, profile: occupant.profile, tool: owner.tool, source: "switched" };
379
+ return owner;
358
380
  } catch {
359
381
  return unresolved;
360
382
  }
361
383
  }
362
384
  async function sessionAccountEmail(env = process.env, tool) {
363
385
  try {
364
- const stateFile = sessionStateFile(env);
365
- const live = stateFile ? str(readJson(stateFile)?.oauthAccount?.emailAddress) : null;
386
+ const live = liveAccountEmail(env);
366
387
  if (live)
367
388
  return live;
389
+ const configDir = sessionConfigDir(env);
390
+ const occupant = switchedOccupant(configDir);
391
+ if (occupant)
392
+ return occupant.email;
368
393
  const paths = await accountsPaths(env);
369
- return str(registryEntry(paths.store, sessionConfigDir(env), env, tool)?.email);
394
+ return str(registryEntry(paths.store, configDir, env, tool)?.email);
370
395
  } catch {
371
396
  return null;
372
397
  }
@@ -694,7 +719,7 @@ async function renderLine(ctx, cfg) {
694
719
  // package.json
695
720
  var package_default = {
696
721
  name: "@hasna/statusline",
697
- version: "0.0.4",
722
+ version: "0.0.6",
698
723
  description: "Tiny composable statusline CLI for AI coding agents \u2014 pre-built toggleable segments for Claude Code, with a provider model for others",
699
724
  license: "Apache-2.0",
700
725
  type: "module",
@@ -906,11 +931,11 @@ run \`statusline list\` to see available segments`);
906
931
  process.exitCode = 1;
907
932
  }
908
933
  function help() {
909
- return `statusline ${statuslineVersion} \u2014 composable statusline for AI coding agents
934
+ return `statusline ${statuslineVersion} \u2014 composable status rows for AI coding agents
910
935
 
911
936
  usage:
912
- statusline render read agent JSON on stdin, print the statusline (default)
913
- statusline list compact segment list (default limit: ${DEFAULT_LIST_LIMIT})
937
+ statusline render read agent JSON on stdin, print status rows (default)
938
+ statusline list [search text] compact segment list (default limit: ${DEFAULT_LIST_LIMIT})
914
939
  statusline list --verbose include descriptions
915
940
  statusline list --all show all rows
916
941
  statusline list --json machine-readable segment list
@@ -918,8 +943,8 @@ usage:
918
943
  statusline list --enabled show only enabled segments
919
944
  statusline list --disabled show only disabled segments
920
945
  statusline list --search text filter by id or description
921
- statusline search <text> alias for list --search
922
- statusline show <id> show one segment in detail
946
+ statusline search <text> alias for list --search (accepts list options)
947
+ statusline show <id> show one segment in detail (--json supported)
923
948
  statusline show <id> --json machine-readable segment detail
924
949
  statusline inspect <id> alias for show
925
950
  statusline enable <id...> enable segments (appended to the end)
@@ -929,7 +954,7 @@ usage:
929
954
  statusline colors <on|off> toggle segment colours (default on)
930
955
  statusline preview render with a sample payload from the current directory
931
956
  statusline reset restore default config
932
- statusline install [claude] wire into Claude Code (~/.claude/settings.json)
957
+ statusline install [claude] wire into the active Claude Code settings file
933
958
  statusline version print version
934
959
 
935
960
  config: ${configPath()}`;
@@ -1200,6 +1225,8 @@ async function runCli(argv = process.argv.slice(2)) {
1200
1225
  return;
1201
1226
  }
1202
1227
  case "enable": {
1228
+ if (!args.length)
1229
+ throw new Error("usage: statusline enable <segment> [segment...]");
1203
1230
  let result;
1204
1231
  try {
1205
1232
  result = enableSegments(args, loadConfig());
@@ -1213,6 +1240,8 @@ order: ${result.config.segments.join(", ")}`);
1213
1240
  return;
1214
1241
  }
1215
1242
  case "disable": {
1243
+ if (!args.length)
1244
+ throw new Error("usage: statusline disable <segment> [segment...]");
1216
1245
  let result;
1217
1246
  try {
1218
1247
  result = disableSegments(args, loadConfig());
package/dist/index.js CHANGED
@@ -242,6 +242,8 @@ var ACCOUNTS_HOME_ENV = "ACCOUNTS_HOME";
242
242
  var DEFAULT_ACCOUNTS_HOME = [".hasna", "accounts"];
243
243
  var STORE_FILE = "accounts.json";
244
244
  var PROFILES_SUBDIR = "profiles";
245
+ var AUTH_STATE_SUBDIR = ".accounts-auth";
246
+ var SWITCHED_ACCOUNT_MARKER_FILE = "switched-account.json";
245
247
  var STATE_FILE_PREFERRED = ".config.json";
246
248
  var STATE_FILE_PREFIX = ".claude";
247
249
  var STATE_FILE_SUFFIX = ".json";
@@ -328,6 +330,14 @@ function layoutProfile(profilesRoot, configDir, env) {
328
330
  return null;
329
331
  return { configDir, profile, tool, source: "layout" };
330
332
  }
333
+ function switchedOccupant(configDir) {
334
+ const raw = readJson(join2(configDir, AUTH_STATE_SUBDIR, SWITCHED_ACCOUNT_MARKER_FILE));
335
+ if (!raw)
336
+ return null;
337
+ const profile = str(raw.profile);
338
+ const email = str(raw.email);
339
+ return profile || email ? { profile, email } : null;
340
+ }
331
341
  function sessionConfigDir(env = process.env) {
332
342
  return canonical(str(env[CONFIG_DIR_ENV]) ?? join2(home(env), DEFAULT_CONFIG_SUBDIR), env);
333
343
  }
@@ -344,6 +354,16 @@ function sessionStateFile(env = process.env) {
344
354
  }
345
355
  return null;
346
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
+ }
347
367
  async function sessionAccount(env = process.env, tool) {
348
368
  const configDir = sessionConfigDir(env);
349
369
  const unresolved = { configDir, profile: null, tool: null, source: null };
@@ -351,21 +371,26 @@ async function sessionAccount(env = process.env, tool) {
351
371
  const paths = await accountsPaths(env);
352
372
  const entry = registryEntry(paths.store, configDir, env, tool);
353
373
  const name = str(entry?.name);
354
- if (name)
355
- return { configDir, profile: name, tool: str(entry?.tool), source: "registry" };
356
- return layoutProfile(paths.profiles, configDir, env) ?? unresolved;
374
+ const owner = name ? { configDir, profile: name, tool: str(entry?.tool), source: "registry" } : layoutProfile(paths.profiles, configDir, env) ?? unresolved;
375
+ const occupant = switchedOccupant(configDir);
376
+ if (occupant && occupantMatchesLiveLogin(occupant, env))
377
+ return { configDir, profile: occupant.profile, tool: owner.tool, source: "switched" };
378
+ return owner;
357
379
  } catch {
358
380
  return unresolved;
359
381
  }
360
382
  }
361
383
  async function sessionAccountEmail(env = process.env, tool) {
362
384
  try {
363
- const stateFile = sessionStateFile(env);
364
- const live = stateFile ? str(readJson(stateFile)?.oauthAccount?.emailAddress) : null;
385
+ const live = liveAccountEmail(env);
365
386
  if (live)
366
387
  return live;
388
+ const configDir = sessionConfigDir(env);
389
+ const occupant = switchedOccupant(configDir);
390
+ if (occupant)
391
+ return occupant.email;
367
392
  const paths = await accountsPaths(env);
368
- return str(registryEntry(paths.store, sessionConfigDir(env), env, tool)?.email);
393
+ return str(registryEntry(paths.store, configDir, env, tool)?.email);
369
394
  } catch {
370
395
  return null;
371
396
  }
@@ -693,7 +718,7 @@ async function renderLine(ctx, cfg) {
693
718
  // package.json
694
719
  var package_default = {
695
720
  name: "@hasna/statusline",
696
- version: "0.0.4",
721
+ version: "0.0.6",
697
722
  description: "Tiny composable statusline CLI for AI coding agents \u2014 pre-built toggleable segments for Claude Code, with a provider model for others",
698
723
  license: "Apache-2.0",
699
724
  type: "module",
package/dist/mcp/index.js CHANGED
@@ -243,6 +243,8 @@ var ACCOUNTS_HOME_ENV = "ACCOUNTS_HOME";
243
243
  var DEFAULT_ACCOUNTS_HOME = [".hasna", "accounts"];
244
244
  var STORE_FILE = "accounts.json";
245
245
  var PROFILES_SUBDIR = "profiles";
246
+ var AUTH_STATE_SUBDIR = ".accounts-auth";
247
+ var SWITCHED_ACCOUNT_MARKER_FILE = "switched-account.json";
246
248
  var STATE_FILE_PREFERRED = ".config.json";
247
249
  var STATE_FILE_PREFIX = ".claude";
248
250
  var STATE_FILE_SUFFIX = ".json";
@@ -329,6 +331,14 @@ function layoutProfile(profilesRoot, configDir, env) {
329
331
  return null;
330
332
  return { configDir, profile, tool, source: "layout" };
331
333
  }
334
+ function switchedOccupant(configDir) {
335
+ const raw = readJson(join2(configDir, AUTH_STATE_SUBDIR, SWITCHED_ACCOUNT_MARKER_FILE));
336
+ if (!raw)
337
+ return null;
338
+ const profile = str(raw.profile);
339
+ const email = str(raw.email);
340
+ return profile || email ? { profile, email } : null;
341
+ }
332
342
  function sessionConfigDir(env = process.env) {
333
343
  return canonical(str(env[CONFIG_DIR_ENV]) ?? join2(home(env), DEFAULT_CONFIG_SUBDIR), env);
334
344
  }
@@ -345,6 +355,16 @@ function sessionStateFile(env = process.env) {
345
355
  }
346
356
  return null;
347
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
+ }
348
368
  async function sessionAccount(env = process.env, tool) {
349
369
  const configDir = sessionConfigDir(env);
350
370
  const unresolved = { configDir, profile: null, tool: null, source: null };
@@ -352,21 +372,26 @@ async function sessionAccount(env = process.env, tool) {
352
372
  const paths = await accountsPaths(env);
353
373
  const entry = registryEntry(paths.store, configDir, env, tool);
354
374
  const name = str(entry?.name);
355
- if (name)
356
- return { configDir, profile: name, tool: str(entry?.tool), source: "registry" };
357
- return layoutProfile(paths.profiles, configDir, env) ?? unresolved;
375
+ const owner = name ? { configDir, profile: name, tool: str(entry?.tool), source: "registry" } : layoutProfile(paths.profiles, configDir, env) ?? unresolved;
376
+ const occupant = switchedOccupant(configDir);
377
+ if (occupant && occupantMatchesLiveLogin(occupant, env))
378
+ return { configDir, profile: occupant.profile, tool: owner.tool, source: "switched" };
379
+ return owner;
358
380
  } catch {
359
381
  return unresolved;
360
382
  }
361
383
  }
362
384
  async function sessionAccountEmail(env = process.env, tool) {
363
385
  try {
364
- const stateFile = sessionStateFile(env);
365
- const live = stateFile ? str(readJson(stateFile)?.oauthAccount?.emailAddress) : null;
386
+ const live = liveAccountEmail(env);
366
387
  if (live)
367
388
  return live;
389
+ const configDir = sessionConfigDir(env);
390
+ const occupant = switchedOccupant(configDir);
391
+ if (occupant)
392
+ return occupant.email;
368
393
  const paths = await accountsPaths(env);
369
- return str(registryEntry(paths.store, sessionConfigDir(env), env, tool)?.email);
394
+ return str(registryEntry(paths.store, configDir, env, tool)?.email);
370
395
  } catch {
371
396
  return null;
372
397
  }
@@ -694,7 +719,7 @@ async function renderLine(ctx, cfg) {
694
719
  // package.json
695
720
  var package_default = {
696
721
  name: "@hasna/statusline",
697
- version: "0.0.4",
722
+ version: "0.0.6",
698
723
  description: "Tiny composable statusline CLI for AI coding agents \u2014 pre-built toggleable segments for Claude Code, with a provider model for others",
699
724
  license: "Apache-2.0",
700
725
  type: "module",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/statusline",
3
- "version": "0.0.4",
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",