@barekey/cli 0.5.5 → 0.5.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.
@@ -162,6 +162,7 @@ async function runWhoami(options) {
162
162
  console.log(await formatWhoamiWithAvatar({
163
163
  displayName: resolveDisplayName(session),
164
164
  email: session.email,
165
+ plan: session.plan,
165
166
  imageUrl: session.imageUrl,
166
167
  }));
167
168
  }
@@ -54,6 +54,7 @@ export declare const CliSessionResponseSchema: Schema.Struct<{
54
54
  displayName: Schema.NullOr<typeof Schema.String>;
55
55
  email: Schema.NullOr<typeof Schema.String>;
56
56
  imageUrl: Schema.NullOr<typeof Schema.String>;
57
+ plan: Schema.NullOr<Schema.Literal<["free", "pro", "max"]>>;
57
58
  orgId: typeof Schema.String;
58
59
  orgSlug: typeof Schema.String;
59
60
  source: Schema.Literal<["clerk", "cli"]>;
@@ -56,6 +56,7 @@ export const CliSessionResponseSchema = Schema.Struct({
56
56
  displayName: Schema.NullOr(Schema.String),
57
57
  email: Schema.NullOr(Schema.String),
58
58
  imageUrl: Schema.NullOr(Schema.String),
59
+ plan: Schema.NullOr(Schema.Literal("free", "pro", "max")),
59
60
  orgId: Schema.String,
60
61
  orgSlug: Schema.String,
61
62
  source: Schema.Literal("clerk", "cli"),
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Builds the terminal `whoami` output with a tiny ANSI avatar when supported.
3
3
  *
4
- * @param input The display name, email, and optional avatar image URL.
4
+ * @param input The display name, email, plan, and optional avatar image URL.
5
5
  * @returns The formatted `whoami` string ready for stdout.
6
6
  * @remarks Non-TTY terminals and avatar failures fall back to plain text without throwing.
7
7
  * @lastModified 2026-03-19
@@ -10,5 +10,6 @@
10
10
  export declare function formatWhoamiWithAvatar(input: {
11
11
  displayName: string;
12
12
  email: string | null;
13
+ plan: "free" | "pro" | "max" | null;
13
14
  imageUrl: string | null;
14
15
  }): Promise<string>;
@@ -1,6 +1,7 @@
1
1
  import { Jimp } from "jimp";
2
- const DEFAULT_AVATAR_COLUMNS = 8;
3
- const DEFAULT_AVATAR_ROWS = 8;
2
+ import pc from "picocolors";
3
+ const DEFAULT_AVATAR_COLUMNS = 10;
4
+ const DEFAULT_AVATAR_ROWS = 5;
4
5
  function supportsAnsiAvatar() {
5
6
  if (!process.stdout.isTTY) {
6
7
  return false;
@@ -93,17 +94,39 @@ function joinAvatarAndText(avatarLines, textLines) {
93
94
  }
94
95
  return renderedRows.join("\n");
95
96
  }
97
+ function formatPlanLabel(plan) {
98
+ if (plan === null) {
99
+ return "No plan";
100
+ }
101
+ if (plan === "free") {
102
+ return "Free";
103
+ }
104
+ if (plan === "pro") {
105
+ return "Pro";
106
+ }
107
+ return "Max";
108
+ }
96
109
  /**
97
110
  * Builds the terminal `whoami` output with a tiny ANSI avatar when supported.
98
111
  *
99
- * @param input The display name, email, and optional avatar image URL.
112
+ * @param input The display name, email, plan, and optional avatar image URL.
100
113
  * @returns The formatted `whoami` string ready for stdout.
101
114
  * @remarks Non-TTY terminals and avatar failures fall back to plain text without throwing.
102
115
  * @lastModified 2026-03-19
103
116
  * @author GPT-5.4
104
117
  */
105
118
  export async function formatWhoamiWithAvatar(input) {
106
- const textLines = [`Signed in as ${input.displayName}.`, input.email ?? ""].filter((line) => line.length > 0);
119
+ const firstLine = `Signed in as ${pc.bold(input.displayName)}`;
120
+ const secondSegments = [];
121
+ if (input.email !== null && input.email.length > 0) {
122
+ secondSegments.push(pc.gray(input.email));
123
+ }
124
+ const formattedPlan = pc.yellow(formatPlanLabel(input.plan));
125
+ if (secondSegments.length > 0) {
126
+ secondSegments.push(pc.dim("•"));
127
+ }
128
+ secondSegments.push(formattedPlan);
129
+ const textLines = [firstLine, secondSegments.join(" ")].filter((line) => line.length > 0);
107
130
  if (!supportsAnsiAvatar() || input.imageUrl === null) {
108
131
  return textLines.join("\n");
109
132
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barekey/cli",
3
- "version": "0.5.5",
3
+ "version": "0.5.6",
4
4
  "description": "Barekey command line interface",
5
5
  "type": "module",
6
6
  "bin": {
@@ -201,6 +201,7 @@ async function runWhoami(options: { json?: boolean }): Promise<void> {
201
201
  await formatWhoamiWithAvatar({
202
202
  displayName: resolveDisplayName(session),
203
203
  email: session.email,
204
+ plan: session.plan,
204
205
  imageUrl: session.imageUrl,
205
206
  }),
206
207
  );
@@ -78,6 +78,7 @@ export const CliSessionResponseSchema = Schema.Struct({
78
78
  displayName: Schema.NullOr(Schema.String),
79
79
  email: Schema.NullOr(Schema.String),
80
80
  imageUrl: Schema.NullOr(Schema.String),
81
+ plan: Schema.NullOr(Schema.Literal("free", "pro", "max")),
81
82
  orgId: Schema.String,
82
83
  orgSlug: Schema.String,
83
84
  source: Schema.Literal("clerk", "cli"),
@@ -1,7 +1,8 @@
1
1
  import { Jimp } from "jimp";
2
+ import pc from "picocolors";
2
3
 
3
- const DEFAULT_AVATAR_COLUMNS = 8;
4
- const DEFAULT_AVATAR_ROWS = 8;
4
+ const DEFAULT_AVATAR_COLUMNS = 10;
5
+ const DEFAULT_AVATAR_ROWS = 5;
5
6
 
6
7
  type Rgba = {
7
8
  red: number;
@@ -131,10 +132,26 @@ function joinAvatarAndText(
131
132
  return renderedRows.join("\n");
132
133
  }
133
134
 
135
+ function formatPlanLabel(plan: "free" | "pro" | "max" | null): string {
136
+ if (plan === null) {
137
+ return "No plan";
138
+ }
139
+
140
+ if (plan === "free") {
141
+ return "Free";
142
+ }
143
+
144
+ if (plan === "pro") {
145
+ return "Pro";
146
+ }
147
+
148
+ return "Max";
149
+ }
150
+
134
151
  /**
135
152
  * Builds the terminal `whoami` output with a tiny ANSI avatar when supported.
136
153
  *
137
- * @param input The display name, email, and optional avatar image URL.
154
+ * @param input The display name, email, plan, and optional avatar image URL.
138
155
  * @returns The formatted `whoami` string ready for stdout.
139
156
  * @remarks Non-TTY terminals and avatar failures fall back to plain text without throwing.
140
157
  * @lastModified 2026-03-19
@@ -143,9 +160,23 @@ function joinAvatarAndText(
143
160
  export async function formatWhoamiWithAvatar(input: {
144
161
  displayName: string;
145
162
  email: string | null;
163
+ plan: "free" | "pro" | "max" | null;
146
164
  imageUrl: string | null;
147
165
  }): Promise<string> {
148
- const textLines = [`Signed in as ${input.displayName}.`, input.email ?? ""].filter(
166
+ const firstLine = `Signed in as ${pc.bold(input.displayName)}`;
167
+ const secondSegments: Array<string> = [];
168
+
169
+ if (input.email !== null && input.email.length > 0) {
170
+ secondSegments.push(pc.gray(input.email));
171
+ }
172
+
173
+ const formattedPlan = pc.yellow(formatPlanLabel(input.plan));
174
+ if (secondSegments.length > 0) {
175
+ secondSegments.push(pc.dim("•"));
176
+ }
177
+ secondSegments.push(formattedPlan);
178
+
179
+ const textLines = [firstLine, secondSegments.join(" ")].filter(
149
180
  (line) => line.length > 0,
150
181
  );
151
182