11/**
22 * Profile command handlers for the Index CLI.
33 *
4- * Implements: (default), show, sync, create, update subcommands.
5- * Follows the same handleX(client, subcommand, positionals, options)
6- * pattern as network.command.ts and conversation.command.ts.
4+ * Implements: (default), show, sync subcommands.
75 */
86
97import type { ApiClient } from "./api.client" ;
108import * as output from "./output" ;
119
1210/**
1311 * Route a profile subcommand to the appropriate handler.
14- *
15- * @param client - Authenticated API client.
16- * @param subcommand - The subcommand (show, sync, create, update, or undefined for self).
17- * @param positionals - Positional arguments after the subcommand.
18- * @param options - Additional options (json, linkedin, github, twitter).
1912 */
2013export async function handleProfile (
2114 client : ApiClient ,
2215 subcommand : string | undefined ,
2316 positionals : string [ ] ,
24- options : { json ?: boolean ; linkedin ?: string ; github ?: string ; twitter ?: string ; details ?: string } = { } ,
17+ options : { json ?: boolean } = { } ,
2518) : Promise < void > {
26- if ( subcommand === "create" ) {
27- await profileCreate ( client , options , options ?. json ) ;
28- return ;
29- }
30-
31- if ( subcommand === "update" ) {
32- const action = positionals . join ( " " ) ;
33- if ( ! action ) {
34- output . error ( "Usage: index profile update <action> [--details <text>]" , 1 ) ;
35- return ;
36- }
37- await profileUpdate ( client , action , options . details , options ?. json ) ;
19+ if ( subcommand === "create" || subcommand === "update" || subcommand === "search" ) {
20+ output . error (
21+ `profile ${ subcommand } was removed; use "index profile sync" for public research prefill` ,
22+ 1 ,
23+ ) ;
3824 return ;
3925 }
4026
@@ -53,33 +39,10 @@ export async function handleProfile(
5339 return ;
5440 }
5541
56- if ( subcommand === "search" ) {
57- const query = positionals . join ( " " ) ;
58- if ( ! query ) { output . error ( "Usage: index profile search <query>" , 1 ) ; return ; }
59- const result = await client . readUserContexts ( { query } ) ;
60- if ( options . json ) { console . log ( JSON . stringify ( result ) ) ; return ; }
61- if ( ! result . success ) { output . error ( result . error ?? "Search failed" , 1 ) ; return ; }
62- const data = result . data as { profiles : Array < { userId : string ; name : string ; bio ?: string ; location ?: string } > } ;
63- output . heading ( "Search Results" ) ;
64- if ( ! data . profiles ?. length ) {
65- output . dim ( " No profiles found." ) ;
66- } else {
67- for ( const p of data . profiles ) {
68- console . log ( ` ${ p . name } (${ p . userId . slice ( 0 , 8 ) } )` ) ;
69- if ( p . bio ) output . dim ( ` ${ p . bio . slice ( 0 , 100 ) } ` ) ;
70- }
71- }
72- console . log ( ) ;
73- return ;
74- }
75-
7642 // Default: show own profile
7743 await profileMe ( client , options ?. json ) ;
7844}
7945
80- /**
81- * Show the authenticated user's own profile.
82- */
8346async function profileMe ( client : ApiClient , json ?: boolean ) : Promise < void > {
8447 if ( ! json ) {
8548 output . info ( "Loading your profile..." ) ;
@@ -93,9 +56,6 @@ async function profileMe(client: ApiClient, json?: boolean): Promise<void> {
9356 output . profileCard ( user ) ;
9457}
9558
96- /**
97- * Show another user's profile by ID.
98- */
9959async function profileShow ( client : ApiClient , userId : string , json ?: boolean ) : Promise < void > {
10060 if ( ! json ) {
10161 output . info ( "Loading profile..." ) ;
@@ -108,7 +68,7 @@ async function profileShow(client: ApiClient, userId: string, json?: boolean): P
10868 output . profileCard ( user ) ;
10969}
11070
111- /** Trigger synchronous profile enrichment for the authenticated user. */
71+ /** Trigger synchronous public profile research for the authenticated user. */
11272async function profileSync ( client : ApiClient , json ?: boolean ) : Promise < void > {
11373 if ( ! json ) output . info ( "Enriching profile..." ) ;
11474 const result = await client . enrichProfile ( ) ;
@@ -117,64 +77,7 @@ async function profileSync(client: ApiClient, json?: boolean): Promise<void> {
11777 return ;
11878 }
11979 output . success ( "Profile enriched." ) ;
120- if ( result . profile . name ) output . dim ( ` Name: ${ result . profile . name } ` ) ;
121- if ( result . profile . location ) output . dim ( ` Location: ${ result . profile . location } ` ) ;
122- output . dim ( ` Social links: ${ result . profile . socials . length } ` ) ;
123- }
124-
125- /**
126- * Create a user profile from social URLs.
127- *
128- * @param client - Authenticated API client.
129- * @param options - Social URL options (linkedin, github, twitter).
130- */
131- async function profileCreate (
132- client : ApiClient ,
133- options : { linkedin ?: string ; github ?: string ; twitter ?: string } ,
134- json ?: boolean ,
135- ) : Promise < void > {
136- if ( ! json ) output . info ( "Creating profile..." ) ;
137- const query : {
138- confirm ?: boolean ;
139- linkedinUrl ?: string ;
140- githubUrl ?: string ;
141- twitterUrl ?: string ;
142- } = { confirm : true } ;
143- if ( options . linkedin ) query . linkedinUrl = options . linkedin ;
144- if ( options . github ) query . githubUrl = options . github ;
145- if ( options . twitter ) query . twitterUrl = options . twitter ;
146-
147- const result = await client . createUserContext ( query ) ;
148- if ( json ) { console . log ( JSON . stringify ( result ) ) ; return ; }
149- if ( ! result . success ) {
150- output . error ( result . error ?? "Profile creation failed" , 1 ) ;
151- return ;
152- }
153- output . success ( "Profile created." ) ;
154- }
155-
156- /**
157- * Update the user's profile with a natural-language action.
158- *
159- * @param client - Authenticated API client.
160- * @param action - The update action description.
161- * @param details - Optional additional details.
162- */
163- async function profileUpdate (
164- client : ApiClient ,
165- action : string ,
166- details ?: string ,
167- json ?: boolean ,
168- ) : Promise < void > {
169- if ( ! json ) output . info ( "Updating profile..." ) ;
170- const query : { action : string ; details ?: string } = { action } ;
171- if ( details ) query . details = details ;
172-
173- const result = await client . updateUserContext ( query ) ;
174- if ( json ) { console . log ( JSON . stringify ( result ) ) ; return ; }
175- if ( ! result . success ) {
176- output . error ( result . error ?? "Profile update failed" , 1 ) ;
177- return ;
178- }
179- output . success ( "Profile updated." ) ;
80+ if ( result . profile ?. name ) output . dim ( ` Name: ${ result . profile . name } ` ) ;
81+ if ( result . profile ?. location ) output . dim ( ` Location: ${ result . profile . location } ` ) ;
82+ output . dim ( ` Social links: ${ result . profile ?. socials ?. length ?? 0 } ` ) ;
18083}
0 commit comments