refactor: remove dead code and unoptimized structures
This commit is contained in:
@@ -39,44 +39,6 @@ export function getAstraDataDir(): string {
|
||||
return astraDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* .astra 내부의 특정 파일 경로를 반환합니다.
|
||||
*
|
||||
* @param filename - 파일 이름 (예: 'project_memory.json', 'tasks.json')
|
||||
* @returns 파일의 절대 경로
|
||||
*/
|
||||
export function getAstraFilePath(filename: string): string {
|
||||
return path.join(getAstraDataDir(), filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* .astra 내부의 프로젝트별 서브디렉토리 경로를 반환합니다.
|
||||
* 프로젝트별 메모리 분리가 필요한 경우 사용합니다.
|
||||
*
|
||||
* @param projectId - 프로젝트 식별자 (hash 또는 이름)
|
||||
* @returns 프로젝트별 .astra 서브디렉토리 경로
|
||||
*/
|
||||
export function getAstraProjectDir(projectId: string): string {
|
||||
const projDir = path.join(getAstraDataDir(), 'projects', projectId);
|
||||
if (!fs.existsSync(projDir)) {
|
||||
fs.mkdirSync(projDir, { recursive: true });
|
||||
}
|
||||
return projDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* AAL(Autonomous Loop) 태스크 파일의 경로를 반환합니다.
|
||||
*/
|
||||
export function getAstraTaskFilePath(): string {
|
||||
return getAstraFilePath('tasks.json');
|
||||
}
|
||||
|
||||
/**
|
||||
* AAL 프로토콜 설정 파일 경로를 반환합니다.
|
||||
*/
|
||||
export function getAstraProtocolPath(): string {
|
||||
return getAstraFilePath('protocol.json');
|
||||
}
|
||||
|
||||
/**
|
||||
* extensionUri가 아직 설정되지 않은 경우의 fallback.
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
/**
|
||||
* IDataSource: 데이터 원천에 대한 추상화 인터페이스 (DIP 준수)
|
||||
*/
|
||||
export interface IDataSource<T> {
|
||||
fetch(): Promise<T[]>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 집계 결과 타입 정의
|
||||
*/
|
||||
@@ -15,7 +8,7 @@ export interface AggregateResult {
|
||||
average?: number;
|
||||
}
|
||||
|
||||
export interface AggregateOptions {
|
||||
interface AggregateOptions {
|
||||
collectValues?: boolean;
|
||||
}
|
||||
|
||||
|
||||
+1
-5
@@ -2,7 +2,7 @@
|
||||
* g1nation Custom Error Classes
|
||||
*/
|
||||
|
||||
export abstract class G1Error extends Error {
|
||||
abstract class G1Error extends Error {
|
||||
constructor(public message: string, public details?: any) {
|
||||
super(message);
|
||||
this.name = this.constructor.name;
|
||||
@@ -29,10 +29,6 @@ export class APICommunicationError extends G1Error {
|
||||
getTypeCode() { return 'API_COMMUNICATION_ERROR'; }
|
||||
}
|
||||
|
||||
export class SecurityValidationError extends G1Error {
|
||||
getTypeCode() { return 'SECURITY_VALIDATION_ERROR'; }
|
||||
}
|
||||
|
||||
export class TransactionError extends G1Error {
|
||||
getTypeCode() { return 'TRANSACTION_ERROR'; }
|
||||
}
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
import { logInfo, logError } from '../utils';
|
||||
import { ErrorType } from '../types/interfaces';
|
||||
import { ErrorClassifier } from './engine';
|
||||
|
||||
export interface ApiResponse<T> {
|
||||
success: boolean;
|
||||
data?: T;
|
||||
error?: {
|
||||
type: ErrorType;
|
||||
message: string;
|
||||
isRecoverable: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* ExternalApiHandler: 외부 서비스(Ollama, Gemini, Search API 등)와의
|
||||
* 모든 통신을 중앙 집중적으로 관리하며, 인증 복구 및 속도 제한 대응을 담당합니다.
|
||||
*/
|
||||
export class ExternalApiHandler {
|
||||
/**
|
||||
* 인증 오류 발생 시 복구 가능성을 판단하고 재시도 로직을 제어합니다.
|
||||
*/
|
||||
public static async handleAuthRecovery(error: any): Promise<boolean> {
|
||||
logInfo(`[ApiHandler] 인증 오류 감지. 복구 시도 중...`);
|
||||
// TODO: 실제 프로젝트의 인증 스키마(API Key, OAuth 등)에 따른 복구 로직 구현
|
||||
// 예: 환경 변수 재로드, 만료된 토큰 갱신 요청 등
|
||||
return false; // 현재는 기본적으로 수동 개입 필요로 처리
|
||||
}
|
||||
|
||||
public static async request<T>(
|
||||
call: () => Promise<T>,
|
||||
context: string
|
||||
): Promise<ApiResponse<T>> {
|
||||
try {
|
||||
const data = await call();
|
||||
return { success: true, data };
|
||||
} catch (error: any) {
|
||||
logError(`[ApiHandler] [${context}] 호출 실패:`, error);
|
||||
|
||||
// ErrorClassifier를 통해 시스템 통합 분류 적용
|
||||
const { type, rule } = ErrorClassifier.classify(error);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
error: {
|
||||
type,
|
||||
message: error.message,
|
||||
isRecoverable: type === ErrorType.TRANSIENT || type === ErrorType.AUTH_FAILURE
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,95 +9,6 @@
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
// ─── 에이전트 서비스 인터페이스 ───
|
||||
export interface IAgentService {
|
||||
/**
|
||||
* LLM에 프롬프트를 보내고 스트리밍 응답을 가져옴
|
||||
*/
|
||||
chat(prompt: string, context: string, model?: string): Promise<AsyncGenerator<string>>;
|
||||
|
||||
/**
|
||||
* 터미널 명령어 실행 (보안 정책 적용)
|
||||
*/
|
||||
runCommand(command: string): Promise<{ stdout: string; stderr: string }>;
|
||||
}
|
||||
|
||||
// ─── 파일 시스템 서비스 인터페이스 ───
|
||||
export interface IFileSystemService {
|
||||
/**
|
||||
* 파일 생성
|
||||
*/
|
||||
createFile(filePath: string, content: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* 파일 읽기
|
||||
*/
|
||||
readFile(filePath: string): Promise<string>;
|
||||
|
||||
/**
|
||||
* 파일 수정
|
||||
*/
|
||||
editFile(filePath: string, find: string, replace: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* 파일 삭제
|
||||
*/
|
||||
deleteFile(filePath: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* 디렉토리 목록 조회
|
||||
*/
|
||||
listDirectory(dirPath: string): Promise<string[]>;
|
||||
}
|
||||
|
||||
// ─── 두뇌 서비스 인터페이스 ───
|
||||
export interface IBrainService {
|
||||
/**
|
||||
* 두뇌 폴더 경로 가져오기
|
||||
*/
|
||||
getBrainDir(): string;
|
||||
|
||||
/**
|
||||
* 두뇌 폴더가 명시적으로 설정되었는지 확인
|
||||
*/
|
||||
isBrainDirExplicitlySet(): boolean;
|
||||
|
||||
/**
|
||||
* 두뇌 폴더 내 파일 목록 조회
|
||||
*/
|
||||
getBrainFiles(): Promise<string[]>;
|
||||
|
||||
/**
|
||||
* 두뇌 파일 내용 읽기
|
||||
*/
|
||||
readBrainFile(fileName: string): Promise<string>;
|
||||
}
|
||||
|
||||
// ─── 웹뷰 서비스 인터페이스 ───
|
||||
export interface IWebviewService {
|
||||
/**
|
||||
* 웹뷰에 메시지 전송
|
||||
*/
|
||||
postMessage(message: any): void;
|
||||
|
||||
/**
|
||||
* 웹뷰에서 메시지 수신 핸들러 등록
|
||||
*/
|
||||
onDidReceiveMessage(callback: (message: any) => void): vscode.Disposable;
|
||||
}
|
||||
|
||||
// ─── HTTP 서비스 인터페이스 ───
|
||||
export interface IHttpService {
|
||||
/**
|
||||
* HTTP GET 요청
|
||||
*/
|
||||
get(url: string, options?: any): Promise<any>;
|
||||
|
||||
/**
|
||||
* HTTP POST 요청
|
||||
*/
|
||||
post(url: string, data: any, options?: any): Promise<any>;
|
||||
}
|
||||
|
||||
// ─── 공용 오류 처리 타입 (Unified Error Handling) ───
|
||||
|
||||
|
||||
@@ -85,11 +85,6 @@ export function shouldAutoPushBrain(): boolean {
|
||||
const cfg = vscode.workspace.getConfiguration('g1nation');
|
||||
return cfg.get<boolean>('autoPushBrain', false);
|
||||
}
|
||||
|
||||
export function getSecondBrainRepo(): string {
|
||||
return getConfig().secondBrainRepo;
|
||||
}
|
||||
|
||||
export function getBrainProfiles(): BrainProfile[] {
|
||||
return getConfig().brainProfiles;
|
||||
}
|
||||
@@ -107,18 +102,6 @@ export function _isBrainDirExplicitlySet(): boolean {
|
||||
return getBrainProfiles().length > 0;
|
||||
}
|
||||
|
||||
export function isTextAttachment(fileName: string, mimeType: string): boolean {
|
||||
const lower = fileName.toLowerCase();
|
||||
const textExtensions = [
|
||||
'.txt', '.md', '.csv', '.json', '.js', '.ts', '.jsx', '.tsx',
|
||||
'.html', '.css', '.py', '.java', '.rs', '.go', '.yaml', '.yml',
|
||||
'.xml', '.toml', '.sql', '.sh'
|
||||
];
|
||||
return mimeType.startsWith('text/')
|
||||
|| mimeType === 'application/json'
|
||||
|| textExtensions.some((ext) => lower.endsWith(ext));
|
||||
}
|
||||
|
||||
export function findBrainFiles(dir: string): string[] {
|
||||
let results: string[] = [];
|
||||
if (!fs.existsSync(dir)) return results;
|
||||
|
||||
Reference in New Issue
Block a user