@profoundlogic/coderflow-cli 0.5.7 → 0.6.0

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.
@@ -7,6 +7,7 @@ import { request } from '../http-client.js';
7
7
  import { saveApiKey, getCredentialsPathForDisplay } from '../config.js';
8
8
  import { getActiveProfileName } from '../profile.js';
9
9
  import { checkOidcConfig, initiateDeviceFlow, pollDeviceFlow } from '../oidc.js';
10
+ import { formatLoginSuccess } from '../login-display.js';
10
11
 
11
12
  /**
12
13
  * Prompt for input from stdin
@@ -198,22 +199,11 @@ async function ssoLogin() {
198
199
  const activeProfile = await getActiveProfileName();
199
200
  const credentialsPath = await getCredentialsPathForDisplay();
200
201
 
201
- console.log('');
202
- console.log(`✓ Logged in as ${result.user?.name || result.user?.username || 'user'}`);
203
- if (result.user?.email) {
204
- console.log(` Email: ${result.user.email}`);
205
- }
206
- if (result.user?.role) {
207
- console.log(` Role: ${result.user.role}`);
208
- }
209
- console.log('');
210
- if (activeProfile) {
211
- console.log(`Credentials saved to profile '${activeProfile}'`);
212
- console.log(` Location: ${credentialsPath}`);
213
- } else {
214
- console.log(`Credentials saved to ${credentialsPath}`);
215
- }
216
- console.log('');
202
+ formatLoginSuccess({
203
+ user: result.user,
204
+ activeProfile,
205
+ credentialsPath
206
+ }).forEach(line => console.log(line));
217
207
  return;
218
208
  }
219
209
 
@@ -295,18 +285,11 @@ async function passwordLogin() {
295
285
  const activeProfile = await getActiveProfileName();
296
286
  const credentialsPath = await getCredentialsPathForDisplay();
297
287
 
298
- console.log('');
299
- console.log(`✓ Logged in as ${response.user.name || response.user.username}`);
300
- console.log(` Email: ${response.user.email}`);
301
- console.log(` Role: ${response.user.role}`);
302
- console.log('');
303
- if (activeProfile) {
304
- console.log(`Credentials saved to profile '${activeProfile}'`);
305
- console.log(` Location: ${credentialsPath}`);
306
- } else {
307
- console.log(`Credentials saved to ${credentialsPath}`);
308
- }
309
- console.log('');
288
+ formatLoginSuccess({
289
+ user: response.user,
290
+ activeProfile,
291
+ credentialsPath
292
+ }).forEach(line => console.log(line));
310
293
 
311
294
  } catch (error) {
312
295
  console.error('');
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Login display formatting — pure function for post-login success output.
3
+ * Used by both password and SSO login flows.
4
+ */
5
+
6
+ /**
7
+ * Format the login success output lines.
8
+ *
9
+ * @param {object} params
10
+ * @param {object} params.user - User object with name, username, email, roles
11
+ * @param {string|null} params.activeProfile - Active profile name or null
12
+ * @param {string} params.credentialsPath - Path where credentials were saved
13
+ * @returns {string[]} Lines to print
14
+ */
15
+ export function formatLoginSuccess({ user, activeProfile, credentialsPath }) {
16
+ const lines = [];
17
+
18
+ lines.push('');
19
+ lines.push(`✓ Logged in as ${user?.name || user?.username || 'user'}`);
20
+
21
+ if (user?.email) {
22
+ lines.push(` Email: ${user.email}`);
23
+ }
24
+
25
+ if (user?.roles && user.roles.length > 0) {
26
+ lines.push(` Role: ${user.roles.join(', ')}`);
27
+ }
28
+
29
+ lines.push('');
30
+
31
+ if (activeProfile) {
32
+ lines.push(`Credentials saved to profile '${activeProfile}'`);
33
+ lines.push(` Location: ${credentialsPath}`);
34
+ } else {
35
+ lines.push(`Credentials saved to ${credentialsPath}`);
36
+ }
37
+
38
+ lines.push('');
39
+
40
+ return lines;
41
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@profoundlogic/coderflow-cli",
3
- "version": "0.5.7",
3
+ "version": "0.6.0",
4
4
  "description": "AI Coder CLI - Command-line interface for managing AI coding tasks",
5
5
  "main": "coder.js",
6
6
  "type": "module",