@yuaone/core 0.1.3 → 0.2.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/dist/agent-loop.d.ts +112 -0
- package/dist/agent-loop.d.ts.map +1 -1
- package/dist/agent-loop.js +715 -9
- package/dist/agent-loop.js.map +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +8 -0
- package/dist/constants.js.map +1 -1
- package/dist/context-budget.d.ts +1 -1
- package/dist/context-budget.d.ts.map +1 -1
- package/dist/context-budget.js +4 -2
- package/dist/context-budget.js.map +1 -1
- package/dist/context-compressor.d.ts +1 -1
- package/dist/context-compressor.d.ts.map +1 -1
- package/dist/context-compressor.js +5 -3
- package/dist/context-compressor.js.map +1 -1
- package/dist/context-manager.d.ts +7 -1
- package/dist/context-manager.d.ts.map +1 -1
- package/dist/context-manager.js +34 -2
- package/dist/context-manager.js.map +1 -1
- package/dist/continuation-engine.d.ts +168 -0
- package/dist/continuation-engine.d.ts.map +1 -0
- package/dist/continuation-engine.js +421 -0
- package/dist/continuation-engine.js.map +1 -0
- package/dist/execution-engine.d.ts.map +1 -1
- package/dist/execution-engine.js +9 -4
- package/dist/execution-engine.js.map +1 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -1
- package/dist/llm-client.d.ts +1 -1
- package/dist/llm-client.d.ts.map +1 -1
- package/dist/llm-client.js +74 -7
- package/dist/llm-client.js.map +1 -1
- package/dist/memory-updater.d.ts +189 -0
- package/dist/memory-updater.d.ts.map +1 -0
- package/dist/memory-updater.js +481 -0
- package/dist/memory-updater.js.map +1 -0
- package/dist/prompt-defense.d.ts +59 -0
- package/dist/prompt-defense.d.ts.map +1 -0
- package/dist/prompt-defense.js +311 -0
- package/dist/prompt-defense.js.map +1 -0
- package/dist/reflexion.d.ts +211 -0
- package/dist/reflexion.d.ts.map +1 -0
- package/dist/reflexion.js +559 -0
- package/dist/reflexion.js.map +1 -0
- package/dist/system-prompt.d.ts +19 -3
- package/dist/system-prompt.d.ts.map +1 -1
- package/dist/system-prompt.js +203 -38
- package/dist/system-prompt.js.map +1 -1
- package/dist/task-classifier.d.ts +92 -0
- package/dist/task-classifier.d.ts.map +1 -0
- package/dist/task-classifier.js +566 -0
- package/dist/task-classifier.js.map +1 -0
- package/dist/token-budget.d.ts +131 -0
- package/dist/token-budget.d.ts.map +1 -0
- package/dist/token-budget.js +321 -0
- package/dist/token-budget.js.map +1 -0
- package/dist/types.d.ts +20 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +18 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/dist/system-prompt.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module system-prompt
|
|
3
|
-
* @description 시스템 프롬프트
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* @description 시스템 프롬프트 생성 — YUAN 에이전트의 두뇌를 구성한다.
|
|
4
|
+
*
|
|
5
|
+
* Claude Code 수준의 상세한 프롬프트로 LLM에게:
|
|
6
|
+
* - 작업 방식 (탐색 → 계획 → 실행 → 검증)
|
|
7
|
+
* - 도구 사용 패턴과 전략
|
|
8
|
+
* - 코드 품질 기준
|
|
9
|
+
* - 안전 규칙
|
|
10
|
+
* 을 가르친다.
|
|
6
11
|
*/
|
|
7
12
|
/**
|
|
8
13
|
* 에이전트 시스템 프롬프트를 생성.
|
|
@@ -11,36 +16,107 @@
|
|
|
11
16
|
*/
|
|
12
17
|
export function buildSystemPrompt(options) {
|
|
13
18
|
const sections = [];
|
|
14
|
-
// 1. 에이전트
|
|
15
|
-
sections.push(
|
|
16
|
-
// 2.
|
|
19
|
+
// 1. 에이전트 정체성 및 핵심 행동 지침
|
|
20
|
+
sections.push(AGENT_IDENTITY);
|
|
21
|
+
// 2. 사고 프로세스
|
|
22
|
+
sections.push(THINKING_PROCESS);
|
|
23
|
+
// 3. 환경 정보
|
|
24
|
+
if (options.environment || options.projectPath) {
|
|
25
|
+
sections.push(buildEnvironmentSection(options.environment, options.projectPath));
|
|
26
|
+
}
|
|
27
|
+
// 4. 프로젝트 컨텍스트
|
|
17
28
|
if (options.projectStructure) {
|
|
18
29
|
sections.push(buildProjectSection(options.projectStructure));
|
|
19
30
|
}
|
|
20
|
-
//
|
|
31
|
+
// 5. YUAN.md 내용 (프로젝트 메모리)
|
|
21
32
|
if (options.yuanMdContent) {
|
|
22
|
-
sections.push(
|
|
33
|
+
sections.push(`# Project Memory (YUAN.md)\n\nThis is the project's persistent memory. Follow any instructions here as they represent established conventions and decisions.\n\n${options.yuanMdContent}`);
|
|
23
34
|
}
|
|
24
|
-
//
|
|
35
|
+
// 6. 도구 사용 전략
|
|
25
36
|
if (options.tools.length > 0) {
|
|
26
|
-
sections.push(
|
|
37
|
+
sections.push(buildToolStrategySection(options.tools));
|
|
27
38
|
}
|
|
28
|
-
//
|
|
29
|
-
sections.push(
|
|
30
|
-
//
|
|
39
|
+
// 7. 코드 작업 규칙
|
|
40
|
+
sections.push(CODE_RULES);
|
|
41
|
+
// 8. 안전 규칙
|
|
42
|
+
sections.push(SAFETY_RULES);
|
|
43
|
+
// 9. 출력 스타일
|
|
44
|
+
sections.push(OUTPUT_STYLE);
|
|
45
|
+
// 10. 추가 규칙
|
|
31
46
|
if (options.additionalRules?.length) {
|
|
32
|
-
sections.push(
|
|
47
|
+
sections.push(`# Additional Rules\n\n${options.additionalRules.map((r) => `- ${r}`).join("\n")}`);
|
|
33
48
|
}
|
|
34
49
|
return sections.join("\n\n---\n\n").trim();
|
|
35
50
|
}
|
|
36
|
-
// ───
|
|
37
|
-
const
|
|
51
|
+
// ─── Section: Identity ───
|
|
52
|
+
const AGENT_IDENTITY = `# You are YUAN
|
|
53
|
+
|
|
54
|
+
You are YUAN, an expert AI coding agent created by YUA. You have direct access to the user's project through a set of powerful tools. Your job is to understand the user's intent, explore their codebase, plan your approach, make changes, and verify everything works.
|
|
55
|
+
|
|
56
|
+
You are autonomous. You can read files, write files, search code, run shell commands, and manage git — all without asking the user for permission on safe operations. For destructive or risky operations (deleting files, force-pushing, running dangerous commands), you must ask for approval.
|
|
57
|
+
|
|
58
|
+
You think before you act. You read before you write. You verify after you change.`;
|
|
59
|
+
// ─── Section: Thinking Process ───
|
|
60
|
+
const THINKING_PROCESS = `# How You Think
|
|
61
|
+
|
|
62
|
+
Before taking any action, follow this mental process:
|
|
63
|
+
|
|
64
|
+
## 1. Understand
|
|
65
|
+
- What exactly does the user want? Restate the goal in your own words.
|
|
66
|
+
- What are the constraints? (language, framework, style, existing patterns)
|
|
67
|
+
- Is this a simple task (one file, obvious change) or complex (multiple files, architectural)?
|
|
68
|
+
|
|
69
|
+
## 2. Explore
|
|
70
|
+
- For any task involving existing code: **read the relevant files first**.
|
|
71
|
+
- Never assume you know what a file contains. Always read it.
|
|
72
|
+
- Use grep/glob to find related files, imports, usages before making changes.
|
|
73
|
+
- Understand the existing patterns before introducing new ones.
|
|
74
|
+
|
|
75
|
+
## 3. Plan
|
|
76
|
+
- For simple tasks (renaming, fixing a typo, adding a line): act directly.
|
|
77
|
+
- For moderate tasks (new function, bug fix): mentally outline the steps, then execute.
|
|
78
|
+
- For complex tasks (new feature, refactoring multiple files): explain your plan briefly to the user, then execute step by step.
|
|
38
79
|
|
|
39
|
-
|
|
80
|
+
## 4. Execute
|
|
81
|
+
- Make minimal, focused changes. Don't refactor code you weren't asked to change.
|
|
82
|
+
- Follow existing code style and patterns in the project.
|
|
83
|
+
- When editing a file, always read it first to get the exact content for precise edits.
|
|
40
84
|
|
|
41
|
-
|
|
85
|
+
## 5. Verify
|
|
86
|
+
- After making changes, verify them when possible:
|
|
87
|
+
- Run the build/compile command to check for errors.
|
|
88
|
+
- Run relevant tests if they exist.
|
|
89
|
+
- Read the changed file to confirm the edit looks correct.
|
|
90
|
+
- If verification fails, analyze the error and fix it. Don't just retry the same thing.
|
|
91
|
+
|
|
92
|
+
## Handling Errors
|
|
93
|
+
- When a tool call fails, read the error message carefully.
|
|
94
|
+
- Diagnose the root cause before retrying.
|
|
95
|
+
- If you're stuck after 2-3 attempts, explain the problem to the user and ask for guidance.
|
|
96
|
+
- Never brute-force by retrying the same failing command.`;
|
|
97
|
+
// ─── Section: Environment ───
|
|
98
|
+
function buildEnvironmentSection(env, projectPath) {
|
|
99
|
+
const parts = ["# Environment"];
|
|
100
|
+
if (projectPath) {
|
|
101
|
+
parts.push(`- **Working Directory:** ${projectPath}`);
|
|
102
|
+
}
|
|
103
|
+
if (env?.os) {
|
|
104
|
+
parts.push(`- **OS:** ${env.os}`);
|
|
105
|
+
}
|
|
106
|
+
if (env?.shell) {
|
|
107
|
+
parts.push(`- **Shell:** ${env.shell}`);
|
|
108
|
+
}
|
|
109
|
+
if (env?.nodeVersion) {
|
|
110
|
+
parts.push(`- **Node.js:** ${env.nodeVersion}`);
|
|
111
|
+
}
|
|
112
|
+
if (env?.gitBranch) {
|
|
113
|
+
parts.push(`- **Git Branch:** ${env.gitBranch}`);
|
|
114
|
+
}
|
|
115
|
+
return parts.join("\n");
|
|
116
|
+
}
|
|
117
|
+
// ─── Section: Project Context ───
|
|
42
118
|
function buildProjectSection(structure) {
|
|
43
|
-
return
|
|
119
|
+
return `# Project Context
|
|
44
120
|
|
|
45
121
|
- **Language:** ${structure.primaryLanguage}
|
|
46
122
|
- **Framework:** ${structure.framework}
|
|
@@ -48,37 +124,126 @@ function buildProjectSection(structure) {
|
|
|
48
124
|
- **Entry Point:** ${structure.entryPoint}
|
|
49
125
|
- **Total Files:** ${structure.fileCount}
|
|
50
126
|
|
|
51
|
-
|
|
127
|
+
## Project Structure
|
|
52
128
|
\`\`\`
|
|
53
129
|
${structure.treeView}
|
|
54
130
|
\`\`\``;
|
|
55
131
|
}
|
|
56
|
-
|
|
57
|
-
|
|
132
|
+
// ─── Section: Tool Strategy ───
|
|
133
|
+
function buildToolStrategySection(tools) {
|
|
134
|
+
const toolList = tools
|
|
58
135
|
.map((t) => {
|
|
59
136
|
const params = t.parameters.properties
|
|
60
137
|
? Object.keys(t.parameters.properties).join(", ")
|
|
61
|
-
: "
|
|
138
|
+
: "";
|
|
62
139
|
return `- **${t.name}**(${params}): ${t.description}`;
|
|
63
140
|
})
|
|
64
141
|
.join("\n");
|
|
65
|
-
return
|
|
142
|
+
return `# Tool Usage Strategy
|
|
66
143
|
|
|
67
|
-
You
|
|
144
|
+
You have the following tools available. Use them strategically — the right tool for the right job.
|
|
68
145
|
|
|
69
|
-
${
|
|
146
|
+
${toolList}
|
|
70
147
|
|
|
71
|
-
|
|
148
|
+
## Tool Usage Patterns
|
|
149
|
+
|
|
150
|
+
### Reading & Understanding Code
|
|
151
|
+
1. Use **glob** first to find files matching a pattern (e.g., \`*.ts\`, \`src/**/*.tsx\`).
|
|
152
|
+
2. Use **grep** to search for specific strings, function names, imports, or patterns.
|
|
153
|
+
3. Use **file_read** to read file contents. Always read a file before editing it.
|
|
154
|
+
4. Use **code_search** for finding symbol definitions, references, or usages.
|
|
155
|
+
|
|
156
|
+
### Making Changes
|
|
157
|
+
1. **Always read before edit.** Never edit a file you haven't read in this session.
|
|
158
|
+
2. Use **file_edit** for surgical changes — replacing specific strings with exact matches.
|
|
159
|
+
3. Use **file_write** only when creating new files or completely rewriting a file.
|
|
160
|
+
4. After editing, re-read the file to confirm the change is correct.
|
|
161
|
+
|
|
162
|
+
### Running Commands
|
|
163
|
+
1. Use **shell_exec** for build, test, lint, and other development commands.
|
|
164
|
+
2. Always check the exit code and stderr for errors.
|
|
165
|
+
3. Common patterns:
|
|
166
|
+
- Build check: \`shell_exec("tsc", ["--noEmit"])\` or \`shell_exec("npm", ["run", "build"])\`
|
|
167
|
+
- Test run: \`shell_exec("npm", ["test"])\` or \`shell_exec("npx", ["jest", "path/to/test"])\`
|
|
168
|
+
- Lint: \`shell_exec("npx", ["eslint", "src/"])\`
|
|
169
|
+
4. **Never use shell features** (pipes, redirects, &&). Pass executable and args separately.
|
|
170
|
+
|
|
171
|
+
### Git Operations
|
|
172
|
+
1. Use **git_ops** for status, diff, log, add, commit, branch operations.
|
|
173
|
+
2. Always check \`git_ops("status")\` before committing to see what's changed.
|
|
174
|
+
3. Write descriptive commit messages that explain the "why", not the "what".
|
|
175
|
+
|
|
176
|
+
### Search Strategy
|
|
177
|
+
- **Know the filename?** → Use \`glob\` with the pattern.
|
|
178
|
+
- **Know a string in the file?** → Use \`grep\` with the pattern.
|
|
179
|
+
- **Know a function/class name?** → Use \`code_search\` with mode "definition" or "reference".
|
|
180
|
+
- **Exploring an unfamiliar codebase?** → Start with \`glob("**/*.{ts,tsx}")\` then \`file_read\` key files.
|
|
181
|
+
|
|
182
|
+
## Anti-Patterns (Avoid These)
|
|
183
|
+
- Don't edit a file without reading it first.
|
|
184
|
+
- Don't grep for something, get results, then grep again for the same thing.
|
|
185
|
+
- Don't run a command that failed without changing something first.
|
|
186
|
+
- Don't write a whole file when you only need to change a few lines (use file_edit).
|
|
187
|
+
- Don't make multiple sequential edits to the same file — batch them if possible.`;
|
|
72
188
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
189
|
+
// ─── Section: Code Rules ───
|
|
190
|
+
const CODE_RULES = `# Code Quality Rules
|
|
191
|
+
|
|
192
|
+
## Making Changes
|
|
193
|
+
1. **Read before edit.** Understand the context before modifying.
|
|
194
|
+
2. **Minimal changes.** Only change what's necessary. Don't refactor surrounding code unless asked.
|
|
195
|
+
3. **Follow existing patterns.** Match the project's naming, formatting, and architecture conventions.
|
|
196
|
+
4. **Don't over-engineer.** The simplest correct solution is usually the best.
|
|
197
|
+
5. **Don't add extras.** No unrequested comments, docstrings, type annotations, error handling, or features.
|
|
198
|
+
|
|
199
|
+
## Code Style
|
|
200
|
+
- Match the existing code style exactly (indentation, quotes, semicolons, etc.).
|
|
201
|
+
- If the project uses tabs, use tabs. If it uses 2-space indent, use 2-space.
|
|
202
|
+
- Don't change formatting in lines you're not otherwise modifying.
|
|
203
|
+
|
|
204
|
+
## Dependencies
|
|
205
|
+
- Check if a dependency already exists before adding new ones.
|
|
206
|
+
- Prefer built-in language features over external libraries when reasonable.
|
|
207
|
+
- When adding dependencies, use the project's package manager (npm/pnpm/yarn).
|
|
208
|
+
|
|
209
|
+
## Testing
|
|
210
|
+
- If the project has tests, run them after making changes.
|
|
211
|
+
- If you're adding a new feature and the project has test patterns, consider adding tests.
|
|
212
|
+
- Don't break existing tests.`;
|
|
213
|
+
// ─── Section: Safety ───
|
|
214
|
+
const SAFETY_RULES = `# Safety Rules
|
|
215
|
+
|
|
216
|
+
## File Operations
|
|
217
|
+
1. Never modify files outside the project directory.
|
|
218
|
+
2. Never read, write, or expose files containing secrets (.env, credentials, API keys).
|
|
219
|
+
3. Create backups when overwriting important files.
|
|
220
|
+
4. Ask for approval before deleting files.
|
|
221
|
+
|
|
222
|
+
## Shell Commands
|
|
223
|
+
1. Never run destructive commands without user approval (rm -rf, drop database, etc.).
|
|
224
|
+
2. Never run interactive commands (editors, REPLs, sudo).
|
|
225
|
+
3. Always use specific executables with argument arrays — never construct shell strings.
|
|
226
|
+
4. Be cautious with commands that modify system state.
|
|
227
|
+
|
|
228
|
+
## Git Operations
|
|
229
|
+
1. Never force-push without explicit user approval.
|
|
230
|
+
2. Never push to main/master without user approval.
|
|
231
|
+
3. Prefer creating new commits over amending existing ones.
|
|
232
|
+
4. Don't skip pre-commit hooks.
|
|
233
|
+
|
|
234
|
+
## Secrets & Privacy
|
|
235
|
+
1. Never include API keys, passwords, tokens, or credentials in your responses.
|
|
236
|
+
2. If you encounter secrets in code, warn the user and suggest moving them to environment variables.
|
|
237
|
+
3. Never log or expose sensitive information.`;
|
|
238
|
+
// ─── Section: Output Style ───
|
|
239
|
+
const OUTPUT_STYLE = `# Communication Style
|
|
240
|
+
|
|
241
|
+
- Be concise. Lead with the action or answer, not the reasoning.
|
|
242
|
+
- For simple tasks, just do them and briefly report what you did.
|
|
243
|
+
- For complex tasks, briefly state your plan, execute, then summarize.
|
|
244
|
+
- When reporting changes, list the files changed and what was done.
|
|
245
|
+
- If something goes wrong, explain the error clearly and what you'll try next.
|
|
246
|
+
- Don't apologize unnecessarily. Don't use filler phrases.
|
|
247
|
+
- Use code blocks for file paths, commands, and code snippets.
|
|
248
|
+
- When you're done with a task, provide a clear summary of all changes made.`;
|
|
84
249
|
//# sourceMappingURL=system-prompt.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../src/system-prompt.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../src/system-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA6BH;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAA4B;IAC5D,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,yBAAyB;IACzB,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAE9B,aAAa;IACb,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAEhC,WAAW;IACX,IAAI,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;QAC/C,QAAQ,CAAC,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;IACnF,CAAC;IAED,eAAe;IACf,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;QAC7B,QAAQ,CAAC,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED,2BAA2B;IAC3B,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;QAC1B,QAAQ,CAAC,IAAI,CACX,mKAAmK,OAAO,CAAC,aAAa,EAAE,CAC3L,CAAC;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B;AAE9B,MAAM,UAAU,GAAG;;;;;;;;;;;;;;;;;;;;;;8BAsBW,CAAC;AAE/B,0BAA0B;AAE1B,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;8CAuByB,CAAC;AAE/C,gCAAgC;AAEhC,MAAM,YAAY,GAAG;;;;;;;;;6EASwD,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module task-classifier
|
|
3
|
+
* @description 사용자 입력을 태스크 유형으로 분류하고, 최적 도구 시퀀스를 매핑한다.
|
|
4
|
+
* 하드코딩된 도구 순서를 지능적 분류로 대체.
|
|
5
|
+
*/
|
|
6
|
+
import type { BYOKClient } from "./llm-client.js";
|
|
7
|
+
/** 태스크 유형 */
|
|
8
|
+
export declare enum TaskType {
|
|
9
|
+
DEBUG = "debug",
|
|
10
|
+
FEATURE = "feature",
|
|
11
|
+
REFACTOR = "refactor",
|
|
12
|
+
TEST = "test",
|
|
13
|
+
EXPLAIN = "explain",
|
|
14
|
+
SEARCH = "search",
|
|
15
|
+
CONFIG = "config",
|
|
16
|
+
DEPLOY = "deploy"
|
|
17
|
+
}
|
|
18
|
+
/** 태스크 분류 결과 */
|
|
19
|
+
export interface TaskClassification {
|
|
20
|
+
/** 분류된 태스크 유형 */
|
|
21
|
+
type: TaskType;
|
|
22
|
+
/** 분류 신뢰도 (0–1) */
|
|
23
|
+
confidence: number;
|
|
24
|
+
/** 최적 도구 실행 순서 */
|
|
25
|
+
toolSequence: string[];
|
|
26
|
+
/** 우선 읽어야 할 파일/패턴 힌트 */
|
|
27
|
+
contextHints: string[];
|
|
28
|
+
/** 예상 복잡도 */
|
|
29
|
+
estimatedComplexity: "trivial" | "simple" | "moderate" | "complex";
|
|
30
|
+
/** grep/glob에 사용할 검색 패턴 */
|
|
31
|
+
searchPatterns?: string[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 사용자 입력을 태스크 유형으로 분류하고 최적 도구 시퀀스를 매핑하는 분류기.
|
|
35
|
+
*
|
|
36
|
+
* 두 가지 모드:
|
|
37
|
+
* 1. `classify()` — 키워드 기반 휴리스틱 (LLM 호출 없이 빠름)
|
|
38
|
+
* 2. `classifyWithLLM()` — LLM 강화 분류 (모호한 경우)
|
|
39
|
+
*/
|
|
40
|
+
export declare class TaskClassifier {
|
|
41
|
+
/**
|
|
42
|
+
* 휴리스틱 기반 태스크 분류 (LLM 호출 없음, 빠름).
|
|
43
|
+
*
|
|
44
|
+
* @param message - 사용자 입력 메시지
|
|
45
|
+
* @param projectContext - 프로젝트 컨텍스트 (선택, 예: 파일 구조 요약)
|
|
46
|
+
* @returns 태스크 분류 결과
|
|
47
|
+
*/
|
|
48
|
+
classify(message: string, projectContext?: string): TaskClassification;
|
|
49
|
+
/**
|
|
50
|
+
* LLM 강화 태스크 분류 (모호한 경우 사용).
|
|
51
|
+
*
|
|
52
|
+
* @param message - 사용자 입력 메시지
|
|
53
|
+
* @param llmClient - BYOK LLM 클라이언트
|
|
54
|
+
* @returns 태스크 분류 결과
|
|
55
|
+
*/
|
|
56
|
+
classifyWithLLM(message: string, llmClient: BYOKClient): Promise<TaskClassification>;
|
|
57
|
+
/**
|
|
58
|
+
* 태스크 유형에 대한 최적 도구 실행 순서를 반환한다.
|
|
59
|
+
*
|
|
60
|
+
* @param type - 태스크 유형
|
|
61
|
+
* @returns 도구 이름 배열 (실행 순서)
|
|
62
|
+
*/
|
|
63
|
+
getToolSequence(type: TaskType): string[];
|
|
64
|
+
/**
|
|
65
|
+
* 분류 결과를 시스템 프롬프트 주입용 문자열로 포맷한다.
|
|
66
|
+
*
|
|
67
|
+
* @param classification - 태스크 분류 결과
|
|
68
|
+
* @returns 시스템 프롬프트에 삽입할 문자열
|
|
69
|
+
*/
|
|
70
|
+
formatForSystemPrompt(classification: TaskClassification): string;
|
|
71
|
+
/**
|
|
72
|
+
* 프로젝트 컨텍스트를 기반으로 점수를 보정한다.
|
|
73
|
+
*/
|
|
74
|
+
private applyContextBoost;
|
|
75
|
+
/**
|
|
76
|
+
* 1위와 2위 점수 차이를 기반으로 신뢰도를 계산한다.
|
|
77
|
+
*/
|
|
78
|
+
private calculateConfidence;
|
|
79
|
+
/**
|
|
80
|
+
* 메시지 복잡도 시그널을 기반으로 복잡도를 추정한다.
|
|
81
|
+
*/
|
|
82
|
+
private estimateComplexity;
|
|
83
|
+
/**
|
|
84
|
+
* 태스크 유형 및 메시지 내용을 기반으로 컨텍스트 힌트를 생성한다.
|
|
85
|
+
*/
|
|
86
|
+
private generateContextHints;
|
|
87
|
+
/**
|
|
88
|
+
* LLM 응답 JSON을 파싱하여 분류 결과로 변환한다.
|
|
89
|
+
*/
|
|
90
|
+
private parseLLMClassification;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=task-classifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-classifier.d.ts","sourceRoot":"","sources":["../src/task-classifier.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAIlD,aAAa;AACb,oBAAY,QAAQ;IAClB,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,QAAQ,aAAa;IACrB,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB;AAID,gBAAgB;AAChB,MAAM,WAAW,kBAAkB;IACjC,iBAAiB;IACjB,IAAI,EAAE,QAAQ,CAAC;IACf,mBAAmB;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB;IAClB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,wBAAwB;IACxB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,aAAa;IACb,mBAAmB,EAAE,SAAS,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;IACnE,2BAA2B;IAC3B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;C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