feat: upgrade core agent workflow and system utilities
This commit is contained in:
@@ -12,15 +12,6 @@ export interface BrainProfile {
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export type MultiAgentStageInput = 'original' | 'previous' | 'combined';
|
||||
|
||||
export interface MultiAgentStageConfig {
|
||||
id: string;
|
||||
name: string;
|
||||
prompt: string;
|
||||
input?: MultiAgentStageInput;
|
||||
}
|
||||
|
||||
// ─── 에이전트 설정 인터페이스 (통합 버전) ───
|
||||
export interface IAgentConfig {
|
||||
ollamaUrl: string;
|
||||
@@ -35,46 +26,12 @@ export interface IAgentConfig {
|
||||
maxAutoSteps: number;
|
||||
dryRun: boolean;
|
||||
multiAgentEnabled: boolean;
|
||||
multiAgentWorkflow: MultiAgentStageConfig[];
|
||||
memoryEnabled: boolean;
|
||||
memoryShortTermMessages: number;
|
||||
memoryMediumTermSessions: number;
|
||||
memoryLongTermFiles: number;
|
||||
}
|
||||
|
||||
export const DEFAULT_MULTI_AGENT_WORKFLOW: MultiAgentStageConfig[] = [
|
||||
{
|
||||
id: 'planner',
|
||||
name: 'Planner',
|
||||
input: 'original',
|
||||
prompt: [
|
||||
'You are the [Master Strategist & Planner].',
|
||||
'Transform the user request into a precise execution blueprint.',
|
||||
'Output Markdown with Objective, Core Challenges, Data Requirements, and Step-by-Step Tasks.'
|
||||
].join('\n')
|
||||
},
|
||||
{
|
||||
id: 'researcher',
|
||||
name: 'Researcher',
|
||||
input: 'combined',
|
||||
prompt: [
|
||||
'You are the [Senior Technical Researcher].',
|
||||
'Extract, filter, and synthesize high-signal facts from the plan and available context.',
|
||||
'Output Key Facts, Technical Deep-Dive, Gaps, and Summary of Knowledge.'
|
||||
].join('\n')
|
||||
},
|
||||
{
|
||||
id: 'writer',
|
||||
name: 'Writer',
|
||||
input: 'combined',
|
||||
prompt: [
|
||||
'You are the [Lead Synthesis Writer & Editor].',
|
||||
'Produce the final response in the user language with a clear conclusion and actionable recommendation.',
|
||||
'Preserve important technical nuance without padding.'
|
||||
].join('\n')
|
||||
}
|
||||
];
|
||||
|
||||
// ─── 경로 정규화 유틸리티 ───
|
||||
function normalizePath(p: string): string {
|
||||
if (!p) return p;
|
||||
@@ -97,21 +54,6 @@ function toBrainProfile(raw: Partial<BrainProfile> | undefined, fallbackIndex: n
|
||||
};
|
||||
}
|
||||
|
||||
function toMultiAgentStage(raw: Partial<MultiAgentStageConfig> | undefined, fallbackIndex: number): MultiAgentStageConfig | null {
|
||||
if (!raw) return null;
|
||||
const prompt = typeof raw.prompt === 'string' ? raw.prompt.trim() : '';
|
||||
if (!prompt) return null;
|
||||
const input = raw.input === 'original' || raw.input === 'previous' || raw.input === 'combined'
|
||||
? raw.input
|
||||
: 'combined';
|
||||
return {
|
||||
id: (raw.id || `stage-${fallbackIndex + 1}`).trim(),
|
||||
name: (raw.name || `Stage ${fallbackIndex + 1}`).trim(),
|
||||
prompt,
|
||||
input
|
||||
};
|
||||
}
|
||||
|
||||
// ─── VS Code 설정에서 읽어오는 값 (통합 구현) ───
|
||||
export function getConfig(): IAgentConfig {
|
||||
const cfg = vscode.workspace.getConfiguration('g1nation');
|
||||
@@ -120,13 +62,9 @@ export function getConfig(): IAgentConfig {
|
||||
const legacyBrainPath = cfg.get<string>('localBrainPath', '');
|
||||
const legacyBrainRepo = cfg.get<string>('secondBrainRepo', '');
|
||||
const configuredProfiles = cfg.get<Partial<BrainProfile>[]>('brainProfiles', []);
|
||||
const configuredWorkflow = cfg.get<Partial<MultiAgentStageConfig>[]>('multiAgentWorkflow', DEFAULT_MULTI_AGENT_WORKFLOW);
|
||||
const profiles = configuredProfiles
|
||||
.map((profile, index) => toBrainProfile(profile, index))
|
||||
.filter((profile): profile is BrainProfile => !!profile);
|
||||
const multiAgentWorkflow = configuredWorkflow
|
||||
.map((stage, index) => toMultiAgentStage(stage, index))
|
||||
.filter((stage): stage is MultiAgentStageConfig => !!stage);
|
||||
|
||||
if (profiles.length === 0) {
|
||||
const fallbackPath = normalizePath(legacyBrainPath) || path.join(os.homedir(), '.g1nation-brain');
|
||||
@@ -144,15 +82,6 @@ export function getConfig(): IAgentConfig {
|
||||
const activeBrainId = cfg.get<string>('activeBrainId', profiles[0].id) || profiles[0].id;
|
||||
const activeBrain = profiles.find((profile) => profile.id === activeBrainId) || profiles[0];
|
||||
|
||||
const rationaleProtocol = `
|
||||
3. Always explain your thought process using the <rationale> tag BEFORE performing any actions. Use the following structure:
|
||||
<rationale>
|
||||
[PROBLEM] Description of the issue or need found in the context.
|
||||
[GOAL] What you intend to achieve with your proposed changes.
|
||||
[REASONING] Detailed logical basis for choosing specific actions or architecture.
|
||||
</rationale>
|
||||
`;
|
||||
|
||||
return {
|
||||
ollamaUrl: cfg.get<string>('ollamaUrl', 'http://127.0.0.1:11434') || 'http://127.0.0.1:11434',
|
||||
defaultModel: cfg.get<string>('defaultModel', 'gemma4:e2b') || 'gemma4:e2b',
|
||||
@@ -166,7 +95,6 @@ export function getConfig(): IAgentConfig {
|
||||
maxAutoSteps: cfg.get<number>('maxAutoSteps', 50),
|
||||
dryRun: cfg.get<boolean>('dryRun', false),
|
||||
multiAgentEnabled: cfg.get<boolean>('multiAgentEnabled', false),
|
||||
multiAgentWorkflow: multiAgentWorkflow.length > 0 ? multiAgentWorkflow : DEFAULT_MULTI_AGENT_WORKFLOW,
|
||||
memoryEnabled: cfg.get<boolean>('memoryEnabled', true),
|
||||
memoryShortTermMessages: Math.max(0, cfg.get<number>('memoryShortTermMessages', 8)),
|
||||
memoryMediumTermSessions: Math.max(0, cfg.get<number>('memoryMediumTermSessions', 5)),
|
||||
|
||||
Reference in New Issue
Block a user