mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-10 02:24:35 +08:00
feat: 引入智能内容格式化器以优化 CLI 输出的格式化处理
This commit is contained in:
@@ -556,8 +556,9 @@ export async function handleClaudeRoutes(ctx: RouteContext): Promise<boolean> {
|
||||
}
|
||||
|
||||
try {
|
||||
// Import CLI executor
|
||||
// Import CLI executor and content formatter
|
||||
const { executeCliTool } = await import('../../tools/cli-executor.js');
|
||||
const { SmartContentFormatter } = await import('../../tools/cli-output-converter.js');
|
||||
|
||||
// Determine file path based on level
|
||||
let filePath: string;
|
||||
@@ -628,8 +629,8 @@ export async function handleClaudeRoutes(ctx: RouteContext): Promise<boolean> {
|
||||
category: 'internal',
|
||||
id: syncId
|
||||
}, (unit) => {
|
||||
// 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: {
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
getEnrichedConversation,
|
||||
getHistoryWithNativeInfo
|
||||
} from '../../tools/cli-executor.js';
|
||||
import { SmartContentFormatter } from '../../tools/cli-output-converter.js';
|
||||
import { generateSmartContext, formatSmartContext } from '../../tools/smart-context.js';
|
||||
import {
|
||||
loadCliConfig,
|
||||
@@ -564,8 +565,8 @@ export async function handleCliRoutes(ctx: RouteContext): Promise<boolean> {
|
||||
parentExecutionId,
|
||||
stream: true
|
||||
}, (unit) => {
|
||||
// CliOutputUnit handler: convert to string content
|
||||
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);
|
||||
|
||||
// Append to active execution buffer
|
||||
const activeExec = activeExecutions.get(executionId);
|
||||
|
||||
@@ -5,6 +5,7 @@ import { join, isAbsolute, extname } from 'path';
|
||||
import { homedir } from 'os';
|
||||
import { getMemoryStore } from '../memory-store.js';
|
||||
import { executeCliTool } from '../../tools/cli-executor.js';
|
||||
import { SmartContentFormatter } from '../../tools/cli-output-converter.js';
|
||||
|
||||
/**
|
||||
* Route context interface
|
||||
@@ -1008,8 +1009,8 @@ RULES: Be concise. Focus on practical understanding. Include function signatures
|
||||
category: 'internal',
|
||||
id: syncId
|
||||
}, (unit) => {
|
||||
// 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: {
|
||||
|
||||
@@ -6,6 +6,7 @@ import { readFileSync, existsSync, readdirSync, unlinkSync, promises as fsPromis
|
||||
import { join } from 'path';
|
||||
import { homedir } from 'os';
|
||||
import { executeCliTool } from '../../tools/cli-executor.js';
|
||||
import { SmartContentFormatter } from '../../tools/cli-output-converter.js';
|
||||
import type { RouteContext } from './types.js';
|
||||
|
||||
interface ParsedRuleFrontmatter {
|
||||
@@ -662,8 +663,8 @@ FILE NAME: ${fileName}`;
|
||||
// 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: {
|
||||
@@ -749,8 +750,8 @@ FILE NAME: ${fileName}`;
|
||||
// Create onOutput callback for review step
|
||||
const reviewOnOutput = 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: {
|
||||
|
||||
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user