@kb-labs/shared-cli-ui 1.0.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.
- package/README.md +342 -0
- package/dist/debug.cjs +765 -0
- package/dist/debug.cjs.map +1 -0
- package/dist/debug.d.cts +151 -0
- package/dist/debug.d.ts +151 -0
- package/dist/debug.js +735 -0
- package/dist/debug.js.map +1 -0
- package/dist/index.cjs +2629 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1037 -0
- package/dist/index.d.ts +1037 -0
- package/dist/index.js +2516 -0
- package/dist/index.js.map +1 -0
- package/package.json +71 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1037 @@
|
|
|
1
|
+
export { DebugContext, DebugDetailLevel, DebugEntry, DebugExportOptions, DebugFilterOptions, DebugFormat, DebugLevel, DebugMeta, DebugOutput, DebugOutputOptions, DebugSection, DebugTrace, DebugTree, DebugTreeNode, DebugTreeOptions, HumanFormatterOptions, TraceOptions, createDebugTree, describeEntriesAI, describeEntriesHuman, describeEntriesTimeline, exportDebugEntries, exportToChromeFormat, exportToJSON, exportToPlainText, filterByLevel, filterByNamespace, filterByTimeRange, filterDebugEntries, formatDebugEntriesAI, formatDebugEntriesHuman, formatDebugEntryAI, formatDebugEntryHuman, formatDebugOutput, formatDebugOutputs, formatTimeline, formatTimelineNode, formatTimelineWithSummary, groupByGroup, groupByNamespace, searchInLogs, shouldUseAIFormat } from './debug.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Minimalist color utilities for CLI output
|
|
5
|
+
* Uses strategic color application - only for status, not decoration
|
|
6
|
+
*/
|
|
7
|
+
declare const colors: {
|
|
8
|
+
success: (text: string) => string;
|
|
9
|
+
error: (text: string) => string;
|
|
10
|
+
warning: (text: string) => string;
|
|
11
|
+
info: (text: string) => string;
|
|
12
|
+
primary: (text: string) => string;
|
|
13
|
+
accent: (text: string) => string;
|
|
14
|
+
highlight: (text: string) => string;
|
|
15
|
+
secondary: (text: string) => string;
|
|
16
|
+
emphasis: (text: string) => string;
|
|
17
|
+
muted: (text: string) => string;
|
|
18
|
+
foreground: (text: string) => string;
|
|
19
|
+
dim: (text: string) => string;
|
|
20
|
+
bold: (text: string) => string;
|
|
21
|
+
underline: (text: string) => string;
|
|
22
|
+
inverse: (text: string) => string;
|
|
23
|
+
};
|
|
24
|
+
declare const symbols: {
|
|
25
|
+
success: string;
|
|
26
|
+
error: string;
|
|
27
|
+
warning: string;
|
|
28
|
+
info: string;
|
|
29
|
+
bullet: string;
|
|
30
|
+
clock: string;
|
|
31
|
+
folder: string;
|
|
32
|
+
package: string;
|
|
33
|
+
pointer: string;
|
|
34
|
+
section: string;
|
|
35
|
+
};
|
|
36
|
+
declare const supportsColor: boolean;
|
|
37
|
+
declare const safeColors: {
|
|
38
|
+
success: (text: string) => string;
|
|
39
|
+
error: (text: string) => string;
|
|
40
|
+
warning: (text: string) => string;
|
|
41
|
+
info: (text: string) => string;
|
|
42
|
+
accent: (text: string) => string;
|
|
43
|
+
primary: (text: string) => string;
|
|
44
|
+
highlight: (text: string) => string;
|
|
45
|
+
secondary: (text: string) => string;
|
|
46
|
+
emphasis: (text: string) => string;
|
|
47
|
+
foreground: (text: string) => string;
|
|
48
|
+
muted: (text: string) => string;
|
|
49
|
+
dim: (text: string) => string;
|
|
50
|
+
bold: (text: string) => string;
|
|
51
|
+
underline: (text: string) => string;
|
|
52
|
+
inverse: (text: string) => string;
|
|
53
|
+
};
|
|
54
|
+
declare const safeSymbols: {
|
|
55
|
+
success: string;
|
|
56
|
+
error: string;
|
|
57
|
+
warning: string;
|
|
58
|
+
info: string;
|
|
59
|
+
bullet: string;
|
|
60
|
+
clock: string;
|
|
61
|
+
folder: string;
|
|
62
|
+
package: string;
|
|
63
|
+
pointer: string;
|
|
64
|
+
section: string;
|
|
65
|
+
separator: string;
|
|
66
|
+
border: string;
|
|
67
|
+
topLeft: string;
|
|
68
|
+
topRight: string;
|
|
69
|
+
bottomLeft: string;
|
|
70
|
+
bottomRight: string;
|
|
71
|
+
leftT: string;
|
|
72
|
+
rightT: string;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Progress indicators and loaders for CLI operations
|
|
77
|
+
*
|
|
78
|
+
* Periodic animation implementation (works in child processes as multi-line output).
|
|
79
|
+
*/
|
|
80
|
+
interface LoaderOptions {
|
|
81
|
+
/** Text to show while loading */
|
|
82
|
+
text?: string;
|
|
83
|
+
/** Whether to show spinner (true) or progress bar (false) */
|
|
84
|
+
spinner?: boolean;
|
|
85
|
+
/** Total items for progress bar */
|
|
86
|
+
total?: number;
|
|
87
|
+
/** Current item for progress bar */
|
|
88
|
+
current?: number;
|
|
89
|
+
/** Whether JSON mode is enabled (disables all visual feedback) */
|
|
90
|
+
jsonMode?: boolean;
|
|
91
|
+
}
|
|
92
|
+
declare class Loader {
|
|
93
|
+
private isActive;
|
|
94
|
+
private options;
|
|
95
|
+
private frameIndex;
|
|
96
|
+
private intervalId?;
|
|
97
|
+
private currentText;
|
|
98
|
+
constructor(options?: LoaderOptions);
|
|
99
|
+
start(): void;
|
|
100
|
+
update(options: Partial<LoaderOptions>): void;
|
|
101
|
+
stop(): void;
|
|
102
|
+
succeed(message?: string): void;
|
|
103
|
+
fail(message?: string): void;
|
|
104
|
+
private clearInterval;
|
|
105
|
+
private updateProgress;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Create a simple spinner
|
|
109
|
+
*/
|
|
110
|
+
declare function createSpinner(text: string, jsonMode?: boolean): Loader;
|
|
111
|
+
/**
|
|
112
|
+
* Create a progress bar
|
|
113
|
+
*/
|
|
114
|
+
declare function createProgressBar(text: string, total: number, jsonMode?: boolean): Loader;
|
|
115
|
+
/**
|
|
116
|
+
* Simple loading message without spinner
|
|
117
|
+
*/
|
|
118
|
+
declare function showLoading(text: string, jsonMode?: boolean): void;
|
|
119
|
+
/**
|
|
120
|
+
* Show completion message
|
|
121
|
+
*/
|
|
122
|
+
declare function showSuccess(text: string, jsonMode?: boolean): void;
|
|
123
|
+
/**
|
|
124
|
+
* Show error message
|
|
125
|
+
*/
|
|
126
|
+
declare function showError(text: string, jsonMode?: boolean): void;
|
|
127
|
+
/**
|
|
128
|
+
* Create a loader for progress indication
|
|
129
|
+
*
|
|
130
|
+
* @param text - Text to display while loading
|
|
131
|
+
* @param options - Optional configuration
|
|
132
|
+
* @returns Loader instance
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```typescript
|
|
136
|
+
* import { useLoader } from '@kb-labs/sdk';
|
|
137
|
+
*
|
|
138
|
+
* const loader = useLoader('Processing data...');
|
|
139
|
+
* loader.start();
|
|
140
|
+
* // ... do work ...
|
|
141
|
+
* loader.succeed('Processing complete!');
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
declare function useLoader(text: string, options?: Partial<LoaderOptions>): Loader;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Output formatting utilities for structured CLI output
|
|
148
|
+
*/
|
|
149
|
+
declare function stripAnsi(input: string): string;
|
|
150
|
+
declare function hasAnsi(input: string): boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Create a boxed section with title
|
|
153
|
+
*/
|
|
154
|
+
declare function box(title: string, content?: string[], maxWidth?: number): string;
|
|
155
|
+
/**
|
|
156
|
+
* Add consistent indentation to lines
|
|
157
|
+
*/
|
|
158
|
+
declare function indent(lines: string[], level?: number): string[];
|
|
159
|
+
/**
|
|
160
|
+
* Create a section with header and content
|
|
161
|
+
*/
|
|
162
|
+
declare function section(header: string, content: string[]): string[];
|
|
163
|
+
/**
|
|
164
|
+
* Format a table with consistent spacing
|
|
165
|
+
*/
|
|
166
|
+
declare function table(rows: (string | number)[][], headers?: string[]): string[];
|
|
167
|
+
/**
|
|
168
|
+
* Format key-value pairs
|
|
169
|
+
*/
|
|
170
|
+
interface KeyValueOptions {
|
|
171
|
+
padKeys?: boolean;
|
|
172
|
+
}
|
|
173
|
+
declare function keyValue(pairs: Record<string, string | number>, options?: KeyValueOptions): string[];
|
|
174
|
+
/**
|
|
175
|
+
* Format a list with bullets
|
|
176
|
+
*/
|
|
177
|
+
declare function bulletList(items: string[]): string[];
|
|
178
|
+
interface SafeKeyValueOptions {
|
|
179
|
+
indent?: number;
|
|
180
|
+
pad?: boolean;
|
|
181
|
+
valueColor?: (value: string, key: string) => string;
|
|
182
|
+
}
|
|
183
|
+
declare function safeKeyValue(pairs: Record<string, string | number>, options?: SafeKeyValueOptions): string[];
|
|
184
|
+
/**
|
|
185
|
+
* Apply primary headline styling
|
|
186
|
+
*/
|
|
187
|
+
declare function headline(text: string): string;
|
|
188
|
+
/**
|
|
189
|
+
* Accent label style (used for tags/pills)
|
|
190
|
+
*/
|
|
191
|
+
declare function accentLabel(text: string): string;
|
|
192
|
+
/**
|
|
193
|
+
* Muted helper
|
|
194
|
+
*/
|
|
195
|
+
declare function muted(text: string): string;
|
|
196
|
+
/**
|
|
197
|
+
* Format file size
|
|
198
|
+
*/
|
|
199
|
+
declare function formatSize(bytes: number): string;
|
|
200
|
+
/**
|
|
201
|
+
* Format relative time
|
|
202
|
+
*/
|
|
203
|
+
declare function formatRelativeTime(timestamp: string | Date): string;
|
|
204
|
+
interface FormatTimestampOptions {
|
|
205
|
+
mode?: 'local' | 'iso';
|
|
206
|
+
timeZone?: string;
|
|
207
|
+
includeSeconds?: boolean;
|
|
208
|
+
includeMilliseconds?: boolean;
|
|
209
|
+
includeOffset?: boolean;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Format timestamps as absolute values (local or ISO) with optional offsets
|
|
213
|
+
*/
|
|
214
|
+
declare function formatTimestamp(timestamp: string | Date, options?: FormatTimestampOptions): string;
|
|
215
|
+
/**
|
|
216
|
+
* Truncate text with ellipsis
|
|
217
|
+
*/
|
|
218
|
+
declare function truncate(text: string, maxLength: number): string;
|
|
219
|
+
/**
|
|
220
|
+
* Pad string to specific width
|
|
221
|
+
*/
|
|
222
|
+
declare function pad(text: string, width: number, align?: 'left' | 'right' | 'center'): string;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Command output formatting utilities
|
|
226
|
+
* Provides consistent formatting for CLI command results
|
|
227
|
+
*/
|
|
228
|
+
interface CommandResult {
|
|
229
|
+
title: string;
|
|
230
|
+
summary: Record<string, string | number>;
|
|
231
|
+
timing?: number | Record<string, number>;
|
|
232
|
+
diagnostics?: string[];
|
|
233
|
+
warnings?: string[];
|
|
234
|
+
errors?: string[];
|
|
235
|
+
suggestions?: string[];
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Format timing in milliseconds to human-readable string
|
|
239
|
+
*/
|
|
240
|
+
declare function formatTiming(ms: number): string;
|
|
241
|
+
/**
|
|
242
|
+
* Format timing breakdown as array of strings
|
|
243
|
+
*/
|
|
244
|
+
declare function formatTimingBreakdown(timings: Record<string, number>): string[];
|
|
245
|
+
/**
|
|
246
|
+
* Format complete command output with box, summary, timing, and additional info
|
|
247
|
+
*/
|
|
248
|
+
declare function formatCommandOutput(result: CommandResult): string;
|
|
249
|
+
/**
|
|
250
|
+
* Create a simple command result with just title, summary, and timing
|
|
251
|
+
*/
|
|
252
|
+
declare function createSimpleResult(title: string, summary: Record<string, string | number>, timing?: number): CommandResult;
|
|
253
|
+
/**
|
|
254
|
+
* Create a detailed command result with all optional fields
|
|
255
|
+
*/
|
|
256
|
+
declare function createDetailedResult(title: string, summary: Record<string, string | number>, options?: {
|
|
257
|
+
timing?: number | Record<string, number>;
|
|
258
|
+
diagnostics?: string[];
|
|
259
|
+
warnings?: string[];
|
|
260
|
+
errors?: string[];
|
|
261
|
+
suggestions?: string[];
|
|
262
|
+
}): CommandResult;
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Timing tracker utility for CLI commands
|
|
266
|
+
* Provides checkpoint-based timing measurement
|
|
267
|
+
*/
|
|
268
|
+
declare class TimingTracker {
|
|
269
|
+
private start;
|
|
270
|
+
private checkpoints;
|
|
271
|
+
constructor();
|
|
272
|
+
/**
|
|
273
|
+
* Record a timing checkpoint
|
|
274
|
+
*/
|
|
275
|
+
checkpoint(name: string): void;
|
|
276
|
+
/**
|
|
277
|
+
* Get total elapsed time in milliseconds
|
|
278
|
+
*/
|
|
279
|
+
total(): number;
|
|
280
|
+
/**
|
|
281
|
+
* Get timing breakdown including total
|
|
282
|
+
*/
|
|
283
|
+
breakdown(): Record<string, number>;
|
|
284
|
+
/**
|
|
285
|
+
* Get timing breakdown without total
|
|
286
|
+
*/
|
|
287
|
+
checkpointsOnly(): Record<string, number>;
|
|
288
|
+
/**
|
|
289
|
+
* Reset the timer
|
|
290
|
+
*/
|
|
291
|
+
reset(): void;
|
|
292
|
+
/**
|
|
293
|
+
* Get elapsed time since last checkpoint or start
|
|
294
|
+
*/
|
|
295
|
+
sinceLastCheckpoint(): number;
|
|
296
|
+
/**
|
|
297
|
+
* Get elapsed time since a specific checkpoint
|
|
298
|
+
*/
|
|
299
|
+
sinceCheckpoint(checkpointName: string): number | null;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Command suggestions and validation utilities
|
|
304
|
+
*/
|
|
305
|
+
interface CommandSuggestion {
|
|
306
|
+
id: string;
|
|
307
|
+
command: string;
|
|
308
|
+
args: string[];
|
|
309
|
+
description: string;
|
|
310
|
+
impact: 'safe' | 'disruptive';
|
|
311
|
+
when: string;
|
|
312
|
+
available?: boolean;
|
|
313
|
+
}
|
|
314
|
+
interface CommandRegistry {
|
|
315
|
+
commands: Set<string>;
|
|
316
|
+
groups: Map<string, Set<string>>;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Create a command registry from available commands
|
|
320
|
+
*/
|
|
321
|
+
declare function createCommandRegistry(commands: string[]): CommandRegistry;
|
|
322
|
+
/**
|
|
323
|
+
* Check if a command is available in the registry
|
|
324
|
+
*/
|
|
325
|
+
declare function isCommandAvailable(command: string, registry: CommandRegistry): boolean;
|
|
326
|
+
/**
|
|
327
|
+
* Validate suggestions against available commands
|
|
328
|
+
*/
|
|
329
|
+
declare function validateSuggestions(suggestions: CommandSuggestion[], registry: CommandRegistry): CommandSuggestion[];
|
|
330
|
+
/**
|
|
331
|
+
* Generate common devlink suggestions
|
|
332
|
+
*/
|
|
333
|
+
declare function generateDevlinkSuggestions(warningCodes: Set<string>, context: {
|
|
334
|
+
undo?: {
|
|
335
|
+
available: boolean;
|
|
336
|
+
};
|
|
337
|
+
}, registry: CommandRegistry): CommandSuggestion[];
|
|
338
|
+
/**
|
|
339
|
+
* Generate quick actions for common scenarios
|
|
340
|
+
*/
|
|
341
|
+
declare function generateQuickActions(hasWarnings: boolean, registry: CommandRegistry, group?: string): CommandSuggestion[];
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Command discovery utilities for CLI systems
|
|
345
|
+
*/
|
|
346
|
+
interface CommandInfo {
|
|
347
|
+
id: string;
|
|
348
|
+
group: string;
|
|
349
|
+
name: string;
|
|
350
|
+
description: string;
|
|
351
|
+
available: boolean;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Discover available commands from CLI manifest or registry
|
|
355
|
+
* This is a generic interface that can be implemented by different CLI systems
|
|
356
|
+
*/
|
|
357
|
+
interface CommandDiscovery {
|
|
358
|
+
/**
|
|
359
|
+
* Get all available commands
|
|
360
|
+
*/
|
|
361
|
+
getAvailableCommands(): Promise<string[]>;
|
|
362
|
+
/**
|
|
363
|
+
* Get command info by ID
|
|
364
|
+
*/
|
|
365
|
+
getCommandInfo(commandId: string): Promise<CommandInfo | null>;
|
|
366
|
+
/**
|
|
367
|
+
* Check if a command is available
|
|
368
|
+
*/
|
|
369
|
+
isCommandAvailable(commandId: string): Promise<boolean>;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Simple command discovery that works with a predefined list
|
|
373
|
+
* Can be extended to work with actual CLI registries
|
|
374
|
+
*/
|
|
375
|
+
declare class StaticCommandDiscovery implements CommandDiscovery {
|
|
376
|
+
private commands;
|
|
377
|
+
constructor(commands: string[]);
|
|
378
|
+
getAvailableCommands(): Promise<string[]>;
|
|
379
|
+
getCommandInfo(commandId: string): Promise<CommandInfo | null>;
|
|
380
|
+
isCommandAvailable(commandId: string): Promise<boolean>;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Create a command discovery instance from a command list
|
|
384
|
+
*/
|
|
385
|
+
declare function createCommandDiscovery(commands: string[]): CommandDiscovery;
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* CLI manifest parsing utilities
|
|
389
|
+
*/
|
|
390
|
+
interface CommandManifest {
|
|
391
|
+
manifestVersion: string;
|
|
392
|
+
id: string;
|
|
393
|
+
aliases?: string[];
|
|
394
|
+
group: string;
|
|
395
|
+
describe: string;
|
|
396
|
+
longDescription?: string;
|
|
397
|
+
requires?: string[];
|
|
398
|
+
flags?: FlagDefinition[];
|
|
399
|
+
examples?: string[];
|
|
400
|
+
loader: () => Promise<{
|
|
401
|
+
run: any;
|
|
402
|
+
}>;
|
|
403
|
+
}
|
|
404
|
+
interface FlagDefinition {
|
|
405
|
+
name: string;
|
|
406
|
+
type: 'string' | 'boolean' | 'number' | 'array';
|
|
407
|
+
alias?: string;
|
|
408
|
+
default?: any;
|
|
409
|
+
description?: string;
|
|
410
|
+
choices?: string[];
|
|
411
|
+
required?: boolean;
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Extract command IDs from a manifest
|
|
415
|
+
*/
|
|
416
|
+
declare function extractCommandIds(manifest: CommandManifest[]): string[];
|
|
417
|
+
/**
|
|
418
|
+
* Extract command groups from a manifest
|
|
419
|
+
*/
|
|
420
|
+
declare function extractCommandGroups(manifest: CommandManifest[]): string[];
|
|
421
|
+
/**
|
|
422
|
+
* Find commands by group
|
|
423
|
+
*/
|
|
424
|
+
declare function findCommandsByGroup(manifest: CommandManifest[], group: string): CommandManifest[];
|
|
425
|
+
/**
|
|
426
|
+
* Find command by ID
|
|
427
|
+
*/
|
|
428
|
+
declare function findCommandById(manifest: CommandManifest[], id: string): CommandManifest | undefined;
|
|
429
|
+
/**
|
|
430
|
+
* Get command info for suggestions
|
|
431
|
+
*/
|
|
432
|
+
declare function getCommandInfo(manifest: CommandManifest[], commandId: string): {
|
|
433
|
+
id: string;
|
|
434
|
+
group: string;
|
|
435
|
+
name: string;
|
|
436
|
+
description: string;
|
|
437
|
+
available: boolean;
|
|
438
|
+
} | null;
|
|
439
|
+
/**
|
|
440
|
+
* Generate suggestions for a specific group
|
|
441
|
+
*/
|
|
442
|
+
declare function generateGroupSuggestions(manifest: CommandManifest[], group: string, _warningCodes: Set<string>, _context: any): Array<{
|
|
443
|
+
id: string;
|
|
444
|
+
command: string;
|
|
445
|
+
args: string[];
|
|
446
|
+
description: string;
|
|
447
|
+
impact: 'safe' | 'disruptive';
|
|
448
|
+
when: string;
|
|
449
|
+
available: boolean;
|
|
450
|
+
}>;
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Multi-CLI suggestions system
|
|
454
|
+
* Supports multiple CLI packages with their own manifests
|
|
455
|
+
*/
|
|
456
|
+
|
|
457
|
+
interface MultiCLIContext {
|
|
458
|
+
warningCodes: Set<string>;
|
|
459
|
+
[key: string]: any;
|
|
460
|
+
}
|
|
461
|
+
interface CLIPackage {
|
|
462
|
+
name: string;
|
|
463
|
+
group: string;
|
|
464
|
+
commands: CommandManifest[];
|
|
465
|
+
priority: number;
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Multi-CLI suggestions manager
|
|
469
|
+
*/
|
|
470
|
+
declare class MultiCLISuggestions {
|
|
471
|
+
private packages;
|
|
472
|
+
private globalRegistry;
|
|
473
|
+
/**
|
|
474
|
+
* Register a CLI package
|
|
475
|
+
*/
|
|
476
|
+
registerPackage(pkg: CLIPackage): void;
|
|
477
|
+
/**
|
|
478
|
+
* Get or create global command registry
|
|
479
|
+
*/
|
|
480
|
+
private getGlobalRegistry;
|
|
481
|
+
/**
|
|
482
|
+
* Generate suggestions for a specific group
|
|
483
|
+
*/
|
|
484
|
+
generateGroupSuggestions(group: string, context: MultiCLIContext): CommandSuggestion[];
|
|
485
|
+
/**
|
|
486
|
+
* Generate all suggestions across all packages
|
|
487
|
+
*/
|
|
488
|
+
generateAllSuggestions(context: MultiCLIContext): CommandSuggestion[];
|
|
489
|
+
/**
|
|
490
|
+
* Get available commands for a group
|
|
491
|
+
*/
|
|
492
|
+
getAvailableCommands(group: string): string[];
|
|
493
|
+
/**
|
|
494
|
+
* Get all registered packages
|
|
495
|
+
*/
|
|
496
|
+
getPackages(): CLIPackage[];
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Dynamic command discovery that loads commands from actual manifests
|
|
501
|
+
*/
|
|
502
|
+
|
|
503
|
+
interface ManifestLoader {
|
|
504
|
+
loadManifest(packageName: string): Promise<any[]>;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Dynamic command discovery that loads commands from manifests
|
|
508
|
+
*/
|
|
509
|
+
declare class DynamicCommandDiscovery implements CommandDiscovery {
|
|
510
|
+
private manifestLoader;
|
|
511
|
+
private packageNames;
|
|
512
|
+
private manifestCache;
|
|
513
|
+
private commandCache;
|
|
514
|
+
constructor(manifestLoader: ManifestLoader, packageNames: string[]);
|
|
515
|
+
getAvailableCommands(): Promise<string[]>;
|
|
516
|
+
getCommandInfo(commandId: string): Promise<CommandInfo | null>;
|
|
517
|
+
isCommandAvailable(commandId: string): Promise<boolean>;
|
|
518
|
+
private loadManifest;
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Create a dynamic command discovery for KB Labs packages
|
|
522
|
+
*/
|
|
523
|
+
declare function createKBLabsCommandDiscovery(): DynamicCommandDiscovery;
|
|
524
|
+
|
|
525
|
+
interface ArtifactInfo {
|
|
526
|
+
name: string;
|
|
527
|
+
path: string;
|
|
528
|
+
size?: number;
|
|
529
|
+
modified?: Date;
|
|
530
|
+
description: string;
|
|
531
|
+
}
|
|
532
|
+
interface ArtifactDisplayOptions {
|
|
533
|
+
showSize?: boolean;
|
|
534
|
+
showTime?: boolean;
|
|
535
|
+
showDescription?: boolean;
|
|
536
|
+
maxItems?: number;
|
|
537
|
+
title?: string;
|
|
538
|
+
groupBy?: 'none' | 'type' | 'time';
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Display artifacts information in CLI
|
|
542
|
+
*/
|
|
543
|
+
declare function displayArtifacts(artifacts: ArtifactInfo[], options?: ArtifactDisplayOptions): string[];
|
|
544
|
+
/**
|
|
545
|
+
* Display a single artifact with full details
|
|
546
|
+
*/
|
|
547
|
+
declare function displaySingleArtifact(artifact: ArtifactInfo, title?: string): string[];
|
|
548
|
+
/**
|
|
549
|
+
* Display artifacts in a compact format (for status-like displays)
|
|
550
|
+
*/
|
|
551
|
+
declare function displayArtifactsCompact(artifacts: ArtifactInfo[], options?: {
|
|
552
|
+
maxItems?: number;
|
|
553
|
+
showSize?: boolean;
|
|
554
|
+
sortByTime?: boolean;
|
|
555
|
+
showTime?: boolean;
|
|
556
|
+
title?: string;
|
|
557
|
+
}): string[];
|
|
558
|
+
/**
|
|
559
|
+
* Discover artifacts in a directory based on patterns
|
|
560
|
+
*
|
|
561
|
+
* @param baseDir - Base directory to search for artifacts
|
|
562
|
+
* @param patterns - Array of artifact patterns to search for
|
|
563
|
+
* @returns Array of discovered artifacts
|
|
564
|
+
*
|
|
565
|
+
* @example
|
|
566
|
+
* ```typescript
|
|
567
|
+
* const artifacts = await discoverArtifacts('.kb/mind', [
|
|
568
|
+
* { name: 'Index', pattern: 'index.json', description: 'Main index' },
|
|
569
|
+
* { name: 'API Index', pattern: 'api-index.json', description: 'API index' },
|
|
570
|
+
* ]);
|
|
571
|
+
* ```
|
|
572
|
+
*/
|
|
573
|
+
declare function discoverArtifacts(baseDir: string, patterns: Array<{
|
|
574
|
+
name: string;
|
|
575
|
+
pattern: string;
|
|
576
|
+
description?: string;
|
|
577
|
+
}>): Promise<ArtifactInfo[]>;
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* Table formatting utilities for CLI output
|
|
581
|
+
* Handles proper column alignment accounting for emoji/unicode width
|
|
582
|
+
*/
|
|
583
|
+
interface TableColumn {
|
|
584
|
+
header: string;
|
|
585
|
+
width?: number;
|
|
586
|
+
align?: 'left' | 'right' | 'center';
|
|
587
|
+
}
|
|
588
|
+
interface TableOptions {
|
|
589
|
+
header?: boolean;
|
|
590
|
+
separator?: string;
|
|
591
|
+
padding?: number;
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Format data as a table with proper column alignment
|
|
595
|
+
*/
|
|
596
|
+
declare function formatTable(columns: TableColumn[], rows: string[][], options?: TableOptions): string[];
|
|
597
|
+
/**
|
|
598
|
+
* Format simple key-value pairs as a table
|
|
599
|
+
*/
|
|
600
|
+
declare function formatKeyValueTable(data: Record<string, string | number>, options?: {
|
|
601
|
+
keyWidth?: number;
|
|
602
|
+
valueWidth?: number;
|
|
603
|
+
}): string[];
|
|
604
|
+
|
|
605
|
+
interface CommandPresenter {
|
|
606
|
+
info(message: string): void;
|
|
607
|
+
warn?(message: string): void;
|
|
608
|
+
error(message: string): void;
|
|
609
|
+
write(payload: string): void;
|
|
610
|
+
json(payload: unknown): void;
|
|
611
|
+
}
|
|
612
|
+
interface CommandContext {
|
|
613
|
+
cwd: string;
|
|
614
|
+
presenter: CommandPresenter;
|
|
615
|
+
}
|
|
616
|
+
interface CommandExecutionResult {
|
|
617
|
+
summary: Record<string, string | number>;
|
|
618
|
+
artifacts?: ArtifactInfo[];
|
|
619
|
+
artifactsOptions?: ArtifactDisplayOptions;
|
|
620
|
+
timing?: number | Record<string, number>;
|
|
621
|
+
diagnostics?: string[];
|
|
622
|
+
warnings?: string[];
|
|
623
|
+
errors?: string[];
|
|
624
|
+
data?: Record<string, unknown>;
|
|
625
|
+
}
|
|
626
|
+
interface AnalyticsConfig {
|
|
627
|
+
actor: string;
|
|
628
|
+
started: string;
|
|
629
|
+
finished: string;
|
|
630
|
+
getPayload?: (flags: Record<string, unknown>, result?: CommandExecutionResult) => Record<string, unknown>;
|
|
631
|
+
}
|
|
632
|
+
interface CommandRunnerOptions {
|
|
633
|
+
title: string;
|
|
634
|
+
analytics?: AnalyticsConfig;
|
|
635
|
+
execute: (ctx: CommandContext, flags: Record<string, unknown>, tracker: TimingTracker) => Promise<CommandExecutionResult>;
|
|
636
|
+
}
|
|
637
|
+
declare function createCommandRunner(options: CommandRunnerOptions): (ctx: CommandContext, argv: string[], flags: Record<string, unknown>) => Promise<number>;
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* Flag system for declarative CLI flag definition with type safety
|
|
641
|
+
*
|
|
642
|
+
* Usage:
|
|
643
|
+
* ```typescript
|
|
644
|
+
* // In contracts
|
|
645
|
+
* export const myFlags = defineFlags({
|
|
646
|
+
* scope: { type: 'string', description: 'Filter by scope' },
|
|
647
|
+
* verbose: { type: 'boolean', default: false },
|
|
648
|
+
* });
|
|
649
|
+
*
|
|
650
|
+
* // In command
|
|
651
|
+
* export default defineCommand({
|
|
652
|
+
* flags: myFlags,
|
|
653
|
+
* handler: {
|
|
654
|
+
* async execute(ctx, input: typeof myFlags.type) {
|
|
655
|
+
* const { scope, verbose } = input;
|
|
656
|
+
* }
|
|
657
|
+
* }
|
|
658
|
+
* });
|
|
659
|
+
* ```
|
|
660
|
+
*/
|
|
661
|
+
type FlagType = 'string' | 'boolean' | 'number';
|
|
662
|
+
interface BaseFlagSpec<T extends FlagType> {
|
|
663
|
+
type: T;
|
|
664
|
+
description?: string;
|
|
665
|
+
examples?: string[];
|
|
666
|
+
deprecated?: boolean | string;
|
|
667
|
+
}
|
|
668
|
+
interface StringFlagSpec extends BaseFlagSpec<'string'> {
|
|
669
|
+
default?: string;
|
|
670
|
+
validate?: (value: string) => void | Promise<void>;
|
|
671
|
+
}
|
|
672
|
+
interface BooleanFlagSpec extends BaseFlagSpec<'boolean'> {
|
|
673
|
+
default?: boolean;
|
|
674
|
+
}
|
|
675
|
+
interface NumberFlagSpec extends BaseFlagSpec<'number'> {
|
|
676
|
+
default?: number;
|
|
677
|
+
validate?: (value: number) => void | Promise<void>;
|
|
678
|
+
}
|
|
679
|
+
type FlagSpec = StringFlagSpec | BooleanFlagSpec | NumberFlagSpec;
|
|
680
|
+
type FlagsSchema = Record<string, FlagSpec>;
|
|
681
|
+
type InferFlagType<T extends FlagSpec> = T extends StringFlagSpec ? T extends {
|
|
682
|
+
default: string;
|
|
683
|
+
} ? string : string | undefined : T extends BooleanFlagSpec ? T extends {
|
|
684
|
+
default: boolean;
|
|
685
|
+
} ? boolean : boolean | undefined : T extends NumberFlagSpec ? T extends {
|
|
686
|
+
default: number;
|
|
687
|
+
} ? number : number | undefined : never;
|
|
688
|
+
type InferFlagsType<T extends FlagsSchema> = {
|
|
689
|
+
[K in keyof T]: InferFlagType<T[K]>;
|
|
690
|
+
};
|
|
691
|
+
interface FlagsDefinition<T extends FlagsSchema> {
|
|
692
|
+
/** Schema for manifest */
|
|
693
|
+
schema: T;
|
|
694
|
+
/** Inferred TypeScript type */
|
|
695
|
+
type: InferFlagsType<T>;
|
|
696
|
+
/** Parse and validate flags from raw input */
|
|
697
|
+
parse: (input: unknown) => InferFlagsType<T>;
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* Define CLI flags with type safety and validation
|
|
701
|
+
*
|
|
702
|
+
* @example
|
|
703
|
+
* ```typescript
|
|
704
|
+
* export const commitFlags = defineFlags({
|
|
705
|
+
* scope: {
|
|
706
|
+
* type: 'string',
|
|
707
|
+
* description: 'Limit to package or path',
|
|
708
|
+
* examples: ['@kb-labs/core', 'packages/**'],
|
|
709
|
+
* },
|
|
710
|
+
* 'dry-run': {
|
|
711
|
+
* type: 'boolean',
|
|
712
|
+
* description: 'Preview without applying',
|
|
713
|
+
* default: false,
|
|
714
|
+
* },
|
|
715
|
+
* });
|
|
716
|
+
*
|
|
717
|
+
* // Use in command
|
|
718
|
+
* type MyInput = typeof commitFlags.type;
|
|
719
|
+
* // Result: { scope?: string; 'dry-run': boolean }
|
|
720
|
+
* ```
|
|
721
|
+
*/
|
|
722
|
+
declare function defineFlags<T extends FlagsSchema>(schema: T): FlagsDefinition<T>;
|
|
723
|
+
/**
|
|
724
|
+
* Parse flags from raw input with type validation and defaults
|
|
725
|
+
*/
|
|
726
|
+
declare function parseFlagsFromInput<T extends FlagsSchema>(input: unknown, schema: T): InferFlagsType<T>;
|
|
727
|
+
declare function parseBoolean(value: unknown, flagName: string): boolean;
|
|
728
|
+
declare function parseString(value: unknown, flagName: string): string;
|
|
729
|
+
declare function parseNumber(value: unknown, flagName: string): number;
|
|
730
|
+
declare function parseNumberFlag(value: unknown): number | undefined;
|
|
731
|
+
/**
|
|
732
|
+
* Merge input.flags into input root (V3 compatibility helper)
|
|
733
|
+
*
|
|
734
|
+
* @example
|
|
735
|
+
* ```typescript
|
|
736
|
+
* const raw = { scope: 'old', flags: { scope: 'new', json: true } };
|
|
737
|
+
* const merged = mergeFlags(raw);
|
|
738
|
+
* // Result: { scope: 'new', json: true, flags: {...} }
|
|
739
|
+
* ```
|
|
740
|
+
*/
|
|
741
|
+
declare function mergeFlags<T extends Record<string, unknown>>(input: T): T;
|
|
742
|
+
|
|
743
|
+
/**
|
|
744
|
+
* Environment variable system for declarative env definition with type safety
|
|
745
|
+
*
|
|
746
|
+
* Usage:
|
|
747
|
+
* ```typescript
|
|
748
|
+
* // In contracts
|
|
749
|
+
* export const myEnv = defineEnv({
|
|
750
|
+
* MY_API_KEY: { type: 'string', description: 'API key for service' },
|
|
751
|
+
* MY_ENABLED: { type: 'boolean', default: true },
|
|
752
|
+
* MY_TIMEOUT: { type: 'number', default: 5000 },
|
|
753
|
+
* });
|
|
754
|
+
*
|
|
755
|
+
* // In command
|
|
756
|
+
* export default defineCommand({
|
|
757
|
+
* handler: {
|
|
758
|
+
* async execute(ctx, input) {
|
|
759
|
+
* const env = myEnv.parse(ctx.runtime);
|
|
760
|
+
* console.log(env.MY_API_KEY); // string | undefined
|
|
761
|
+
* console.log(env.MY_ENABLED); // boolean
|
|
762
|
+
* }
|
|
763
|
+
* }
|
|
764
|
+
* });
|
|
765
|
+
* ```
|
|
766
|
+
*/
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* Runtime API interface (minimal for env parsing)
|
|
770
|
+
* Avoids dependency on @kb-labs/plugin-contracts
|
|
771
|
+
*/
|
|
772
|
+
interface RuntimeLike {
|
|
773
|
+
env(key: string): string | undefined;
|
|
774
|
+
}
|
|
775
|
+
/**
|
|
776
|
+
* Environment variable schema (reuses FlagSpec types)
|
|
777
|
+
*/
|
|
778
|
+
type EnvSchema = FlagsSchema;
|
|
779
|
+
/**
|
|
780
|
+
* Environment variable definition with parse method
|
|
781
|
+
*/
|
|
782
|
+
interface EnvDefinition<T extends EnvSchema> {
|
|
783
|
+
/** Schema for documentation and validation */
|
|
784
|
+
schema: T;
|
|
785
|
+
/** Inferred TypeScript type */
|
|
786
|
+
type: InferFlagsType<T>;
|
|
787
|
+
/** Parse environment variables from RuntimeLike */
|
|
788
|
+
parse: (runtime: RuntimeLike) => InferFlagsType<T>;
|
|
789
|
+
}
|
|
790
|
+
/**
|
|
791
|
+
* Define environment variables with type safety and validation
|
|
792
|
+
*
|
|
793
|
+
* @example
|
|
794
|
+
* ```typescript
|
|
795
|
+
* export const commitEnv = defineEnv({
|
|
796
|
+
* KB_COMMIT_LLM_ENABLED: {
|
|
797
|
+
* type: 'boolean',
|
|
798
|
+
* default: true,
|
|
799
|
+
* description: 'Enable LLM analysis',
|
|
800
|
+
* },
|
|
801
|
+
* KB_COMMIT_LLM_TEMPERATURE: {
|
|
802
|
+
* type: 'number',
|
|
803
|
+
* default: 0.3,
|
|
804
|
+
* description: 'LLM temperature (0-1)',
|
|
805
|
+
* validate: (v) => {
|
|
806
|
+
* if (v < 0 || v > 1) throw new Error('Must be 0-1');
|
|
807
|
+
* },
|
|
808
|
+
* },
|
|
809
|
+
* });
|
|
810
|
+
*
|
|
811
|
+
* // Use in command
|
|
812
|
+
* const env = commitEnv.parse(ctx.runtime);
|
|
813
|
+
* // Type: { KB_COMMIT_LLM_ENABLED: boolean; KB_COMMIT_LLM_TEMPERATURE: number }
|
|
814
|
+
* ```
|
|
815
|
+
*/
|
|
816
|
+
declare function defineEnv<T extends EnvSchema>(schema: T): EnvDefinition<T>;
|
|
817
|
+
/**
|
|
818
|
+
* Parse environment variables from RuntimeLike with validation and defaults
|
|
819
|
+
*/
|
|
820
|
+
declare function parseEnvFromRuntime<T extends EnvSchema>(runtime: RuntimeLike, schema: T): InferFlagsType<T>;
|
|
821
|
+
|
|
822
|
+
/**
|
|
823
|
+
* Resolve the current working directory from a CLI context-like object.
|
|
824
|
+
* Falls back to the process cwd when the context does not provide one.
|
|
825
|
+
*/
|
|
826
|
+
declare function getContextCwd(input: {
|
|
827
|
+
cwd?: string;
|
|
828
|
+
} | undefined): string;
|
|
829
|
+
|
|
830
|
+
/**
|
|
831
|
+
* Normalize filesystem paths to POSIX (forward-slash) form.
|
|
832
|
+
*/
|
|
833
|
+
declare function toPosixPath(input: string): string;
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* Modern CLI formatting utilities with side border design
|
|
837
|
+
* Provides minimalist, modern UI components for CLI output
|
|
838
|
+
*/
|
|
839
|
+
|
|
840
|
+
/**
|
|
841
|
+
* Side border box - modern minimalist design
|
|
842
|
+
*
|
|
843
|
+
* @example
|
|
844
|
+
* ```
|
|
845
|
+
* ┌── Command Name
|
|
846
|
+
* │
|
|
847
|
+
* │ Section Header
|
|
848
|
+
* │ Key: value
|
|
849
|
+
* │
|
|
850
|
+
* └── ✓ Success / 12ms
|
|
851
|
+
* ```
|
|
852
|
+
*/
|
|
853
|
+
interface SideBorderBoxOptions {
|
|
854
|
+
title: string;
|
|
855
|
+
sections: SectionContent[];
|
|
856
|
+
footer?: string;
|
|
857
|
+
status?: 'success' | 'error' | 'warning' | 'info';
|
|
858
|
+
timing?: number;
|
|
859
|
+
}
|
|
860
|
+
interface SectionContent {
|
|
861
|
+
header?: string;
|
|
862
|
+
items: string[];
|
|
863
|
+
}
|
|
864
|
+
/**
|
|
865
|
+
* Create a side-bordered box with modern design
|
|
866
|
+
*/
|
|
867
|
+
declare function sideBorderBox(options: SideBorderBoxOptions): string;
|
|
868
|
+
/**
|
|
869
|
+
* Format a section header
|
|
870
|
+
*/
|
|
871
|
+
declare function sectionHeader(text: string): string;
|
|
872
|
+
/**
|
|
873
|
+
* Format metrics list (key: value pairs with aligned values)
|
|
874
|
+
*/
|
|
875
|
+
declare function metricsList(metrics: Record<string, string | number>): string[];
|
|
876
|
+
/**
|
|
877
|
+
* Format status line for footer
|
|
878
|
+
*/
|
|
879
|
+
declare function statusLine(status: 'success' | 'error' | 'warning' | 'info', timing?: number): string;
|
|
880
|
+
/**
|
|
881
|
+
* Format command help in modern side-border style
|
|
882
|
+
*
|
|
883
|
+
* @example
|
|
884
|
+
* ```typescript
|
|
885
|
+
* const help = formatCommandHelp({
|
|
886
|
+
* title: 'kb version',
|
|
887
|
+
* description: 'Show CLI version',
|
|
888
|
+
* longDescription: 'Displays the current version...',
|
|
889
|
+
* examples: ['kb version', 'kb version --json'],
|
|
890
|
+
* flags: [{name: 'json', description: 'Output in JSON'}]
|
|
891
|
+
* });
|
|
892
|
+
* ```
|
|
893
|
+
*/
|
|
894
|
+
declare function formatCommandHelp(options: {
|
|
895
|
+
title: string;
|
|
896
|
+
description?: string;
|
|
897
|
+
longDescription?: string;
|
|
898
|
+
examples?: string[];
|
|
899
|
+
flags?: Array<{
|
|
900
|
+
name: string;
|
|
901
|
+
alias?: string;
|
|
902
|
+
description?: string;
|
|
903
|
+
required?: boolean;
|
|
904
|
+
}>;
|
|
905
|
+
aliases?: string[];
|
|
906
|
+
}): string;
|
|
907
|
+
|
|
908
|
+
/**
|
|
909
|
+
* Command result formatting utilities
|
|
910
|
+
* Provides high and low-level APIs for formatting command output
|
|
911
|
+
*/
|
|
912
|
+
/**
|
|
913
|
+
* Command output with human and machine-readable formats
|
|
914
|
+
* Extends CommandResult contract from command-kit
|
|
915
|
+
*/
|
|
916
|
+
interface CommandOutput {
|
|
917
|
+
/** Whether command executed successfully - required by CommandResult contract */
|
|
918
|
+
ok: boolean;
|
|
919
|
+
/** Execution status */
|
|
920
|
+
status?: 'success' | 'error' | 'warning' | 'info' | 'failed' | 'cancelled' | 'skipped';
|
|
921
|
+
/** Human-readable output (side border format) */
|
|
922
|
+
human: string;
|
|
923
|
+
/** Machine-readable output (JSON) */
|
|
924
|
+
json: object;
|
|
925
|
+
/** Agent-specific output (optional, for --agent flag) */
|
|
926
|
+
agent?: object;
|
|
927
|
+
}
|
|
928
|
+
/**
|
|
929
|
+
* Parameters for formatting command results
|
|
930
|
+
*/
|
|
931
|
+
interface CommandResultParams {
|
|
932
|
+
title: string;
|
|
933
|
+
summary?: Record<string, string | number>;
|
|
934
|
+
details?: Array<{
|
|
935
|
+
section: string;
|
|
936
|
+
items: string[];
|
|
937
|
+
}>;
|
|
938
|
+
warnings?: string[];
|
|
939
|
+
errors?: string[];
|
|
940
|
+
timing?: number;
|
|
941
|
+
status: 'success' | 'error' | 'warning' | 'info';
|
|
942
|
+
/** Custom JSON data (optional) */
|
|
943
|
+
jsonData?: object;
|
|
944
|
+
}
|
|
945
|
+
/**
|
|
946
|
+
* Low-level: Format command result with full control
|
|
947
|
+
*
|
|
948
|
+
* @example
|
|
949
|
+
* ```typescript
|
|
950
|
+
* const output = formatCommandResult({
|
|
951
|
+
* title: 'System Diagnostics',
|
|
952
|
+
* summary: { 'Total Checks': 4, 'OK': 3 },
|
|
953
|
+
* details: [
|
|
954
|
+
* { section: 'Environment', items: ['Node 20.11.0'] }
|
|
955
|
+
* ],
|
|
956
|
+
* warnings: ['Cache is old'],
|
|
957
|
+
* timing: 150,
|
|
958
|
+
* status: 'success',
|
|
959
|
+
* });
|
|
960
|
+
*
|
|
961
|
+
* console.log(output.human); // Pretty CLI output
|
|
962
|
+
* console.log(output.json); // JSON for --json flag
|
|
963
|
+
* ```
|
|
964
|
+
*/
|
|
965
|
+
declare function formatCommandResult(params: CommandResultParams): CommandOutput;
|
|
966
|
+
/**
|
|
967
|
+
* High-level: Quick success result
|
|
968
|
+
*
|
|
969
|
+
* @example
|
|
970
|
+
* ```typescript
|
|
971
|
+
* return successResult('Version Info', {
|
|
972
|
+
* summary: { 'CLI Version': '0.1.0' },
|
|
973
|
+
* timing: 5,
|
|
974
|
+
* });
|
|
975
|
+
* ```
|
|
976
|
+
*/
|
|
977
|
+
declare function successResult(title: string, data?: {
|
|
978
|
+
summary?: Record<string, string | number>;
|
|
979
|
+
details?: Array<{
|
|
980
|
+
section: string;
|
|
981
|
+
items: string[];
|
|
982
|
+
}>;
|
|
983
|
+
timing?: number;
|
|
984
|
+
json?: object;
|
|
985
|
+
}): CommandOutput;
|
|
986
|
+
/**
|
|
987
|
+
* High-level: Quick error result
|
|
988
|
+
*
|
|
989
|
+
* @example
|
|
990
|
+
* ```typescript
|
|
991
|
+
* return errorResult('Command Failed', new Error('Something went wrong'), {
|
|
992
|
+
* timing: 100,
|
|
993
|
+
* suggestions: ['Try running with --debug flag'],
|
|
994
|
+
* });
|
|
995
|
+
* ```
|
|
996
|
+
*/
|
|
997
|
+
declare function errorResult(title: string, error: Error | string, options?: {
|
|
998
|
+
timing?: number;
|
|
999
|
+
suggestions?: string[];
|
|
1000
|
+
}): CommandOutput;
|
|
1001
|
+
/**
|
|
1002
|
+
* High-level: Quick warning result
|
|
1003
|
+
*
|
|
1004
|
+
* @example
|
|
1005
|
+
* ```typescript
|
|
1006
|
+
* return warningResult('Configuration Updated', ['Deprecated option used'], {
|
|
1007
|
+
* summary: { 'Files Updated': 3 },
|
|
1008
|
+
* timing: 50,
|
|
1009
|
+
* });
|
|
1010
|
+
* ```
|
|
1011
|
+
*/
|
|
1012
|
+
declare function warningResult(title: string, warnings: string[], options?: {
|
|
1013
|
+
summary?: Record<string, string | number>;
|
|
1014
|
+
timing?: number;
|
|
1015
|
+
}): CommandOutput;
|
|
1016
|
+
/**
|
|
1017
|
+
* High-level: Info result
|
|
1018
|
+
*
|
|
1019
|
+
* @example
|
|
1020
|
+
* ```typescript
|
|
1021
|
+
* return infoResult('Help Information', {
|
|
1022
|
+
* details: [
|
|
1023
|
+
* { section: 'Usage', items: ['kb command --flag'] }
|
|
1024
|
+
* ],
|
|
1025
|
+
* });
|
|
1026
|
+
* ```
|
|
1027
|
+
*/
|
|
1028
|
+
declare function infoResult(title: string, data?: {
|
|
1029
|
+
summary?: Record<string, string | number>;
|
|
1030
|
+
details?: Array<{
|
|
1031
|
+
section: string;
|
|
1032
|
+
items: string[];
|
|
1033
|
+
}>;
|
|
1034
|
+
timing?: number;
|
|
1035
|
+
}): CommandOutput;
|
|
1036
|
+
|
|
1037
|
+
export { type AnalyticsConfig, type ArtifactDisplayOptions, type ArtifactInfo, type BaseFlagSpec, type BooleanFlagSpec, type CLIPackage, type CommandContext, type CommandDiscovery, type CommandExecutionResult, type CommandInfo, type CommandManifest, type CommandOutput, type CommandPresenter, type CommandRegistry, type CommandResult, type CommandResultParams, type CommandRunnerOptions, type CommandSuggestion, DynamicCommandDiscovery, type EnvDefinition, type EnvSchema, type FlagDefinition, type FlagSpec, type FlagType, type FlagsDefinition, type FlagsSchema, type FormatTimestampOptions, type InferFlagsType, type KeyValueOptions, Loader, type LoaderOptions, type ManifestLoader, type MultiCLIContext, MultiCLISuggestions, type NumberFlagSpec, type RuntimeLike, type SafeKeyValueOptions, type SectionContent, type SideBorderBoxOptions, StaticCommandDiscovery, type StringFlagSpec, type TableColumn, type TableOptions, TimingTracker, accentLabel, box, bulletList, colors, createCommandDiscovery, createCommandRegistry, createCommandRunner, createDetailedResult, createKBLabsCommandDiscovery, createProgressBar, createSimpleResult, createSpinner, defineEnv, defineFlags, discoverArtifacts, displayArtifacts, displayArtifactsCompact, displaySingleArtifact, errorResult, extractCommandGroups, extractCommandIds, findCommandById, findCommandsByGroup, formatCommandHelp, formatCommandOutput, formatCommandResult, formatKeyValueTable, formatRelativeTime, formatSize, formatTable, formatTimestamp, formatTiming, formatTimingBreakdown, generateDevlinkSuggestions, generateGroupSuggestions, generateQuickActions, getCommandInfo, getContextCwd, hasAnsi, headline, indent, infoResult, isCommandAvailable, keyValue, mergeFlags, metricsList, muted, pad, parseBoolean, parseEnvFromRuntime, parseFlagsFromInput, parseNumber, parseNumberFlag, parseString, safeColors, safeKeyValue, safeSymbols, section, sectionHeader, showError, showLoading, showSuccess, sideBorderBox, statusLine, stripAnsi, successResult, supportsColor, symbols, table, toPosixPath, truncate, useLoader, validateSuggestions, warningResult };
|