@yuaone/core 0.1.3 → 0.3.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 +152 -0
- package/dist/agent-loop.d.ts.map +1 -1
- package/dist/agent-loop.js +893 -9
- package/dist/agent-loop.js.map +1 -1
- package/dist/benchmark-runner.d.ts +141 -0
- package/dist/benchmark-runner.d.ts.map +1 -0
- package/dist/benchmark-runner.js +526 -0
- package/dist/benchmark-runner.js.map +1 -0
- package/dist/codebase-context.d.ts +49 -0
- package/dist/codebase-context.d.ts.map +1 -1
- package/dist/codebase-context.js +146 -0
- package/dist/codebase-context.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/cost-optimizer.d.ts +159 -0
- package/dist/cost-optimizer.d.ts.map +1 -0
- package/dist/cost-optimizer.js +406 -0
- package/dist/cost-optimizer.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/execution-policy-engine.d.ts +133 -0
- package/dist/execution-policy-engine.d.ts.map +1 -0
- package/dist/execution-policy-engine.js +367 -0
- package/dist/execution-policy-engine.js.map +1 -0
- package/dist/failure-recovery.d.ts +228 -0
- package/dist/failure-recovery.d.ts.map +1 -0
- package/dist/failure-recovery.js +664 -0
- package/dist/failure-recovery.js.map +1 -0
- package/dist/hierarchical-planner.d.ts +69 -1
- package/dist/hierarchical-planner.d.ts.map +1 -1
- package/dist/hierarchical-planner.js +117 -0
- package/dist/hierarchical-planner.js.map +1 -1
- package/dist/impact-analyzer.d.ts +92 -0
- package/dist/impact-analyzer.d.ts.map +1 -0
- package/dist/impact-analyzer.js +615 -0
- package/dist/impact-analyzer.js.map +1 -0
- package/dist/index.d.ts +28 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -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/dist/world-state.d.ts +87 -0
- package/dist/world-state.d.ts.map +1 -0
- package/dist/world-state.js +435 -0
- package/dist/world-state.js.map +1 -0
- package/package.json +11 -21
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module reflexion
|
|
3
|
+
* @description Reflexion Layer — structured self-reflection after each agent run.
|
|
4
|
+
*
|
|
5
|
+
* Based on the Reflexion paper (Shinn et al., 2023):
|
|
6
|
+
* dynamic memory + self-reflection loop for continuous improvement.
|
|
7
|
+
*
|
|
8
|
+
* Key design decisions:
|
|
9
|
+
* - `reflect()` is purely heuristic (no LLM calls) — analyzes tool results, counts failures, detects patterns
|
|
10
|
+
* - `getGuidance()` uses keyword matching to find relevant past reflections
|
|
11
|
+
* - Strategy confidence decays over time (0.95 per week)
|
|
12
|
+
* - File-based persistence in `.yuan/memory/`
|
|
13
|
+
* - Max 100 reflections (FIFO), max 50 strategies
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const engine = new ReflexionEngine({ projectPath: "/my/project" });
|
|
18
|
+
*
|
|
19
|
+
* // After a run
|
|
20
|
+
* const entry = engine.reflect({ goal, runId, termination, toolResults, ... });
|
|
21
|
+
* await engine.store.saveReflection(entry);
|
|
22
|
+
*
|
|
23
|
+
* // Before a run
|
|
24
|
+
* const guidance = await engine.getGuidance("fix the auth middleware");
|
|
25
|
+
* const prompt = engine.formatForSystemPrompt(guidance);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
import { readFile, writeFile, mkdir, rename } from "node:fs/promises";
|
|
29
|
+
import { join } from "node:path";
|
|
30
|
+
import { randomUUID } from "node:crypto";
|
|
31
|
+
// ─── Constants ───
|
|
32
|
+
const DEFAULT_MAX_REFLECTIONS = 100;
|
|
33
|
+
const DEFAULT_MAX_STRATEGIES = 50;
|
|
34
|
+
const DEFAULT_CONFIDENCE_DECAY = 0.95;
|
|
35
|
+
const MS_PER_WEEK = 7 * 24 * 60 * 60 * 1000;
|
|
36
|
+
const REFLECTIONS_FILE = "reflections.json";
|
|
37
|
+
const STRATEGIES_FILE = "strategies.json";
|
|
38
|
+
// ─── ReflexionStore ───
|
|
39
|
+
/**
|
|
40
|
+
* File-based persistence for reflections and strategies.
|
|
41
|
+
*
|
|
42
|
+
* Storage location: `<projectPath>/.yuan/memory/`
|
|
43
|
+
*/
|
|
44
|
+
export class ReflexionStore {
|
|
45
|
+
memoryDir;
|
|
46
|
+
constructor(projectPath) {
|
|
47
|
+
this.memoryDir = join(projectPath, ".yuan", "memory");
|
|
48
|
+
}
|
|
49
|
+
// ─── Reflection CRUD ───
|
|
50
|
+
/** Save a reflection entry. Appends to the list. */
|
|
51
|
+
async saveReflection(entry) {
|
|
52
|
+
const entries = await this.loadReflectionsFile();
|
|
53
|
+
entries.push(entry);
|
|
54
|
+
// FIFO: keep only last maxReflections (caller can prune, but we cap at a safe limit)
|
|
55
|
+
if (entries.length > DEFAULT_MAX_REFLECTIONS * 2) {
|
|
56
|
+
entries.splice(0, entries.length - DEFAULT_MAX_REFLECTIONS);
|
|
57
|
+
}
|
|
58
|
+
await this.writeJsonFile(REFLECTIONS_FILE, entries);
|
|
59
|
+
}
|
|
60
|
+
/** Get most recent reflections, optionally limited. */
|
|
61
|
+
async getReflections(limit) {
|
|
62
|
+
const entries = await this.loadReflectionsFile();
|
|
63
|
+
if (limit !== undefined && limit > 0) {
|
|
64
|
+
return entries.slice(-limit);
|
|
65
|
+
}
|
|
66
|
+
return entries;
|
|
67
|
+
}
|
|
68
|
+
/** Get reflections filtered by outcome. */
|
|
69
|
+
async getReflectionsByOutcome(outcome) {
|
|
70
|
+
const entries = await this.loadReflectionsFile();
|
|
71
|
+
return entries.filter((e) => e.outcome === outcome);
|
|
72
|
+
}
|
|
73
|
+
// ─── Strategy management ───
|
|
74
|
+
/** Save or update a strategy record. */
|
|
75
|
+
async saveStrategy(strategy) {
|
|
76
|
+
const strategies = await this.loadStrategiesFile();
|
|
77
|
+
const existingIdx = strategies.findIndex((s) => s.id === strategy.id);
|
|
78
|
+
if (existingIdx >= 0) {
|
|
79
|
+
strategies[existingIdx] = strategy;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
strategies.push(strategy);
|
|
83
|
+
}
|
|
84
|
+
// Cap at a safe limit
|
|
85
|
+
if (strategies.length > DEFAULT_MAX_STRATEGIES * 2) {
|
|
86
|
+
// Remove lowest confidence
|
|
87
|
+
strategies.sort((a, b) => b.confidence - a.confidence);
|
|
88
|
+
strategies.length = DEFAULT_MAX_STRATEGIES;
|
|
89
|
+
}
|
|
90
|
+
await this.writeJsonFile(STRATEGIES_FILE, strategies);
|
|
91
|
+
}
|
|
92
|
+
/** Find strategies relevant to a goal using keyword matching. */
|
|
93
|
+
async findRelevantStrategies(goal, limit) {
|
|
94
|
+
const strategies = await this.loadStrategiesFile();
|
|
95
|
+
const keywords = extractKeywords(goal);
|
|
96
|
+
const maxResults = limit ?? 5;
|
|
97
|
+
const scored = strategies.map((s) => {
|
|
98
|
+
let score = 0;
|
|
99
|
+
// Check taskPattern as regex or keywords
|
|
100
|
+
try {
|
|
101
|
+
const re = new RegExp(s.taskPattern, "i");
|
|
102
|
+
if (re.test(goal))
|
|
103
|
+
score += 10;
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
// If not valid regex, treat as keywords
|
|
107
|
+
const patternWords = extractKeywords(s.taskPattern);
|
|
108
|
+
const overlap = patternWords.filter((pw) => keywords.includes(pw)).length;
|
|
109
|
+
score += overlap * 3;
|
|
110
|
+
}
|
|
111
|
+
// Check examples
|
|
112
|
+
for (const example of s.examples) {
|
|
113
|
+
const exWords = extractKeywords(example);
|
|
114
|
+
const overlap = exWords.filter((ew) => keywords.includes(ew)).length;
|
|
115
|
+
score += overlap;
|
|
116
|
+
}
|
|
117
|
+
// Weight by confidence
|
|
118
|
+
score *= s.confidence;
|
|
119
|
+
return { strategy: s, score };
|
|
120
|
+
});
|
|
121
|
+
return scored
|
|
122
|
+
.filter((s) => s.score > 0)
|
|
123
|
+
.sort((a, b) => b.score - a.score)
|
|
124
|
+
.slice(0, maxResults)
|
|
125
|
+
.map((s) => s.strategy);
|
|
126
|
+
}
|
|
127
|
+
/** Update success/failure stats for a strategy. */
|
|
128
|
+
async updateStrategyStats(strategyId, success) {
|
|
129
|
+
const strategies = await this.loadStrategiesFile();
|
|
130
|
+
const strategy = strategies.find((s) => s.id === strategyId);
|
|
131
|
+
if (!strategy)
|
|
132
|
+
return;
|
|
133
|
+
if (success) {
|
|
134
|
+
strategy.successCount++;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
strategy.failureCount++;
|
|
138
|
+
}
|
|
139
|
+
strategy.confidence =
|
|
140
|
+
strategy.successCount / (strategy.successCount + strategy.failureCount);
|
|
141
|
+
strategy.lastUsed = Date.now();
|
|
142
|
+
await this.writeJsonFile(STRATEGIES_FILE, strategies);
|
|
143
|
+
}
|
|
144
|
+
// ─── Cleanup ───
|
|
145
|
+
/** Remove reflections older than maxAge (ms). Returns count removed. */
|
|
146
|
+
async pruneOldReflections(maxAge) {
|
|
147
|
+
const entries = await this.loadReflectionsFile();
|
|
148
|
+
const cutoff = Date.now() - maxAge;
|
|
149
|
+
const filtered = entries.filter((e) => e.timestamp > cutoff);
|
|
150
|
+
const removed = entries.length - filtered.length;
|
|
151
|
+
if (removed > 0) {
|
|
152
|
+
await this.writeJsonFile(REFLECTIONS_FILE, filtered);
|
|
153
|
+
}
|
|
154
|
+
return removed;
|
|
155
|
+
}
|
|
156
|
+
// ─── Private I/O ───
|
|
157
|
+
async ensureDir() {
|
|
158
|
+
await mkdir(this.memoryDir, { recursive: true });
|
|
159
|
+
}
|
|
160
|
+
async readJsonFile(filename) {
|
|
161
|
+
try {
|
|
162
|
+
const raw = await readFile(join(this.memoryDir, filename), "utf-8");
|
|
163
|
+
return JSON.parse(raw);
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
async writeJsonFile(filename, data) {
|
|
170
|
+
await this.ensureDir();
|
|
171
|
+
const filePath = join(this.memoryDir, filename);
|
|
172
|
+
const tmpPath = filePath + ".tmp";
|
|
173
|
+
await writeFile(tmpPath, JSON.stringify(data, null, 2), "utf-8");
|
|
174
|
+
await rename(tmpPath, filePath);
|
|
175
|
+
}
|
|
176
|
+
async loadReflectionsFile() {
|
|
177
|
+
return (await this.readJsonFile(REFLECTIONS_FILE)) ?? [];
|
|
178
|
+
}
|
|
179
|
+
async loadStrategiesFile() {
|
|
180
|
+
return (await this.readJsonFile(STRATEGIES_FILE)) ?? [];
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* ReflexionEngine — heuristic-based self-reflection after agent runs.
|
|
185
|
+
*
|
|
186
|
+
* No LLM calls. Analyzes tool results, detects failure patterns,
|
|
187
|
+
* extracts strategies from successful runs, and provides guidance
|
|
188
|
+
* for future runs.
|
|
189
|
+
*/
|
|
190
|
+
export class ReflexionEngine {
|
|
191
|
+
store;
|
|
192
|
+
maxReflections;
|
|
193
|
+
maxStrategies;
|
|
194
|
+
confidenceDecayPerWeek;
|
|
195
|
+
constructor(config) {
|
|
196
|
+
this.store = new ReflexionStore(config.projectPath);
|
|
197
|
+
this.maxReflections = config.maxReflections ?? DEFAULT_MAX_REFLECTIONS;
|
|
198
|
+
this.maxStrategies = config.maxStrategies ?? DEFAULT_MAX_STRATEGIES;
|
|
199
|
+
this.confidenceDecayPerWeek = config.confidenceDecayPerWeek ?? DEFAULT_CONFIDENCE_DECAY;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* After an agent run: analyze what happened and produce a ReflexionEntry.
|
|
203
|
+
*
|
|
204
|
+
* Purely heuristic — no LLM call. Analyzes:
|
|
205
|
+
* - Tool success/failure rates
|
|
206
|
+
* - Error patterns
|
|
207
|
+
* - Termination reason
|
|
208
|
+
* - Duration and resource usage
|
|
209
|
+
*/
|
|
210
|
+
reflect(params) {
|
|
211
|
+
const { goal, runId, termination, toolResults, messages, tokensUsed, durationMs, changedFiles, } = params;
|
|
212
|
+
// ── Determine outcome ──
|
|
213
|
+
const outcome = this.determineOutcome(termination, toolResults);
|
|
214
|
+
const terminationReason = termination.reason;
|
|
215
|
+
// ── Analyze tools ──
|
|
216
|
+
const toolAnalysis = this.analyzeTools(toolResults);
|
|
217
|
+
// ── Build reflection ──
|
|
218
|
+
const reflection = this.buildReflection(outcome, termination, toolResults, toolAnalysis, messages);
|
|
219
|
+
// ── Count iterations from messages ──
|
|
220
|
+
const iterations = messages.filter((m) => m.role === "assistant").length;
|
|
221
|
+
return {
|
|
222
|
+
id: randomUUID(),
|
|
223
|
+
runId,
|
|
224
|
+
timestamp: Date.now(),
|
|
225
|
+
goal,
|
|
226
|
+
outcome,
|
|
227
|
+
terminationReason,
|
|
228
|
+
reflection,
|
|
229
|
+
toolAnalysis,
|
|
230
|
+
metrics: {
|
|
231
|
+
iterations,
|
|
232
|
+
tokensUsed,
|
|
233
|
+
durationMs,
|
|
234
|
+
filesChanged: changedFiles,
|
|
235
|
+
},
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Before an agent run: retrieve relevant past reflections for context injection.
|
|
240
|
+
*
|
|
241
|
+
* Searches reflections and strategies by keyword matching against the goal.
|
|
242
|
+
*/
|
|
243
|
+
async getGuidance(goal) {
|
|
244
|
+
const keywords = extractKeywords(goal);
|
|
245
|
+
// Find relevant strategies (with time-decayed confidence)
|
|
246
|
+
const rawStrategies = await this.store.findRelevantStrategies(goal, 5);
|
|
247
|
+
const relevantStrategies = rawStrategies.map((s) => this.applyConfidenceDecay(s));
|
|
248
|
+
// Find recent failures on similar goals
|
|
249
|
+
const allReflections = await this.store.getReflections();
|
|
250
|
+
const recentFailures = allReflections
|
|
251
|
+
.filter((r) => {
|
|
252
|
+
if (r.outcome === "success")
|
|
253
|
+
return false;
|
|
254
|
+
const rKeywords = extractKeywords(r.goal);
|
|
255
|
+
return keywords.some((kw) => rKeywords.includes(kw));
|
|
256
|
+
})
|
|
257
|
+
.slice(-5); // Last 5 relevant failures
|
|
258
|
+
// Extract avoid patterns from failures
|
|
259
|
+
const avoidPatterns = [];
|
|
260
|
+
for (const failure of recentFailures) {
|
|
261
|
+
for (const failed of failure.reflection.whatFailed) {
|
|
262
|
+
if (!avoidPatterns.includes(failed)) {
|
|
263
|
+
avoidPatterns.push(failed);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
if (failure.reflection.rootCause) {
|
|
267
|
+
const rc = `Root cause: ${failure.reflection.rootCause}`;
|
|
268
|
+
if (!avoidPatterns.includes(rc)) {
|
|
269
|
+
avoidPatterns.push(rc);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
// Suggest approach from best strategy
|
|
274
|
+
let suggestedApproach = null;
|
|
275
|
+
if (relevantStrategies.length > 0) {
|
|
276
|
+
const best = relevantStrategies[0];
|
|
277
|
+
if (best.confidence >= 0.5) {
|
|
278
|
+
suggestedApproach = best.strategy;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return {
|
|
282
|
+
relevantStrategies,
|
|
283
|
+
recentFailures,
|
|
284
|
+
avoidPatterns,
|
|
285
|
+
suggestedApproach,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Extract a StrategyRecord from a successful run.
|
|
290
|
+
*
|
|
291
|
+
* Only creates a strategy if the run used 3+ tool calls (nontrivial).
|
|
292
|
+
*/
|
|
293
|
+
extractStrategy(entry, goal) {
|
|
294
|
+
// Only extract from successful or partially successful runs
|
|
295
|
+
if (entry.outcome === "failure")
|
|
296
|
+
return null;
|
|
297
|
+
// Require at least 3 tool calls for a meaningful strategy
|
|
298
|
+
if (entry.toolAnalysis.totalCalls < 3)
|
|
299
|
+
return null;
|
|
300
|
+
// Build tool sequence (unique, in order of first appearance)
|
|
301
|
+
const toolSequence = entry.toolAnalysis.toolsUsed;
|
|
302
|
+
// Build strategy description from what worked
|
|
303
|
+
const strategyParts = entry.reflection.whatWorked;
|
|
304
|
+
if (strategyParts.length === 0)
|
|
305
|
+
return null;
|
|
306
|
+
const strategy = strategyParts.join("; ");
|
|
307
|
+
// Extract task pattern: take significant keywords from goal
|
|
308
|
+
const keywords = extractKeywords(goal);
|
|
309
|
+
const taskPattern = keywords.slice(0, 5).join("|");
|
|
310
|
+
if (!taskPattern)
|
|
311
|
+
return null;
|
|
312
|
+
return {
|
|
313
|
+
id: randomUUID(),
|
|
314
|
+
taskPattern,
|
|
315
|
+
strategy,
|
|
316
|
+
toolSequence,
|
|
317
|
+
successCount: 1,
|
|
318
|
+
failureCount: 0,
|
|
319
|
+
confidence: 1.0,
|
|
320
|
+
lastUsed: Date.now(),
|
|
321
|
+
examples: [goal],
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Format guidance for injection into a system prompt.
|
|
326
|
+
*
|
|
327
|
+
* Returns empty string if no relevant guidance found.
|
|
328
|
+
*/
|
|
329
|
+
formatForSystemPrompt(guidance) {
|
|
330
|
+
const sections = [];
|
|
331
|
+
if (guidance.relevantStrategies.length === 0 &&
|
|
332
|
+
guidance.recentFailures.length === 0 &&
|
|
333
|
+
guidance.avoidPatterns.length === 0) {
|
|
334
|
+
return "";
|
|
335
|
+
}
|
|
336
|
+
sections.push("<reflexion-guidance>");
|
|
337
|
+
// Suggested approach
|
|
338
|
+
if (guidance.suggestedApproach) {
|
|
339
|
+
sections.push(`<suggested-approach>${guidance.suggestedApproach}</suggested-approach>`);
|
|
340
|
+
}
|
|
341
|
+
// Proven strategies
|
|
342
|
+
if (guidance.relevantStrategies.length > 0) {
|
|
343
|
+
sections.push("<proven-strategies>");
|
|
344
|
+
for (const s of guidance.relevantStrategies) {
|
|
345
|
+
const conf = (s.confidence * 100).toFixed(0);
|
|
346
|
+
sections.push(`- [${conf}% confidence] ${s.strategy} (tools: ${s.toolSequence.join(" → ")})`);
|
|
347
|
+
}
|
|
348
|
+
sections.push("</proven-strategies>");
|
|
349
|
+
}
|
|
350
|
+
// Avoid patterns
|
|
351
|
+
if (guidance.avoidPatterns.length > 0) {
|
|
352
|
+
sections.push("<avoid-patterns>");
|
|
353
|
+
for (const p of guidance.avoidPatterns) {
|
|
354
|
+
sections.push(`- ${p}`);
|
|
355
|
+
}
|
|
356
|
+
sections.push("</avoid-patterns>");
|
|
357
|
+
}
|
|
358
|
+
// Recent failures
|
|
359
|
+
if (guidance.recentFailures.length > 0) {
|
|
360
|
+
sections.push("<recent-failures>");
|
|
361
|
+
for (const f of guidance.recentFailures) {
|
|
362
|
+
const rootCause = f.reflection.rootCause
|
|
363
|
+
? ` (root cause: ${f.reflection.rootCause})`
|
|
364
|
+
: "";
|
|
365
|
+
sections.push(`- Goal: "${f.goal}" → ${f.outcome}${rootCause}`);
|
|
366
|
+
}
|
|
367
|
+
sections.push("</recent-failures>");
|
|
368
|
+
}
|
|
369
|
+
sections.push("</reflexion-guidance>");
|
|
370
|
+
return sections.join("\n");
|
|
371
|
+
}
|
|
372
|
+
// ─── Private helpers ───
|
|
373
|
+
/** Determine outcome from termination reason and tool results */
|
|
374
|
+
determineOutcome(termination, toolResults) {
|
|
375
|
+
switch (termination.reason) {
|
|
376
|
+
case "GOAL_ACHIEVED":
|
|
377
|
+
return "success";
|
|
378
|
+
case "ERROR":
|
|
379
|
+
return "failure";
|
|
380
|
+
case "USER_CANCELLED":
|
|
381
|
+
// If some tools succeeded, it's partial
|
|
382
|
+
return toolResults.some((r) => r.success) ? "partial" : "failure";
|
|
383
|
+
case "MAX_ITERATIONS":
|
|
384
|
+
case "BUDGET_EXHAUSTED":
|
|
385
|
+
// If some tools succeeded and files were changed, partial
|
|
386
|
+
return toolResults.some((r) => r.success) ? "partial" : "failure";
|
|
387
|
+
case "NEEDS_APPROVAL":
|
|
388
|
+
return "partial";
|
|
389
|
+
default:
|
|
390
|
+
return "failure";
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
/** Analyze tool usage from results */
|
|
394
|
+
analyzeTools(toolResults) {
|
|
395
|
+
if (toolResults.length === 0) {
|
|
396
|
+
return {
|
|
397
|
+
toolsUsed: [],
|
|
398
|
+
failedTools: [],
|
|
399
|
+
successRate: 0,
|
|
400
|
+
totalCalls: 0,
|
|
401
|
+
avgDurationMs: 0,
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
// Unique tools in order of first appearance
|
|
405
|
+
const toolsUsed = [];
|
|
406
|
+
for (const r of toolResults) {
|
|
407
|
+
if (!toolsUsed.includes(r.name)) {
|
|
408
|
+
toolsUsed.push(r.name);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
// Failed tools aggregation
|
|
412
|
+
const failMap = new Map();
|
|
413
|
+
for (const r of toolResults) {
|
|
414
|
+
if (!r.success) {
|
|
415
|
+
const existing = failMap.get(r.name);
|
|
416
|
+
if (existing) {
|
|
417
|
+
existing.count++;
|
|
418
|
+
}
|
|
419
|
+
else {
|
|
420
|
+
failMap.set(r.name, {
|
|
421
|
+
error: truncate(r.output, 200),
|
|
422
|
+
count: 1,
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
const failedTools = Array.from(failMap.entries()).map(([tool, info]) => ({
|
|
428
|
+
tool,
|
|
429
|
+
error: info.error,
|
|
430
|
+
count: info.count,
|
|
431
|
+
}));
|
|
432
|
+
const successCount = toolResults.filter((r) => r.success).length;
|
|
433
|
+
const successRate = successCount / toolResults.length;
|
|
434
|
+
const totalDuration = toolResults.reduce((sum, r) => sum + r.durationMs, 0);
|
|
435
|
+
const avgDurationMs = Math.round(totalDuration / toolResults.length);
|
|
436
|
+
return {
|
|
437
|
+
toolsUsed,
|
|
438
|
+
failedTools,
|
|
439
|
+
successRate,
|
|
440
|
+
totalCalls: toolResults.length,
|
|
441
|
+
avgDurationMs,
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
/** Build reflection heuristically from run data */
|
|
445
|
+
buildReflection(outcome, termination, toolResults, toolAnalysis, _messages) {
|
|
446
|
+
const whatWorked = [];
|
|
447
|
+
const whatFailed = [];
|
|
448
|
+
let rootCause = null;
|
|
449
|
+
let alternativeApproach = null;
|
|
450
|
+
// ── What worked ──
|
|
451
|
+
// Successful tools
|
|
452
|
+
const successfulTools = new Set();
|
|
453
|
+
for (const r of toolResults) {
|
|
454
|
+
if (r.success)
|
|
455
|
+
successfulTools.add(r.name);
|
|
456
|
+
}
|
|
457
|
+
if (successfulTools.size > 0) {
|
|
458
|
+
whatWorked.push(`Tools succeeded: ${[...successfulTools].join(", ")}`);
|
|
459
|
+
}
|
|
460
|
+
// High success rate
|
|
461
|
+
if (toolAnalysis.successRate >= 0.8 && toolAnalysis.totalCalls >= 3) {
|
|
462
|
+
whatWorked.push("High tool success rate (>=80%)");
|
|
463
|
+
}
|
|
464
|
+
// Fast execution
|
|
465
|
+
if (toolAnalysis.avgDurationMs < 500 && toolAnalysis.totalCalls > 0) {
|
|
466
|
+
whatWorked.push("Fast tool execution (<500ms avg)");
|
|
467
|
+
}
|
|
468
|
+
if (outcome === "success") {
|
|
469
|
+
whatWorked.push("Goal achieved successfully");
|
|
470
|
+
}
|
|
471
|
+
// ── What failed ──
|
|
472
|
+
// Failed tools
|
|
473
|
+
for (const ft of toolAnalysis.failedTools) {
|
|
474
|
+
whatFailed.push(`Tool "${ft.tool}" failed ${ft.count} time(s): ${ft.error}`);
|
|
475
|
+
}
|
|
476
|
+
// Low success rate
|
|
477
|
+
if (toolAnalysis.successRate < 0.5 && toolAnalysis.totalCalls >= 3) {
|
|
478
|
+
whatFailed.push("Low tool success rate (<50%)");
|
|
479
|
+
}
|
|
480
|
+
// Repeated failures on same tool
|
|
481
|
+
const repeatedFailures = toolAnalysis.failedTools.filter((ft) => ft.count >= 3);
|
|
482
|
+
if (repeatedFailures.length > 0) {
|
|
483
|
+
whatFailed.push(`Repeated failures: ${repeatedFailures.map((f) => f.tool).join(", ")}`);
|
|
484
|
+
}
|
|
485
|
+
// ── Root cause analysis ──
|
|
486
|
+
switch (termination.reason) {
|
|
487
|
+
case "ERROR":
|
|
488
|
+
rootCause = `Error: ${termination.error}`;
|
|
489
|
+
alternativeApproach =
|
|
490
|
+
"Consider breaking the task into smaller steps or using different tools";
|
|
491
|
+
break;
|
|
492
|
+
case "MAX_ITERATIONS":
|
|
493
|
+
rootCause = "Ran out of iterations — task may be too complex or agent got stuck in a loop";
|
|
494
|
+
alternativeApproach =
|
|
495
|
+
"Break task into smaller sub-goals; check for infinite retry loops";
|
|
496
|
+
break;
|
|
497
|
+
case "BUDGET_EXHAUSTED":
|
|
498
|
+
rootCause = `Token budget exhausted (${termination.tokensUsed} tokens used)`;
|
|
499
|
+
alternativeApproach =
|
|
500
|
+
"Use more focused context; avoid reading large files; use grep instead of reading entire files";
|
|
501
|
+
break;
|
|
502
|
+
case "USER_CANCELLED":
|
|
503
|
+
rootCause = "User cancelled the run";
|
|
504
|
+
break;
|
|
505
|
+
case "NEEDS_APPROVAL":
|
|
506
|
+
rootCause = "Blocked on approval — consider auto-approve for low-risk actions";
|
|
507
|
+
break;
|
|
508
|
+
}
|
|
509
|
+
// Additional heuristic: if many tool failures are the same error
|
|
510
|
+
if (toolAnalysis.failedTools.length > 0) {
|
|
511
|
+
const topFailure = toolAnalysis.failedTools.reduce((max, ft) => (ft.count > max.count ? ft : max), toolAnalysis.failedTools[0]);
|
|
512
|
+
if (topFailure.count >= 3 && !rootCause) {
|
|
513
|
+
rootCause = `Tool "${topFailure.tool}" repeatedly failed: ${topFailure.error}`;
|
|
514
|
+
alternativeApproach = `Avoid "${topFailure.tool}" or fix the underlying issue before retrying`;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
return { whatWorked, whatFailed, rootCause, alternativeApproach };
|
|
518
|
+
}
|
|
519
|
+
/** Apply time-based confidence decay to a strategy */
|
|
520
|
+
applyConfidenceDecay(strategy) {
|
|
521
|
+
const now = Date.now();
|
|
522
|
+
const weeksSinceLastUse = (now - strategy.lastUsed) / MS_PER_WEEK;
|
|
523
|
+
if (weeksSinceLastUse <= 0)
|
|
524
|
+
return strategy;
|
|
525
|
+
const decayFactor = Math.pow(this.confidenceDecayPerWeek, weeksSinceLastUse);
|
|
526
|
+
return {
|
|
527
|
+
...strategy,
|
|
528
|
+
confidence: strategy.confidence * decayFactor,
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
// ─── Utility Functions ───
|
|
533
|
+
/** Extract meaningful keywords from text, removing stop words */
|
|
534
|
+
function extractKeywords(text) {
|
|
535
|
+
const stopWords = new Set([
|
|
536
|
+
"the", "a", "an", "is", "are", "was", "were", "be",
|
|
537
|
+
"to", "of", "and", "in", "that", "have", "it",
|
|
538
|
+
"for", "not", "on", "with", "as", "do", "at",
|
|
539
|
+
"this", "but", "from", "or", "by", "will", "my",
|
|
540
|
+
"all", "can", "had", "her", "one", "our", "out",
|
|
541
|
+
"should", "would", "could", "has", "its", "into",
|
|
542
|
+
"then", "than", "been", "some", "when", "what",
|
|
543
|
+
]);
|
|
544
|
+
// CJK 문자를 개별 토큰으로 추출 (한국어/일본어/중국어 지원)
|
|
545
|
+
const cjkMatches = text.match(/[\u3000-\u9fff\uac00-\ud7af]{2,}/g) ?? [];
|
|
546
|
+
const asciiWords = text
|
|
547
|
+
.toLowerCase()
|
|
548
|
+
.replace(/[^a-z0-9\s_-]/g, " ")
|
|
549
|
+
.split(/\s+/)
|
|
550
|
+
.filter((w) => w.length > 2 && !stopWords.has(w));
|
|
551
|
+
return [...asciiWords, ...cjkMatches];
|
|
552
|
+
}
|
|
553
|
+
/** Truncate a string to maxLen, appending "..." if truncated */
|
|
554
|
+
function truncate(str, maxLen) {
|
|
555
|
+
if (str.length <= maxLen)
|
|
556
|
+
return str;
|
|
557
|
+
return str.slice(0, maxLen - 3) + "...";
|
|
558
|
+
}
|
|
559
|
+
//# sourceMappingURL=reflexion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|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CAAC,KAAK,CAAC;SACZ,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAEpD,OAAO,CAAC,GAAG,UAAU,EAAE,GAAG,UAAU,CAAC,CAAC;AACxC,CAAC;AAED,gEAAgE;AAChE,SAAS,QAAQ,CAAC,GAAW,EAAE,MAAc;IAC3C,IAAI,GAAG,CAAC,MAAM,IAAI,MAAM;QAAE,OAAO,GAAG,CAAC;IACrC,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;AAC1C,CAAC"}
|
package/dist/system-prompt.d.ts
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
|
import type { ToolDefinition } from "./types.js";
|
|
8
13
|
import type { ProjectStructure } from "./memory.js";
|
|
@@ -16,6 +21,17 @@ export interface SystemPromptOptions {
|
|
|
16
21
|
tools: ToolDefinition[];
|
|
17
22
|
/** 추가 규칙/지시 */
|
|
18
23
|
additionalRules?: string[];
|
|
24
|
+
/** 프로젝트 경로 */
|
|
25
|
+
projectPath?: string;
|
|
26
|
+
/** OS / 환경 정보 */
|
|
27
|
+
environment?: EnvironmentInfo;
|
|
28
|
+
}
|
|
29
|
+
/** 환경 정보 */
|
|
30
|
+
export interface EnvironmentInfo {
|
|
31
|
+
os?: string;
|
|
32
|
+
shell?: string;
|
|
33
|
+
nodeVersion?: string;
|
|
34
|
+
gitBranch?: string;
|
|
19
35
|
}
|
|
20
36
|
/**
|
|
21
37
|
* 에이전트 시스템 프롬프트를 생성.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../src/system-prompt.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../src/system-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,qBAAqB;AACrB,MAAM,WAAW,mBAAmB;IAClC,oBAAoB;IACpB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,iBAAiB;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mBAAmB;IACnB,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB,eAAe;IACf,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,cAAc;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB;IACjB,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B;AAED,YAAY;AACZ,MAAM,WAAW,eAAe;IAC9B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAgDtE"}
|