@@ -121,8 +121,9 @@ function printJson(data: unknown): void {
121121
122122/** Apply --fields filter to output. Reduces context window for AI agents. */
123123function applyFieldsFilter ( data : unknown , fields ?: string ) : unknown {
124- if ( ! fields ) return data ;
124+ if ( fields === undefined || fields === null ) return data ;
125125 const keys = fields . split ( "," ) . map ( ( f ) => f . trim ( ) ) . filter ( Boolean ) ;
126+ if ( keys . length === 0 ) return data ; // --fields "" → treat as no filter
126127 if ( Array . isArray ( data ) && data . length > 0 ) {
127128 const sample = data [ 0 ] as Record < string , unknown > ;
128129 const available = Object . keys ( sample ) ;
@@ -1043,12 +1044,20 @@ export function createProgram(): Command {
10431044 . description ( "Show resource schema for payload construction. AI agents: use this to discover fields before building payloads." )
10441045 . action ( ( resource ) => {
10451046 if ( ! resource ) {
1046- printResult ( {
1047- schema : "agenticflow.schema.index.v1" ,
1048- available : Object . keys ( SCHEMAS ) ,
1049- usage : "af schema <resource> --json" ,
1050- hint : "Use 'af schema agent' to see agent create/stream payload schemas." ,
1051- } ) ;
1047+ if ( isJsonFlagEnabled ( ) ) {
1048+ printResult ( {
1049+ schema : "agenticflow.schema.index.v1" ,
1050+ available : Object . keys ( SCHEMAS ) ,
1051+ usage : "af schema <resource> --json" ,
1052+ hint : "Use 'af schema agent' to see agent create/stream payload schemas." ,
1053+ } ) ;
1054+ } else {
1055+ console . log ( "Available resource schemas:" ) ;
1056+ for ( const key of Object . keys ( SCHEMAS ) ) {
1057+ console . log ( ` af schema ${ key } ` ) ;
1058+ }
1059+ console . log ( "\nUse --json for machine-readable output." ) ;
1060+ }
10521061 return ;
10531062 }
10541063 const schema = SCHEMAS [ resource ] ;
@@ -1059,7 +1068,25 @@ export function createProgram(): Command {
10591068 `Available: ${ Object . keys ( SCHEMAS ) . join ( ", " ) } ` ,
10601069 ) ;
10611070 }
1062- printResult ( schema ) ;
1071+ if ( isJsonFlagEnabled ( ) ) {
1072+ printResult ( schema ) ;
1073+ } else {
1074+ const s = schema as Record < string , unknown > ;
1075+ console . log ( `Resource: ${ s . resource } ` ) ;
1076+ if ( s . create ) {
1077+ const c = s . create as Record < string , unknown > ;
1078+ console . log ( `\nCreate (required): ${ ( c . required as string [ ] ) . join ( ", " ) } ` ) ;
1079+ if ( c . optional ) {
1080+ console . log ( "Create (optional):" ) ;
1081+ for ( const [ k , v ] of Object . entries ( c . optional as Record < string , string > ) ) {
1082+ console . log ( ` ${ k } : ${ v } ` ) ;
1083+ }
1084+ }
1085+ if ( c . example ) console . log ( `\nExample:\n ${ JSON . stringify ( c . example ) } ` ) ;
1086+ }
1087+ if ( s . fields ) console . log ( `\nFields: ${ ( s . fields as string [ ] ) . join ( ", " ) } ` ) ;
1088+ console . log ( "\nUse --json for full machine-readable schema." ) ;
1089+ }
10631090 } ) ;
10641091
10651092 // ═════════════════════════════════════════════════════════════════
@@ -4328,7 +4355,8 @@ export function createProgram(): Command {
43284355 fail ( "agent_fetch_failed" , `Failed to fetch AgenticFlow agent ${ opts . agentId } : ${ message } ` ) ;
43294356 }
43304357
4331- let companyId = resolvePaperclipCompanyId ( opts . companyId ) ;
4358+ // --company-name takes priority: always create a new company
4359+ let companyId = opts . companyName ? undefined : resolvePaperclipCompanyId ( opts . companyId ) ;
43324360 if ( ! companyId && opts . companyName ) {
43334361 const company = await pc . createCompany ( { name : opts . companyName } ) ;
43344362 companyId = company . id ;
0 commit comments