feat: subagent runtime & CLI display - done

This commit is contained in:
tanzhenxin
2025-09-09 15:53:10 +08:00
parent 4985bfc000
commit 35e996d46c
23 changed files with 767 additions and 684 deletions

View File

@@ -1,7 +1,7 @@
import { COLOR_OPTIONS } from './constants.js';
export const shouldShowColor = (backgroundColor?: string): boolean =>
backgroundColor !== undefined && backgroundColor !== 'auto';
export const shouldShowColor = (color?: string): boolean =>
color !== undefined && color !== 'auto';
export const getColorForDisplay = (colorName?: string): string | undefined =>
!colorName || colorName === 'auto'
@@ -20,3 +20,16 @@ export function sanitizeInput(input: string): string {
.replace(/\s+/g, ' ') // Normalize whitespace
); // Limit length
}
export function fmtDuration(ms: number): string {
if (ms < 1000) return `${Math.round(ms)}ms`;
if (ms < 60000) return `${(ms / 1000).toFixed(1)}s`;
if (ms < 3600000) {
const m = Math.floor(ms / 60000);
const s = Math.floor((ms % 60000) / 1000);
return `${m}m ${s}s`;
}
const h = Math.floor(ms / 3600000);
const m = Math.floor((ms % 3600000) / 60000);
return `${h}h ${m}m`;
}