@kb-labs/shared-cli-ui 2.46.0 → 2.53.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/dist/index.cjs +62 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -2
- package/dist/index.d.ts +21 -2
- package/dist/index.js +62 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -859,9 +859,18 @@ interface SideBorderBoxOptions {
|
|
|
859
859
|
status?: 'success' | 'error' | 'warning' | 'info';
|
|
860
860
|
timing?: number;
|
|
861
861
|
}
|
|
862
|
+
interface RichSectionItem {
|
|
863
|
+
text: string;
|
|
864
|
+
/** Render text in muted/dim color */
|
|
865
|
+
dim?: boolean;
|
|
866
|
+
/** Hard-truncate to N visible chars instead of wrapping */
|
|
867
|
+
truncate?: number;
|
|
868
|
+
}
|
|
869
|
+
/** A section item — either a plain string or a rich descriptor */
|
|
870
|
+
type SectionItem = string | RichSectionItem;
|
|
862
871
|
interface SectionContent {
|
|
863
872
|
header?: string;
|
|
864
|
-
items:
|
|
873
|
+
items: SectionItem[];
|
|
865
874
|
}
|
|
866
875
|
/**
|
|
867
876
|
* Create a side-bordered box with modern design
|
|
@@ -879,6 +888,16 @@ declare function metricsList(metrics: Record<string, string | number>): string[]
|
|
|
879
888
|
* Format status line for footer
|
|
880
889
|
*/
|
|
881
890
|
declare function statusLine(status: 'success' | 'error' | 'warning' | 'info', timing?: number): string;
|
|
891
|
+
/**
|
|
892
|
+
* Convert an Error or raw string into clean display lines for sideBorderBox items.
|
|
893
|
+
* Splits on newlines, removes blank lines, and caps at maxLines with a "… N more" hint.
|
|
894
|
+
*
|
|
895
|
+
* @example
|
|
896
|
+
* items: formatError(err, { maxLines: 6 })
|
|
897
|
+
*/
|
|
898
|
+
declare function formatError(err: Error | string, opts?: {
|
|
899
|
+
maxLines?: number;
|
|
900
|
+
}): string[];
|
|
882
901
|
/**
|
|
883
902
|
* Format command help in modern side-border style
|
|
884
903
|
*
|
|
@@ -1036,4 +1055,4 @@ declare function infoResult(title: string, data?: {
|
|
|
1036
1055
|
timing?: number;
|
|
1037
1056
|
}): CommandOutput;
|
|
1038
1057
|
|
|
1039
|
-
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, isJsonMode, keyValue, mergeFlags, metricsList, muted, pad, parseBoolean, parseEnvFromRuntime, parseFlagsFromInput, parseNumber, parseNumberFlag, parseString, safeColors, safeKeyValue, safeSymbols, section, sectionHeader, setJsonMode, showError, showLoading, showSuccess, sideBorderBox, statusLine, stripAnsi, successResult, supportsColor, symbols, table, toPosixPath, truncate, useLoader, validateSuggestions, warningResult };
|
|
1058
|
+
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 RichSectionItem, type RuntimeLike, type SafeKeyValueOptions, type SectionContent, type SectionItem, 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, formatError, formatKeyValueTable, formatRelativeTime, formatSize, formatTable, formatTimestamp, formatTiming, formatTimingBreakdown, generateDevlinkSuggestions, generateGroupSuggestions, generateQuickActions, getCommandInfo, getContextCwd, hasAnsi, headline, indent, infoResult, isCommandAvailable, isJsonMode, keyValue, mergeFlags, metricsList, muted, pad, parseBoolean, parseEnvFromRuntime, parseFlagsFromInput, parseNumber, parseNumberFlag, parseString, safeColors, safeKeyValue, safeSymbols, section, sectionHeader, setJsonMode, showError, showLoading, showSuccess, sideBorderBox, statusLine, stripAnsi, successResult, supportsColor, symbols, table, toPosixPath, truncate, useLoader, validateSuggestions, warningResult };
|
package/dist/index.d.ts
CHANGED
|
@@ -859,9 +859,18 @@ interface SideBorderBoxOptions {
|
|
|
859
859
|
status?: 'success' | 'error' | 'warning' | 'info';
|
|
860
860
|
timing?: number;
|
|
861
861
|
}
|
|
862
|
+
interface RichSectionItem {
|
|
863
|
+
text: string;
|
|
864
|
+
/** Render text in muted/dim color */
|
|
865
|
+
dim?: boolean;
|
|
866
|
+
/** Hard-truncate to N visible chars instead of wrapping */
|
|
867
|
+
truncate?: number;
|
|
868
|
+
}
|
|
869
|
+
/** A section item — either a plain string or a rich descriptor */
|
|
870
|
+
type SectionItem = string | RichSectionItem;
|
|
862
871
|
interface SectionContent {
|
|
863
872
|
header?: string;
|
|
864
|
-
items:
|
|
873
|
+
items: SectionItem[];
|
|
865
874
|
}
|
|
866
875
|
/**
|
|
867
876
|
* Create a side-bordered box with modern design
|
|
@@ -879,6 +888,16 @@ declare function metricsList(metrics: Record<string, string | number>): string[]
|
|
|
879
888
|
* Format status line for footer
|
|
880
889
|
*/
|
|
881
890
|
declare function statusLine(status: 'success' | 'error' | 'warning' | 'info', timing?: number): string;
|
|
891
|
+
/**
|
|
892
|
+
* Convert an Error or raw string into clean display lines for sideBorderBox items.
|
|
893
|
+
* Splits on newlines, removes blank lines, and caps at maxLines with a "… N more" hint.
|
|
894
|
+
*
|
|
895
|
+
* @example
|
|
896
|
+
* items: formatError(err, { maxLines: 6 })
|
|
897
|
+
*/
|
|
898
|
+
declare function formatError(err: Error | string, opts?: {
|
|
899
|
+
maxLines?: number;
|
|
900
|
+
}): string[];
|
|
882
901
|
/**
|
|
883
902
|
* Format command help in modern side-border style
|
|
884
903
|
*
|
|
@@ -1036,4 +1055,4 @@ declare function infoResult(title: string, data?: {
|
|
|
1036
1055
|
timing?: number;
|
|
1037
1056
|
}): CommandOutput;
|
|
1038
1057
|
|
|
1039
|
-
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, isJsonMode, keyValue, mergeFlags, metricsList, muted, pad, parseBoolean, parseEnvFromRuntime, parseFlagsFromInput, parseNumber, parseNumberFlag, parseString, safeColors, safeKeyValue, safeSymbols, section, sectionHeader, setJsonMode, showError, showLoading, showSuccess, sideBorderBox, statusLine, stripAnsi, successResult, supportsColor, symbols, table, toPosixPath, truncate, useLoader, validateSuggestions, warningResult };
|
|
1058
|
+
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 RichSectionItem, type RuntimeLike, type SafeKeyValueOptions, type SectionContent, type SectionItem, 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, formatError, formatKeyValueTable, formatRelativeTime, formatSize, formatTable, formatTimestamp, formatTiming, formatTimingBreakdown, generateDevlinkSuggestions, generateGroupSuggestions, generateQuickActions, getCommandInfo, getContextCwd, hasAnsi, headline, indent, infoResult, isCommandAvailable, isJsonMode, keyValue, mergeFlags, metricsList, muted, pad, parseBoolean, parseEnvFromRuntime, parseFlagsFromInput, parseNumber, parseNumberFlag, parseString, safeColors, safeKeyValue, safeSymbols, section, sectionHeader, setJsonMode, showError, showLoading, showSuccess, sideBorderBox, statusLine, stripAnsi, successResult, supportsColor, symbols, table, toPosixPath, truncate, useLoader, validateSuggestions, warningResult };
|
package/dist/index.js
CHANGED
|
@@ -2263,6 +2263,8 @@ function toPosixPath(input) {
|
|
|
2263
2263
|
function sideBorderBox(options) {
|
|
2264
2264
|
const { title, sections, footer, status, timing } = options;
|
|
2265
2265
|
const lines = [];
|
|
2266
|
+
const terminalWidth = typeof process !== "undefined" && process.stdout?.columns ? process.stdout.columns : 80;
|
|
2267
|
+
const itemMaxWidth = Math.max(40, terminalWidth - 4);
|
|
2266
2268
|
const titleLine = `${safeSymbols.topLeft}${safeSymbols.separator.repeat(2)} ${safeColors.primary(safeColors.bold(title))}`;
|
|
2267
2269
|
lines.push(titleLine);
|
|
2268
2270
|
lines.push(safeSymbols.border);
|
|
@@ -2274,8 +2276,20 @@ function sideBorderBox(options) {
|
|
|
2274
2276
|
if (section2.header) {
|
|
2275
2277
|
lines.push(`${safeSymbols.border} ${safeColors.bold(section2.header)}`);
|
|
2276
2278
|
}
|
|
2277
|
-
for (const
|
|
2278
|
-
|
|
2279
|
+
for (const rawItem of section2.items) {
|
|
2280
|
+
const item = typeof rawItem === "string" ? { text: rawItem } : rawItem;
|
|
2281
|
+
let displayLines;
|
|
2282
|
+
if (item.truncate !== void 0) {
|
|
2283
|
+
const vis = stripAnsi(item.text);
|
|
2284
|
+
const truncated = vis.length > item.truncate ? vis.slice(0, item.truncate - 1) + "\u2026" : vis;
|
|
2285
|
+
displayLines = [item.dim ? safeColors.muted(truncated) : truncated];
|
|
2286
|
+
} else {
|
|
2287
|
+
const wrapped = wrapText(item.text, itemMaxWidth);
|
|
2288
|
+
displayLines = item.dim ? wrapped.map((l) => safeColors.muted(l)) : wrapped;
|
|
2289
|
+
}
|
|
2290
|
+
for (const dl of displayLines) {
|
|
2291
|
+
lines.push(`${safeSymbols.border} ${dl}`);
|
|
2292
|
+
}
|
|
2279
2293
|
}
|
|
2280
2294
|
if (i < sections.length - 1) {
|
|
2281
2295
|
lines.push(safeSymbols.border);
|
|
@@ -2367,6 +2381,51 @@ function getStatusColor(status) {
|
|
|
2367
2381
|
return safeColors.info;
|
|
2368
2382
|
}
|
|
2369
2383
|
}
|
|
2384
|
+
function wrapText(text, maxWidth) {
|
|
2385
|
+
const result = [];
|
|
2386
|
+
const rawLines = text.split("\n");
|
|
2387
|
+
for (const rawLine of rawLines) {
|
|
2388
|
+
const line = rawLine.trimEnd();
|
|
2389
|
+
if (stripAnsi(line).length <= maxWidth) {
|
|
2390
|
+
result.push(line);
|
|
2391
|
+
continue;
|
|
2392
|
+
}
|
|
2393
|
+
const words = line.split(/(\s+)/);
|
|
2394
|
+
let current = "";
|
|
2395
|
+
for (const word of words) {
|
|
2396
|
+
const test = current + word;
|
|
2397
|
+
if (stripAnsi(test).length <= maxWidth) {
|
|
2398
|
+
current = test;
|
|
2399
|
+
} else {
|
|
2400
|
+
if (current.trimEnd()) {
|
|
2401
|
+
result.push(current.trimEnd());
|
|
2402
|
+
}
|
|
2403
|
+
const wordLen = stripAnsi(word).length;
|
|
2404
|
+
if (wordLen > maxWidth) {
|
|
2405
|
+
result.push(stripAnsi(word).slice(0, maxWidth - 1) + "\u2026");
|
|
2406
|
+
current = "";
|
|
2407
|
+
} else {
|
|
2408
|
+
current = word;
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2411
|
+
}
|
|
2412
|
+
if (current.trimEnd()) {
|
|
2413
|
+
result.push(current.trimEnd());
|
|
2414
|
+
}
|
|
2415
|
+
}
|
|
2416
|
+
return result.length > 0 ? result : [""];
|
|
2417
|
+
}
|
|
2418
|
+
function formatError(err, opts) {
|
|
2419
|
+
const raw = err instanceof Error ? err.message : String(err);
|
|
2420
|
+
const allLines = raw.split("\n").map((l) => l.trimEnd()).filter((l) => l.length > 0);
|
|
2421
|
+
const max = opts?.maxLines ?? 8;
|
|
2422
|
+
if (allLines.length <= max) {
|
|
2423
|
+
return allLines;
|
|
2424
|
+
}
|
|
2425
|
+
const shown = allLines.slice(0, max - 1);
|
|
2426
|
+
shown.push(safeColors.muted(`\u2026 ${allLines.length - max + 1} more lines`));
|
|
2427
|
+
return shown;
|
|
2428
|
+
}
|
|
2370
2429
|
function formatCommandHelp(options) {
|
|
2371
2430
|
const { title, description, longDescription, examples, flags, aliases } = options;
|
|
2372
2431
|
const sections = [];
|
|
@@ -2522,6 +2581,6 @@ function infoResult(title, data) {
|
|
|
2522
2581
|
});
|
|
2523
2582
|
}
|
|
2524
2583
|
|
|
2525
|
-
export { DebugOutput, DebugSection, DebugTrace, DebugTree, DynamicCommandDiscovery, Loader, MultiCLISuggestions, StaticCommandDiscovery, TimingTracker, accentLabel, box, bulletList, colors, createCommandDiscovery, createCommandRegistry, createCommandRunner, createDebugTree, createDetailedResult, createKBLabsCommandDiscovery, createProgressBar, createSimpleResult, createSpinner, defineEnv, defineFlags, describeEntriesAI, describeEntriesHuman, describeEntriesTimeline, discoverArtifacts, displayArtifacts, displayArtifactsCompact, displaySingleArtifact, errorResult, exportDebugEntries, exportToChromeFormat, exportToJSON, exportToPlainText, extractCommandGroups, extractCommandIds, filterByLevel, filterByNamespace, filterByTimeRange, filterDebugEntries, findCommandById, findCommandsByGroup, formatCommandHelp, formatCommandOutput, formatCommandResult, formatDebugEntriesAI, formatDebugEntriesHuman, formatDebugEntryAI, formatDebugEntryHuman, formatDebugOutput, formatDebugOutputs, formatKeyValueTable, formatRelativeTime, formatSize, formatTable, formatTimeline, formatTimelineNode, formatTimelineWithSummary, formatTimestamp, formatTiming, formatTimingBreakdown, generateDevlinkSuggestions, generateGroupSuggestions, generateQuickActions, getCommandInfo, getContextCwd, groupByGroup, groupByNamespace, hasAnsi, headline, indent, infoResult, isCommandAvailable, isJsonMode, keyValue, mergeFlags, metricsList, muted, pad, parseBoolean, parseEnvFromRuntime, parseFlagsFromInput, parseNumber, parseNumberFlag, parseString, safeColors, safeKeyValue, safeSymbols, searchInLogs, section, sectionHeader, setJsonMode, shouldUseAIFormat, showError, showLoading, showSuccess, sideBorderBox, statusLine, stripAnsi, successResult, supportsColor, symbols, table, toPosixPath, truncate, useLoader, validateSuggestions, warningResult };
|
|
2584
|
+
export { DebugOutput, DebugSection, DebugTrace, DebugTree, DynamicCommandDiscovery, Loader, MultiCLISuggestions, StaticCommandDiscovery, TimingTracker, accentLabel, box, bulletList, colors, createCommandDiscovery, createCommandRegistry, createCommandRunner, createDebugTree, createDetailedResult, createKBLabsCommandDiscovery, createProgressBar, createSimpleResult, createSpinner, defineEnv, defineFlags, describeEntriesAI, describeEntriesHuman, describeEntriesTimeline, discoverArtifacts, displayArtifacts, displayArtifactsCompact, displaySingleArtifact, errorResult, exportDebugEntries, exportToChromeFormat, exportToJSON, exportToPlainText, extractCommandGroups, extractCommandIds, filterByLevel, filterByNamespace, filterByTimeRange, filterDebugEntries, findCommandById, findCommandsByGroup, formatCommandHelp, formatCommandOutput, formatCommandResult, formatDebugEntriesAI, formatDebugEntriesHuman, formatDebugEntryAI, formatDebugEntryHuman, formatDebugOutput, formatDebugOutputs, formatError, formatKeyValueTable, formatRelativeTime, formatSize, formatTable, formatTimeline, formatTimelineNode, formatTimelineWithSummary, formatTimestamp, formatTiming, formatTimingBreakdown, generateDevlinkSuggestions, generateGroupSuggestions, generateQuickActions, getCommandInfo, getContextCwd, groupByGroup, groupByNamespace, hasAnsi, headline, indent, infoResult, isCommandAvailable, isJsonMode, keyValue, mergeFlags, metricsList, muted, pad, parseBoolean, parseEnvFromRuntime, parseFlagsFromInput, parseNumber, parseNumberFlag, parseString, safeColors, safeKeyValue, safeSymbols, searchInLogs, section, sectionHeader, setJsonMode, shouldUseAIFormat, showError, showLoading, showSuccess, sideBorderBox, statusLine, stripAnsi, successResult, supportsColor, symbols, table, toPosixPath, truncate, useLoader, validateSuggestions, warningResult };
|
|
2526
2585
|
//# sourceMappingURL=index.js.map
|
|
2527
2586
|
//# sourceMappingURL=index.js.map
|