feat: 引入智能内容格式化器以优化 CLI 输出的格式化处理

This commit is contained in:
catlog22
2026-01-11 20:57:32 +08:00
parent e1eafede65
commit 7387a25d65
6 changed files with 351 additions and 18 deletions

View File

@@ -6,6 +6,7 @@ import { readFileSync, existsSync, readdirSync, statSync, unlinkSync, promises a
import { join } from 'path';
import { homedir } from 'os';
import { executeCliTool } from '../../tools/cli-executor.js';
import { SmartContentFormatter } from '../../tools/cli-output-converter.js';
import { validatePath as validateAllowedPath } from '../../utils/path-validator.js';
import type { RouteContext } from './types.js';
@@ -580,8 +581,8 @@ Create a new Claude Code skill with the following specifications:
// Create onOutput callback for real-time streaming
const onOutput = broadcastToClients
? (unit: import('../../tools/cli-output-converter.js').CliOutputUnit) => {
// CliOutputUnit handler: convert to string content for broadcast
const content = typeof unit.content === 'string' ? unit.content : JSON.stringify(unit.content);
// CliOutputUnit handler: use SmartContentFormatter for intelligent formatting
const content = SmartContentFormatter.format(unit.content, unit.type) || JSON.stringify(unit.content);
broadcastToClients({
type: 'CLI_OUTPUT',
payload: {