@yuaone/core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +663 -0
- package/README.md +15 -0
- package/dist/__tests__/context-manager.test.d.ts +6 -0
- package/dist/__tests__/context-manager.test.d.ts.map +1 -0
- package/dist/__tests__/context-manager.test.js +220 -0
- package/dist/__tests__/context-manager.test.js.map +1 -0
- package/dist/__tests__/governor.test.d.ts +6 -0
- package/dist/__tests__/governor.test.d.ts.map +1 -0
- package/dist/__tests__/governor.test.js +210 -0
- package/dist/__tests__/governor.test.js.map +1 -0
- package/dist/__tests__/model-router.test.d.ts +6 -0
- package/dist/__tests__/model-router.test.d.ts.map +1 -0
- package/dist/__tests__/model-router.test.js +329 -0
- package/dist/__tests__/model-router.test.js.map +1 -0
- package/dist/agent-logger.d.ts +384 -0
- package/dist/agent-logger.d.ts.map +1 -0
- package/dist/agent-logger.js +820 -0
- package/dist/agent-logger.js.map +1 -0
- package/dist/agent-loop.d.ts +163 -0
- package/dist/agent-loop.d.ts.map +1 -0
- package/dist/agent-loop.js +609 -0
- package/dist/agent-loop.js.map +1 -0
- package/dist/agent-modes.d.ts +85 -0
- package/dist/agent-modes.d.ts.map +1 -0
- package/dist/agent-modes.js +418 -0
- package/dist/agent-modes.js.map +1 -0
- package/dist/approval.d.ts +137 -0
- package/dist/approval.d.ts.map +1 -0
- package/dist/approval.js +299 -0
- package/dist/approval.js.map +1 -0
- package/dist/async-completion-queue.d.ts +56 -0
- package/dist/async-completion-queue.d.ts.map +1 -0
- package/dist/async-completion-queue.js +77 -0
- package/dist/async-completion-queue.js.map +1 -0
- package/dist/auto-fix.d.ts +174 -0
- package/dist/auto-fix.d.ts.map +1 -0
- package/dist/auto-fix.js +319 -0
- package/dist/auto-fix.js.map +1 -0
- package/dist/codebase-context.d.ts +396 -0
- package/dist/codebase-context.d.ts.map +1 -0
- package/dist/codebase-context.js +1260 -0
- package/dist/codebase-context.js.map +1 -0
- package/dist/conflict-resolver.d.ts +191 -0
- package/dist/conflict-resolver.d.ts.map +1 -0
- package/dist/conflict-resolver.js +524 -0
- package/dist/conflict-resolver.js.map +1 -0
- package/dist/constants.d.ts +52 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +141 -0
- package/dist/constants.js.map +1 -0
- package/dist/context-budget.d.ts +435 -0
- package/dist/context-budget.d.ts.map +1 -0
- package/dist/context-budget.js +903 -0
- package/dist/context-budget.js.map +1 -0
- package/dist/context-compressor.d.ts +143 -0
- package/dist/context-compressor.d.ts.map +1 -0
- package/dist/context-compressor.js +511 -0
- package/dist/context-compressor.js.map +1 -0
- package/dist/context-manager.d.ts +112 -0
- package/dist/context-manager.d.ts.map +1 -0
- package/dist/context-manager.js +247 -0
- package/dist/context-manager.js.map +1 -0
- package/dist/continuous-reflection.d.ts +267 -0
- package/dist/continuous-reflection.d.ts.map +1 -0
- package/dist/continuous-reflection.js +338 -0
- package/dist/continuous-reflection.js.map +1 -0
- package/dist/cross-file-refactor.d.ts +352 -0
- package/dist/cross-file-refactor.d.ts.map +1 -0
- package/dist/cross-file-refactor.js +1544 -0
- package/dist/cross-file-refactor.js.map +1 -0
- package/dist/dag-orchestrator.d.ts +138 -0
- package/dist/dag-orchestrator.d.ts.map +1 -0
- package/dist/dag-orchestrator.js +379 -0
- package/dist/dag-orchestrator.js.map +1 -0
- package/dist/debate-orchestrator.d.ts +301 -0
- package/dist/debate-orchestrator.d.ts.map +1 -0
- package/dist/debate-orchestrator.js +719 -0
- package/dist/debate-orchestrator.js.map +1 -0
- package/dist/dependency-analyzer.d.ts +113 -0
- package/dist/dependency-analyzer.d.ts.map +1 -0
- package/dist/dependency-analyzer.js +444 -0
- package/dist/dependency-analyzer.js.map +1 -0
- package/dist/design-loop.d.ts +59 -0
- package/dist/design-loop.d.ts.map +1 -0
- package/dist/design-loop.js +344 -0
- package/dist/design-loop.js.map +1 -0
- package/dist/doc-intelligence.d.ts +383 -0
- package/dist/doc-intelligence.d.ts.map +1 -0
- package/dist/doc-intelligence.js +1307 -0
- package/dist/doc-intelligence.js.map +1 -0
- package/dist/dynamic-role-generator.d.ts +76 -0
- package/dist/dynamic-role-generator.d.ts.map +1 -0
- package/dist/dynamic-role-generator.js +194 -0
- package/dist/dynamic-role-generator.js.map +1 -0
- package/dist/errors.d.ts +69 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +102 -0
- package/dist/errors.js.map +1 -0
- package/dist/event-bus.d.ts +159 -0
- package/dist/event-bus.d.ts.map +1 -0
- package/dist/event-bus.js +305 -0
- package/dist/event-bus.js.map +1 -0
- package/dist/execution-engine.d.ts +425 -0
- package/dist/execution-engine.d.ts.map +1 -0
- package/dist/execution-engine.js +1555 -0
- package/dist/execution-engine.js.map +1 -0
- package/dist/git-intelligence.d.ts +306 -0
- package/dist/git-intelligence.d.ts.map +1 -0
- package/dist/git-intelligence.js +1099 -0
- package/dist/git-intelligence.js.map +1 -0
- package/dist/governor.d.ts +77 -0
- package/dist/governor.d.ts.map +1 -0
- package/dist/governor.js +161 -0
- package/dist/governor.js.map +1 -0
- package/dist/hierarchical-planner.d.ts +313 -0
- package/dist/hierarchical-planner.d.ts.map +1 -0
- package/dist/hierarchical-planner.js +981 -0
- package/dist/hierarchical-planner.js.map +1 -0
- package/dist/index.d.ts +121 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +123 -0
- package/dist/index.js.map +1 -0
- package/dist/intent-inference.d.ts +103 -0
- package/dist/intent-inference.d.ts.map +1 -0
- package/dist/intent-inference.js +605 -0
- package/dist/intent-inference.js.map +1 -0
- package/dist/interrupt-manager.d.ts +143 -0
- package/dist/interrupt-manager.d.ts.map +1 -0
- package/dist/interrupt-manager.js +196 -0
- package/dist/interrupt-manager.js.map +1 -0
- package/dist/kernel.d.ts +564 -0
- package/dist/kernel.d.ts.map +1 -0
- package/dist/kernel.js +1419 -0
- package/dist/kernel.js.map +1 -0
- package/dist/language-support.d.ts +232 -0
- package/dist/language-support.d.ts.map +1 -0
- package/dist/language-support.js +1134 -0
- package/dist/language-support.js.map +1 -0
- package/dist/llm-client.d.ts +82 -0
- package/dist/llm-client.d.ts.map +1 -0
- package/dist/llm-client.js +475 -0
- package/dist/llm-client.js.map +1 -0
- package/dist/mcp-client.d.ts +232 -0
- package/dist/mcp-client.d.ts.map +1 -0
- package/dist/mcp-client.js +718 -0
- package/dist/mcp-client.js.map +1 -0
- package/dist/memory-manager.d.ts +200 -0
- package/dist/memory-manager.d.ts.map +1 -0
- package/dist/memory-manager.js +568 -0
- package/dist/memory-manager.js.map +1 -0
- package/dist/memory.d.ts +87 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +341 -0
- package/dist/memory.js.map +1 -0
- package/dist/model-router.d.ts +245 -0
- package/dist/model-router.d.ts.map +1 -0
- package/dist/model-router.js +632 -0
- package/dist/model-router.js.map +1 -0
- package/dist/parallel-executor.d.ts +125 -0
- package/dist/parallel-executor.d.ts.map +1 -0
- package/dist/parallel-executor.js +201 -0
- package/dist/parallel-executor.js.map +1 -0
- package/dist/perf-optimizer.d.ts +212 -0
- package/dist/perf-optimizer.d.ts.map +1 -0
- package/dist/perf-optimizer.js +721 -0
- package/dist/perf-optimizer.js.map +1 -0
- package/dist/persona.d.ts +305 -0
- package/dist/persona.d.ts.map +1 -0
- package/dist/persona.js +887 -0
- package/dist/persona.js.map +1 -0
- package/dist/planner.d.ts +70 -0
- package/dist/planner.d.ts.map +1 -0
- package/dist/planner.js +264 -0
- package/dist/planner.js.map +1 -0
- package/dist/qa-pipeline.d.ts +365 -0
- package/dist/qa-pipeline.d.ts.map +1 -0
- package/dist/qa-pipeline.js +1352 -0
- package/dist/qa-pipeline.js.map +1 -0
- package/dist/reasoning-adapter.d.ts +116 -0
- package/dist/reasoning-adapter.d.ts.map +1 -0
- package/dist/reasoning-adapter.js +187 -0
- package/dist/reasoning-adapter.js.map +1 -0
- package/dist/role-registry.d.ts +55 -0
- package/dist/role-registry.d.ts.map +1 -0
- package/dist/role-registry.js +192 -0
- package/dist/role-registry.js.map +1 -0
- package/dist/sandbox-tiers.d.ts +327 -0
- package/dist/sandbox-tiers.d.ts.map +1 -0
- package/dist/sandbox-tiers.js +928 -0
- package/dist/sandbox-tiers.js.map +1 -0
- package/dist/security-scanner.d.ts +222 -0
- package/dist/security-scanner.d.ts.map +1 -0
- package/dist/security-scanner.js +1129 -0
- package/dist/security-scanner.js.map +1 -0
- package/dist/security.d.ts +93 -0
- package/dist/security.d.ts.map +1 -0
- package/dist/security.js +393 -0
- package/dist/security.js.map +1 -0
- package/dist/self-reflection.d.ts +397 -0
- package/dist/self-reflection.d.ts.map +1 -0
- package/dist/self-reflection.js +908 -0
- package/dist/self-reflection.js.map +1 -0
- package/dist/session-persistence.d.ts +191 -0
- package/dist/session-persistence.d.ts.map +1 -0
- package/dist/session-persistence.js +395 -0
- package/dist/session-persistence.js.map +1 -0
- package/dist/speculative-executor.d.ts +210 -0
- package/dist/speculative-executor.d.ts.map +1 -0
- package/dist/speculative-executor.js +618 -0
- package/dist/speculative-executor.js.map +1 -0
- package/dist/state-machine.d.ts +289 -0
- package/dist/state-machine.d.ts.map +1 -0
- package/dist/state-machine.js +695 -0
- package/dist/state-machine.js.map +1 -0
- package/dist/sub-agent.d.ts +177 -0
- package/dist/sub-agent.d.ts.map +1 -0
- package/dist/sub-agent.js +303 -0
- package/dist/sub-agent.js.map +1 -0
- package/dist/system-prompt.d.ts +26 -0
- package/dist/system-prompt.d.ts.map +1 -0
- package/dist/system-prompt.js +84 -0
- package/dist/system-prompt.js.map +1 -0
- package/dist/test-intelligence.d.ts +439 -0
- package/dist/test-intelligence.d.ts.map +1 -0
- package/dist/test-intelligence.js +1165 -0
- package/dist/test-intelligence.js.map +1 -0
- package/dist/types.d.ts +632 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/dist/vector-index.d.ts +314 -0
- package/dist/vector-index.d.ts.map +1 -0
- package/dist/vector-index.js +618 -0
- package/dist/vector-index.js.map +1 -0
- package/package.json +41 -0
package/dist/auto-fix.js
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module auto-fix
|
|
3
|
+
* @description 자동 수정 루프 — 도구 실행 결과를 검증하고, 실패 시 자동 수정 시도.
|
|
4
|
+
*
|
|
5
|
+
* 플로우:
|
|
6
|
+
* 1. 도구 실행 결과 수신
|
|
7
|
+
* 2. 결과 검증 (lint 에러, 빌드 에러, 타입 에러 등)
|
|
8
|
+
* 3. 실패 시 → 에러 메시지를 LLM에 피드백할 프롬프트 생성
|
|
9
|
+
* 4. LLM이 수정 제안 → 도구 재실행
|
|
10
|
+
* 5. 최대 maxRetries 반복 후 포기
|
|
11
|
+
*
|
|
12
|
+
* @see 설계 문서 Section 6.4
|
|
13
|
+
*/
|
|
14
|
+
import { execFile } from "node:child_process";
|
|
15
|
+
import { access, constants } from "node:fs/promises";
|
|
16
|
+
import path from "node:path";
|
|
17
|
+
/** 기본 자동 수정 설정 */
|
|
18
|
+
export const DEFAULT_AUTO_FIX_CONFIG = {
|
|
19
|
+
maxRetries: 3,
|
|
20
|
+
autoLint: true,
|
|
21
|
+
autoTest: false, // Phase 1b
|
|
22
|
+
autoBuild: true,
|
|
23
|
+
};
|
|
24
|
+
// ─── AutoFixLoop ───
|
|
25
|
+
/**
|
|
26
|
+
* AutoFixLoop — 도구 실행 결과를 검증하고 자동 수정 루프를 관리.
|
|
27
|
+
*
|
|
28
|
+
* 이 클래스 자체는 LLM을 호출하지 않는다.
|
|
29
|
+
* 검증 실패 시 LLM에 피드백할 프롬프트를 생성하고,
|
|
30
|
+
* AgentLoop이 해당 프롬프트를 LLM에 전달하여 수정 도구 호출을 받는다.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const autoFix = new AutoFixLoop({ maxRetries: 3, autoLint: true, autoBuild: true, autoTest: false });
|
|
35
|
+
*
|
|
36
|
+
* // 도구 실행 후 검증
|
|
37
|
+
* const validation = await autoFix.validateResult('file_write', result, '/project');
|
|
38
|
+
* if (!validation.passed) {
|
|
39
|
+
* const fixPrompt = autoFix.buildFixPrompt(
|
|
40
|
+
* validation.failures[0].message,
|
|
41
|
+
* 'Writing component file'
|
|
42
|
+
* );
|
|
43
|
+
* // fixPrompt를 LLM에 전달 → 수정 도구 호출 수신
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export class AutoFixLoop {
|
|
48
|
+
config;
|
|
49
|
+
attempts = [];
|
|
50
|
+
constructor(config) {
|
|
51
|
+
this.config = { ...DEFAULT_AUTO_FIX_CONFIG, ...config };
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 도구 실행 결과를 검증.
|
|
55
|
+
* file_write/file_edit 후에는 lint/빌드 체크를 자동 실행한다.
|
|
56
|
+
*
|
|
57
|
+
* @param toolName 실행된 도구 이름
|
|
58
|
+
* @param toolOutput 도구 실행 결과 출력
|
|
59
|
+
* @param success 도구 실행 성공 여부
|
|
60
|
+
* @param workDir 프로젝트 루트 경로
|
|
61
|
+
* @returns 검증 결과
|
|
62
|
+
*/
|
|
63
|
+
async validateResult(toolName, toolOutput, success, workDir) {
|
|
64
|
+
const failures = [];
|
|
65
|
+
// 도구 실행 자체가 실패한 경우
|
|
66
|
+
if (!success) {
|
|
67
|
+
const trigger = this.classifyError(toolOutput);
|
|
68
|
+
failures.push({
|
|
69
|
+
type: trigger,
|
|
70
|
+
message: toolOutput,
|
|
71
|
+
rawOutput: toolOutput,
|
|
72
|
+
});
|
|
73
|
+
return { passed: false, failures };
|
|
74
|
+
}
|
|
75
|
+
// file_write / file_edit 후 검증
|
|
76
|
+
if (["file_write", "file_edit"].includes(toolName)) {
|
|
77
|
+
// 자동 lint
|
|
78
|
+
if (this.config.autoLint) {
|
|
79
|
+
const lintResult = await this.runLint(workDir);
|
|
80
|
+
if (!lintResult.passed) {
|
|
81
|
+
failures.push({
|
|
82
|
+
type: "LINT_ERROR",
|
|
83
|
+
message: `Lint failed with ${lintResult.errorCount} error(s)`,
|
|
84
|
+
rawOutput: lintResult.output,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// 자동 빌드 체크
|
|
89
|
+
if (this.config.autoBuild) {
|
|
90
|
+
const buildResult = await this.runBuildCheck(workDir);
|
|
91
|
+
if (!buildResult.passed) {
|
|
92
|
+
failures.push({
|
|
93
|
+
type: this.isBuildTypeError(buildResult.output)
|
|
94
|
+
? "TYPE_ERROR"
|
|
95
|
+
: "BUILD_FAIL",
|
|
96
|
+
message: `Build check failed with ${buildResult.errorCount} error(s)`,
|
|
97
|
+
rawOutput: buildResult.output,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// shell_exec 결과에서 에러 감지
|
|
103
|
+
if (toolName === "shell_exec" && success) {
|
|
104
|
+
const shellErrors = this.detectShellErrors(toolOutput);
|
|
105
|
+
failures.push(...shellErrors);
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
passed: failures.length === 0,
|
|
109
|
+
failures,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* 실패 시 LLM에 피드백할 수정 프롬프트를 생성.
|
|
114
|
+
*
|
|
115
|
+
* @param error 에러 메시지
|
|
116
|
+
* @param context 현재 작업 컨텍스트
|
|
117
|
+
* @returns LLM에 전달할 프롬프트 문자열
|
|
118
|
+
*/
|
|
119
|
+
buildFixPrompt(error, context) {
|
|
120
|
+
const attemptNum = this.attempts.length + 1;
|
|
121
|
+
const maxRetries = this.config.maxRetries;
|
|
122
|
+
let prompt = `[AUTO-FIX ${attemptNum}/${maxRetries}] The previous action resulted in an error.\n\n`;
|
|
123
|
+
prompt += `## Error\n\`\`\`\n${this.truncateOutput(error, 2000)}\n\`\`\`\n\n`;
|
|
124
|
+
prompt += `## Context\n${context}\n\n`;
|
|
125
|
+
prompt += `## Instructions\n`;
|
|
126
|
+
prompt += `- Analyze the error and fix the issue.\n`;
|
|
127
|
+
prompt += `- Make minimal, targeted changes to resolve the error.\n`;
|
|
128
|
+
prompt += `- Do not introduce new functionality or refactoring.\n`;
|
|
129
|
+
if (attemptNum > 1) {
|
|
130
|
+
prompt += `\n## Previous Attempts\n`;
|
|
131
|
+
for (const attempt of this.attempts) {
|
|
132
|
+
prompt += `- Attempt ${attempt.iteration}: ${attempt.fix} → ${attempt.success ? "OK" : "FAILED"}\n`;
|
|
133
|
+
}
|
|
134
|
+
prompt += `\nAvoid repeating the same fix. Try a different approach.\n`;
|
|
135
|
+
}
|
|
136
|
+
if (attemptNum >= maxRetries) {
|
|
137
|
+
prompt +=
|
|
138
|
+
`\nThis is the LAST attempt. If this fix doesn't work, the error will be reported to the user.\n`;
|
|
139
|
+
}
|
|
140
|
+
return prompt;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* 수정 시도를 기록.
|
|
144
|
+
* @param error 에러 메시지
|
|
145
|
+
* @param fix 수정 내용 설명
|
|
146
|
+
* @param success 수정 성공 여부
|
|
147
|
+
* @param durationMs 소요 시간
|
|
148
|
+
*/
|
|
149
|
+
recordAttempt(error, fix, success, durationMs) {
|
|
150
|
+
this.attempts.push({
|
|
151
|
+
iteration: this.attempts.length + 1,
|
|
152
|
+
error,
|
|
153
|
+
fix,
|
|
154
|
+
success,
|
|
155
|
+
durationMs,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* 남은 수정 시도 횟수를 반환.
|
|
160
|
+
*/
|
|
161
|
+
getRemainingRetries() {
|
|
162
|
+
return Math.max(0, this.config.maxRetries - this.attempts.length);
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* 수정 시도를 더 할 수 있는지 반환.
|
|
166
|
+
*/
|
|
167
|
+
canRetry() {
|
|
168
|
+
return this.getRemainingRetries() > 0;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* 수정 시도 기록을 반환.
|
|
172
|
+
*/
|
|
173
|
+
getAttempts() {
|
|
174
|
+
return this.attempts;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* 수정 시도 기록을 초기화 (새 도구 호출 시작 시).
|
|
178
|
+
*/
|
|
179
|
+
resetAttempts() {
|
|
180
|
+
this.attempts.length = 0;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* 현재 설정을 반환.
|
|
184
|
+
*/
|
|
185
|
+
getConfig() {
|
|
186
|
+
return { ...this.config };
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* 프로젝트에서 lint를 실행.
|
|
190
|
+
* 순서: eslint → npx tsc --noEmit (lint 대체)
|
|
191
|
+
* @param workDir 프로젝트 루트 경로
|
|
192
|
+
*/
|
|
193
|
+
async runLint(workDir) {
|
|
194
|
+
// eslint 먼저 시도
|
|
195
|
+
const hasEslint = await this.fileExists(path.join(workDir, "node_modules/.bin/eslint"));
|
|
196
|
+
if (hasEslint) {
|
|
197
|
+
const result = await this.exec("npx", ["eslint", ".", "--quiet"], workDir);
|
|
198
|
+
const errorCount = (result.output.match(/\d+ error/g) || []).length;
|
|
199
|
+
return {
|
|
200
|
+
passed: result.exitCode === 0,
|
|
201
|
+
errorCount: result.exitCode === 0 ? 0 : Math.max(1, errorCount),
|
|
202
|
+
warningCount: 0,
|
|
203
|
+
output: result.output,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
// eslint 없으면 tsc --noEmit으로 대체
|
|
207
|
+
return this.runTscCheck(workDir);
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* 프로젝트에서 빌드 체크 (tsc --noEmit) 를 실행.
|
|
211
|
+
* @param workDir 프로젝트 루트 경로
|
|
212
|
+
*/
|
|
213
|
+
async runBuildCheck(workDir) {
|
|
214
|
+
const result = await this.runTscCheck(workDir);
|
|
215
|
+
return {
|
|
216
|
+
passed: result.passed,
|
|
217
|
+
errorCount: result.errorCount,
|
|
218
|
+
output: result.output,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
// ─── Private ───
|
|
222
|
+
async runTscCheck(workDir) {
|
|
223
|
+
const hasTsc = await this.fileExists(path.join(workDir, "node_modules/.bin/tsc"));
|
|
224
|
+
if (!hasTsc) {
|
|
225
|
+
// tsc 없으면 검증 통과 (검증 불가)
|
|
226
|
+
return { passed: true, errorCount: 0, warningCount: 0, output: "" };
|
|
227
|
+
}
|
|
228
|
+
const result = await this.exec("npx", ["tsc", "--noEmit", "--pretty"], workDir);
|
|
229
|
+
const errorMatch = result.output.match(/Found (\d+) error/);
|
|
230
|
+
const errorCount = errorMatch ? parseInt(errorMatch[1], 10) : 0;
|
|
231
|
+
return {
|
|
232
|
+
passed: result.exitCode === 0,
|
|
233
|
+
errorCount: result.exitCode === 0 ? 0 : Math.max(1, errorCount),
|
|
234
|
+
warningCount: 0,
|
|
235
|
+
output: result.output,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
classifyError(output) {
|
|
239
|
+
const lower = output.toLowerCase();
|
|
240
|
+
if (lower.includes("type") && lower.includes("error")) {
|
|
241
|
+
return "TYPE_ERROR";
|
|
242
|
+
}
|
|
243
|
+
if (lower.includes("cannot find module") ||
|
|
244
|
+
lower.includes("import") ||
|
|
245
|
+
lower.includes("require")) {
|
|
246
|
+
return "IMPORT_ERROR";
|
|
247
|
+
}
|
|
248
|
+
if (lower.includes("lint")) {
|
|
249
|
+
return "LINT_ERROR";
|
|
250
|
+
}
|
|
251
|
+
if (lower.includes("test")) {
|
|
252
|
+
return "TEST_FAIL";
|
|
253
|
+
}
|
|
254
|
+
if (lower.includes("build") ||
|
|
255
|
+
lower.includes("compile") ||
|
|
256
|
+
lower.includes("tsc")) {
|
|
257
|
+
return "BUILD_FAIL";
|
|
258
|
+
}
|
|
259
|
+
return "RUNTIME_ERROR";
|
|
260
|
+
}
|
|
261
|
+
isBuildTypeError(output) {
|
|
262
|
+
return /TS\d{4}:/.test(output) || /type.*error/i.test(output);
|
|
263
|
+
}
|
|
264
|
+
detectShellErrors(output) {
|
|
265
|
+
const failures = [];
|
|
266
|
+
// TypeScript 에러 감지
|
|
267
|
+
const tsErrors = output.match(/error TS\d+:.+/g);
|
|
268
|
+
if (tsErrors && tsErrors.length > 0) {
|
|
269
|
+
failures.push({
|
|
270
|
+
type: "TYPE_ERROR",
|
|
271
|
+
message: `TypeScript: ${tsErrors.length} error(s) detected`,
|
|
272
|
+
rawOutput: tsErrors.join("\n"),
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
// ESLint 에러 감지
|
|
276
|
+
if (/\d+ error/.test(output) && /eslint/i.test(output)) {
|
|
277
|
+
failures.push({
|
|
278
|
+
type: "LINT_ERROR",
|
|
279
|
+
message: "ESLint errors detected",
|
|
280
|
+
rawOutput: output,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
return failures;
|
|
284
|
+
}
|
|
285
|
+
truncateOutput(output, maxLength) {
|
|
286
|
+
if (output.length <= maxLength)
|
|
287
|
+
return output;
|
|
288
|
+
const half = Math.floor(maxLength / 2);
|
|
289
|
+
return (output.slice(0, half) +
|
|
290
|
+
"\n... [truncated] ...\n" +
|
|
291
|
+
output.slice(-half));
|
|
292
|
+
}
|
|
293
|
+
async fileExists(filePath) {
|
|
294
|
+
try {
|
|
295
|
+
await access(filePath, constants.F_OK);
|
|
296
|
+
return true;
|
|
297
|
+
}
|
|
298
|
+
catch {
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
exec(executable, args, cwd) {
|
|
303
|
+
return new Promise((resolve) => {
|
|
304
|
+
execFile(executable, args, {
|
|
305
|
+
cwd,
|
|
306
|
+
timeout: 30_000,
|
|
307
|
+
maxBuffer: 1024 * 1024,
|
|
308
|
+
env: { ...process.env, FORCE_COLOR: "0" },
|
|
309
|
+
}, (error, stdout, stderr) => {
|
|
310
|
+
const exitCode = error && "code" in error ? error.code ?? 1 : 0;
|
|
311
|
+
resolve({
|
|
312
|
+
exitCode: typeof exitCode === "number" ? exitCode : 1,
|
|
313
|
+
output: (stdout + "\n" + stderr).trim(),
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
//# sourceMappingURL=auto-fix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-fix.js","sourceRoot":"","sources":["../src/auto-fix.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,IAAI,MAAM,WAAW,CAAC;AAmF7B,kBAAkB;AAClB,MAAM,CAAC,MAAM,uBAAuB,GAAkB;IACpD,UAAU,EAAE,CAAC;IACb,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,KAAK,EAAE,WAAW;IAC5B,SAAS,EAAE,IAAI;CAChB,CAAC;AAEF,sBAAsB;AAEtB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,WAAW;IACL,MAAM,CAAgB;IACtB,QAAQ,GAAiB,EAAE,CAAC;IAE7C,YAAY,MAA+B;QACzC,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,uBAAuB,EAAE,GAAG,MAAM,EAAE,CAAC;IAC1D,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,cAAc,CAClB,QAAgB,EAChB,UAAkB,EAClB,OAAgB,EAChB,OAAe;QAEf,MAAM,QAAQ,GAAwB,EAAE,CAAC;QAEzC,mBAAmB;QACnB,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;YAC/C,QAAQ,CAAC,IAAI,CAAC;gBACZ,IAAI,EAAE,OAAO;gBACb,OA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