refactor: extract shared utilities, protocol constants, and retry loop
Phase 3: provider-retry.ts — shared Claude rotation loop (SSOT) - retryClaudeWithRotation extracted from message-agent-executor + task-scheduler - ~200 lines of duplicated retry logic removed Phase 4: types.ts — AgentOutputPhase + VisiblePhase unified Phase 5: types.ts — AgentConfig extended with claudeThinking/claudeThinkingBudget Utilities (utils.ts): - getErrorMessage: 14 occurrences of instanceof Error pattern → 1 function - readJsonFile/writeJsonFile: 19 occurrences of JSON+fs pattern → 2 functions - fetchWithTimeout: 3 occurrences of AbortController pattern → 1 function - formatElapsedKorean: deduplicated from task-watch-status + message-turn-controller Protocol (agent-protocol.ts): - OUTPUT_START/END_MARKER centralized (runners keep local copies with SSOT reference) - IMAGE_TAG_RE, IPC constants documented Runner: show "대화 요약 중..." progress message during auto-compact Net: -137 lines, 354/354 tests passing
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
resolveGroupIpcPath,
|
||||
resolveTaskRuntimeIpcPath,
|
||||
} from './group-folder.js';
|
||||
import { writeJsonFile } from './utils.js';
|
||||
|
||||
export function writeTasksSnapshot(
|
||||
groupFolder: string,
|
||||
@@ -28,7 +29,7 @@ export function writeTasksSnapshot(
|
||||
? tasks
|
||||
: tasks.filter((t) => t.groupFolder === groupFolder);
|
||||
const tasksFile = path.join(groupIpcDir, 'current_tasks.json');
|
||||
fs.writeFileSync(tasksFile, JSON.stringify(filteredTasks, null, 2));
|
||||
writeJsonFile(tasksFile, filteredTasks, true);
|
||||
}
|
||||
|
||||
export interface AvailableGroup {
|
||||
@@ -48,12 +49,5 @@ export function writeGroupsSnapshot(
|
||||
fs.mkdirSync(groupIpcDir, { recursive: true });
|
||||
const visibleGroups = isMain ? groups : [];
|
||||
const groupsFile = path.join(groupIpcDir, 'available_groups.json');
|
||||
fs.writeFileSync(
|
||||
groupsFile,
|
||||
JSON.stringify(
|
||||
{ groups: visibleGroups, lastSync: new Date().toISOString() },
|
||||
null,
|
||||
2,
|
||||
),
|
||||
);
|
||||
writeJsonFile(groupsFile, { groups: visibleGroups, lastSync: new Date().toISOString() }, true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user