@yuaone/core 0.9.38 → 0.9.39
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 +21 -0
- package/dist/agent-loop.d.ts.map +1 -1
- package/dist/agent-loop.js +155 -154
- package/dist/agent-loop.js.map +1 -1
- package/dist/auto-fix.d.ts.map +1 -1
- package/dist/auto-fix.js +10 -0
- package/dist/auto-fix.js.map +1 -1
- package/dist/capability-graph.d.ts +3 -1
- package/dist/capability-graph.d.ts.map +1 -1
- package/dist/capability-graph.js +22 -8
- package/dist/capability-graph.js.map +1 -1
- package/dist/code-orchestrator.d.ts +109 -0
- package/dist/code-orchestrator.d.ts.map +1 -0
- package/dist/code-orchestrator.js +223 -0
- package/dist/code-orchestrator.js.map +1 -0
- package/dist/context-manager.d.ts +19 -0
- package/dist/context-manager.d.ts.map +1 -1
- package/dist/context-manager.js +100 -31
- package/dist/context-manager.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/system-prompt.js +8 -0
- package/dist/system-prompt.js.map +1 -1
- package/package.json +1 -1
package/dist/agent-loop.d.ts
CHANGED
|
@@ -235,8 +235,29 @@ export declare class AgentLoop extends EventEmitter {
|
|
|
235
235
|
* Memory와 프로젝트 컨텍스트를 로드하여 시스템 프롬프트를 갱신.
|
|
236
236
|
* run() 호출 전에 한 번 호출하면 메모리가 자동으로 주입된다.
|
|
237
237
|
* 이미 초기화되었으면 스킵.
|
|
238
|
+
* @deprecated run()은 내부적으로 criticalInit() + backgroundInit()을 직접 호출함.
|
|
239
|
+
* 외부에서 호출 시 하위호환을 위해 유지.
|
|
238
240
|
*/
|
|
239
241
|
init(): Promise<void>;
|
|
242
|
+
/**
|
|
243
|
+
* TTFT 최적화: LLM 호출 전 반드시 완료되어야 하는 최소 초기화.
|
|
244
|
+
* - 메모리/페르소나 로드 (YUAN.md, MemoryManager, PersonaManager)
|
|
245
|
+
* - ExecutionPolicyEngine (FailureRecovery 설정)
|
|
246
|
+
* - ImpactAnalyzer, ContinuationEngine + 체크포인트 복원
|
|
247
|
+
* - buildSystemPrompt (projectStructure 없이 — background에서 보완)
|
|
248
|
+
* 목표: 1초 이내 완료.
|
|
249
|
+
*/
|
|
250
|
+
private criticalInit;
|
|
251
|
+
/**
|
|
252
|
+
* TTFT 최적화: LLM 호출을 블로킹하지 않는 백그라운드 초기화.
|
|
253
|
+
* - VectorStore.load() + CodeIndexer
|
|
254
|
+
* - analyzeProject() + WorldState 수집
|
|
255
|
+
* - MCP connectAll()
|
|
256
|
+
* - CapabilityGraph, SkillLearner, Phase 4/5/6
|
|
257
|
+
* - HierarchicalPlanner, ContinuousReflection
|
|
258
|
+
* criticalInit() 완료 후 fire-and-forget으로 실행됨.
|
|
259
|
+
*/
|
|
260
|
+
private backgroundInit;
|
|
240
261
|
/**
|
|
241
262
|
* MemoryManager의 학습/실패 기록을 시스템 메시지로 변환.
|
|
242
263
|
*/
|
package/dist/agent-loop.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-loop.d.ts","sourceRoot":"","sources":["../src/agent-loop.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAI3C,OAAO,KAAK,EACV,WAAW,EAEX,gBAAgB,EAChB,OAAO,EAGP,YAAY,EACZ,UAAU,EACX,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAkB,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAEL,KAAK,WAAW,EAGjB,MAAM,0BAA0B,CAAC;AAQlC,OAAO,EACL,eAAe,EACf,KAAK,eAAe,EAEpB,KAAK,kBAAkB,EACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL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H,aAAa,IAAI,kBAAkB,GAAG,IAAI;IAM1C;;;;OAIG;IACH,OAAO,CAAC,uBAAuB;IAe/B;;;OAGG;IACH,OAAO,CAAC,aAAa;IA2BrB;;;OAGG;YACW,kBAAkB;IAkBhC;;;OAGG;YACW,iBAAiB;IAoB/B;;;OAGG;YACW,8BAA8B;IAoD5C;;;OAGG;YACW,uBAAuB;IAwCrC;;OAEG;IACH,gBAAgB,IAAI,aAAa;IAIjC;;OAEG;IACH,iBAAiB,IAAI,cAAc,GAAG,IAAI;IAM1C,kBAAkB;IAClB,OAAO,CAAC,SAAS;IAIjB,oCAAoC;YACtB,cAAc;IAK5B;;;;;;;OAOG;IACH,OAAO,CAAC,kBAAkB;IAgC1B;;;;OAIG;YACW,yBAAyB;IAevC,gCAAgC;IAC1B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAa9B;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAa5B,OAAO,CAAC,SAAS;IAKjB,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,gBAAgB;IAiBxB;;;OAGG;IACH,OAAO,CAAC,eAAe;IAavB;;;OAGG;YACW,cAAc;IAyD5B;;;OAGG;YACW,kBAAkB;IAoDhC;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAqB3B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAgB3B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAM;IAC1C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAM;IAE/C;;;;;OAKG;IACH,OAAO,CAAC,qBAAqB;CA6B9B"}
|
package/dist/agent-loop.js
CHANGED
|
@@ -51,7 +51,6 @@ import { SubAgent } from "./sub-agent.js";
|
|
|
51
51
|
import { ReasoningAggregator } from "./reasoning-aggregator.js";
|
|
52
52
|
import { ReasoningTree } from "./reasoning-tree.js";
|
|
53
53
|
import { ContextCompressor } from "./context-compressor.js";
|
|
54
|
-
import { DependencyAnalyzer } from "./dependency-analyzer.js";
|
|
55
54
|
import { CrossFileRefactor } from "./cross-file-refactor.js";
|
|
56
55
|
import { ContextBudgetManager } from "./context-budget.js";
|
|
57
56
|
import { QAPipeline } from "./qa-pipeline.js";
|
|
@@ -445,19 +444,32 @@ export class AgentLoop extends EventEmitter {
|
|
|
445
444
|
* Memory와 프로젝트 컨텍스트를 로드하여 시스템 프롬프트를 갱신.
|
|
446
445
|
* run() 호출 전에 한 번 호출하면 메모리가 자동으로 주입된다.
|
|
447
446
|
* 이미 초기화되었으면 스킵.
|
|
447
|
+
* @deprecated run()은 내부적으로 criticalInit() + backgroundInit()을 직접 호출함.
|
|
448
|
+
* 외부에서 호출 시 하위호환을 위해 유지.
|
|
448
449
|
*/
|
|
449
450
|
async init() {
|
|
451
|
+
await this.criticalInit();
|
|
452
|
+
await this.backgroundInit();
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* TTFT 최적화: LLM 호출 전 반드시 완료되어야 하는 최소 초기화.
|
|
456
|
+
* - 메모리/페르소나 로드 (YUAN.md, MemoryManager, PersonaManager)
|
|
457
|
+
* - ExecutionPolicyEngine (FailureRecovery 설정)
|
|
458
|
+
* - ImpactAnalyzer, ContinuationEngine + 체크포인트 복원
|
|
459
|
+
* - buildSystemPrompt (projectStructure 없이 — background에서 보완)
|
|
460
|
+
* 목표: 1초 이내 완료.
|
|
461
|
+
*/
|
|
462
|
+
async criticalInit() {
|
|
450
463
|
if (this.initialized)
|
|
451
464
|
return;
|
|
452
|
-
// Guard against concurrent re-entry while init is already running
|
|
453
465
|
if (this.partialInit)
|
|
454
466
|
return;
|
|
455
467
|
this.partialInit = true;
|
|
456
|
-
//
|
|
468
|
+
// ContextBudgetManager 초기화
|
|
457
469
|
this.contextBudgetManager = new ContextBudgetManager({
|
|
458
470
|
totalBudget: this.config.loop.totalTokenBudget,
|
|
459
471
|
enableSummarization: true,
|
|
460
|
-
summarizationThreshold: 0.60,
|
|
472
|
+
summarizationThreshold: 0.60,
|
|
461
473
|
});
|
|
462
474
|
const projectPath = this.config.loop.projectPath;
|
|
463
475
|
if (!projectPath)
|
|
@@ -470,8 +482,7 @@ export class AgentLoop extends EventEmitter {
|
|
|
470
482
|
this.sessionPersistence = null;
|
|
471
483
|
}
|
|
472
484
|
let yuanMdContent;
|
|
473
|
-
|
|
474
|
-
// Memory 로드
|
|
485
|
+
// Memory 로드 (YUAN.md + MemoryManager + PersonaManager — fast file I/O only)
|
|
475
486
|
if (this.enableMemory) {
|
|
476
487
|
try {
|
|
477
488
|
// YUAN.md (raw markdown)
|
|
@@ -491,24 +502,6 @@ export class AgentLoop extends EventEmitter {
|
|
|
491
502
|
enableLearning: true,
|
|
492
503
|
});
|
|
493
504
|
await this.personaManager.loadProfile().catch(() => { });
|
|
494
|
-
// InMemoryVectorStore — RAG semantic code context (TF-IDF fallback if Ollama unavailable)
|
|
495
|
-
this.vectorStore = new InMemoryVectorStore({
|
|
496
|
-
projectId: personaUserId,
|
|
497
|
-
projectPath,
|
|
498
|
-
embeddingProvider: new OllamaEmbeddingProvider(),
|
|
499
|
-
});
|
|
500
|
-
await Promise.race([
|
|
501
|
-
this.vectorStore.load(),
|
|
502
|
-
new Promise(resolve => setTimeout(resolve, 1_500)),
|
|
503
|
-
]).catch(() => { });
|
|
504
|
-
// Background indexing — non-blocking, fires and forgets
|
|
505
|
-
const vectorStoreRef = this.vectorStore;
|
|
506
|
-
import("./code-indexer.js").then(({ CodeIndexer }) => {
|
|
507
|
-
const indexer = new CodeIndexer({});
|
|
508
|
-
indexer.indexProject(projectPath, vectorStoreRef).catch(() => { });
|
|
509
|
-
}).catch(() => { });
|
|
510
|
-
// 프로젝트 구조 분석
|
|
511
|
-
projectStructure = await this.yuanMemory.analyzeProject();
|
|
512
505
|
}
|
|
513
506
|
catch (memErr) {
|
|
514
507
|
// 메모리 로드 실패는 치명적이지 않음 — 경고만 출력
|
|
@@ -522,7 +515,7 @@ export class AgentLoop extends EventEmitter {
|
|
|
522
515
|
// ExecutionPolicyEngine 로드
|
|
523
516
|
try {
|
|
524
517
|
this.policyEngine = new ExecutionPolicyEngine(projectPath);
|
|
525
|
-
|
|
518
|
+
await this.policyEngine.load();
|
|
526
519
|
if (this.policyOverrides) {
|
|
527
520
|
for (const [section, values] of Object.entries(this.policyOverrides)) {
|
|
528
521
|
this.policyEngine.override(section, values);
|
|
@@ -535,6 +528,110 @@ export class AgentLoop extends EventEmitter {
|
|
|
535
528
|
catch {
|
|
536
529
|
// 정책 로드 실패 → 기본값 사용
|
|
537
530
|
}
|
|
531
|
+
// ImpactAnalyzer 생성
|
|
532
|
+
this.impactAnalyzer = new ImpactAnalyzer({ projectPath });
|
|
533
|
+
// ContinuationEngine 생성 + 체크포인트 복원
|
|
534
|
+
this.continuationEngine = new ContinuationEngine({ projectPath });
|
|
535
|
+
try {
|
|
536
|
+
const latestCheckpoint = await this.continuationEngine.findLatestCheckpoint();
|
|
537
|
+
if (latestCheckpoint) {
|
|
538
|
+
const continuationPrompt = this.continuationEngine.formatContinuationPrompt(latestCheckpoint);
|
|
539
|
+
this.contextManager.addMessage({
|
|
540
|
+
role: "system",
|
|
541
|
+
content: continuationPrompt,
|
|
542
|
+
});
|
|
543
|
+
// 복원 후 체크포인트 정리
|
|
544
|
+
await this.continuationEngine.pruneOldCheckpoints();
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
catch {
|
|
548
|
+
// 체크포인트 복원 실패는 치명적이지 않음
|
|
549
|
+
}
|
|
550
|
+
// 향상된 시스템 프롬프트 생성 (projectStructure/worldState는 background에서 보완)
|
|
551
|
+
const enhancedPrompt = buildSystemPrompt({
|
|
552
|
+
projectStructure: undefined, // background에서 analyzeProject() 후 갱신
|
|
553
|
+
yuanMdContent,
|
|
554
|
+
tools: [...this.config.loop.tools, ...this.mcpToolDefinitions, SPAWN_SUB_AGENT_TOOL],
|
|
555
|
+
projectPath,
|
|
556
|
+
environment: this.environment,
|
|
557
|
+
});
|
|
558
|
+
// 기존 시스템 메시지를 향상된 프롬프트로 교체
|
|
559
|
+
this.contextManager.replaceSystemMessage(enhancedPrompt);
|
|
560
|
+
// MemoryManager의 관련 학습/경고를 추가 컨텍스트로 주입
|
|
561
|
+
if (this.memoryManager) {
|
|
562
|
+
const memory = this.memoryManager.getMemory();
|
|
563
|
+
if (memory.learnings.length > 0 || memory.failedApproaches.length > 0) {
|
|
564
|
+
const memoryContext = this.buildMemoryContext(memory);
|
|
565
|
+
if (memoryContext) {
|
|
566
|
+
this.contextManager.addMessage({
|
|
567
|
+
role: "system",
|
|
568
|
+
content: memoryContext,
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
// criticalInit 완료 — LLM 호출 가능 상태
|
|
574
|
+
// initialized=true는 backgroundInit() 완료 후 설정됨
|
|
575
|
+
// partialInit은 backgroundInit이 시작될 때까지 유지
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* TTFT 최적화: LLM 호출을 블로킹하지 않는 백그라운드 초기화.
|
|
579
|
+
* - VectorStore.load() + CodeIndexer
|
|
580
|
+
* - analyzeProject() + WorldState 수집
|
|
581
|
+
* - MCP connectAll()
|
|
582
|
+
* - CapabilityGraph, SkillLearner, Phase 4/5/6
|
|
583
|
+
* - HierarchicalPlanner, ContinuousReflection
|
|
584
|
+
* criticalInit() 완료 후 fire-and-forget으로 실행됨.
|
|
585
|
+
*/
|
|
586
|
+
async backgroundInit() {
|
|
587
|
+
// backgroundInit은 criticalInit이 완료된 후에만 의미 있음
|
|
588
|
+
// initialized=true이면 이미 완료된 것
|
|
589
|
+
if (this.initialized)
|
|
590
|
+
return;
|
|
591
|
+
const projectPath = this.config.loop.projectPath;
|
|
592
|
+
if (!projectPath) {
|
|
593
|
+
this.initialized = true;
|
|
594
|
+
this.partialInit = false;
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
// partialInit을 false로 — backgroundInit 실행 중이므로 재진입 방어 불필요
|
|
598
|
+
this.partialInit = false;
|
|
599
|
+
// VectorStore — RAG semantic code context (Ollama 느릴 수 있음)
|
|
600
|
+
if (this.enableMemory && this.yuanMemory) {
|
|
601
|
+
try {
|
|
602
|
+
const personaUserId = basename(projectPath) || "default";
|
|
603
|
+
this.vectorStore = new InMemoryVectorStore({
|
|
604
|
+
projectId: personaUserId,
|
|
605
|
+
projectPath,
|
|
606
|
+
embeddingProvider: new OllamaEmbeddingProvider(),
|
|
607
|
+
});
|
|
608
|
+
await Promise.race([
|
|
609
|
+
this.vectorStore.load(),
|
|
610
|
+
new Promise(resolve => setTimeout(resolve, 1_500)),
|
|
611
|
+
]).catch(() => { });
|
|
612
|
+
// Background code indexing — fire and forget
|
|
613
|
+
const vectorStoreRef = this.vectorStore;
|
|
614
|
+
import("./code-indexer.js").then(({ CodeIndexer }) => {
|
|
615
|
+
const indexer = new CodeIndexer({});
|
|
616
|
+
indexer.indexProject(projectPath, vectorStoreRef).catch(() => { });
|
|
617
|
+
}).catch(() => { });
|
|
618
|
+
// 프로젝트 구조 분석 (느림 — file scan)
|
|
619
|
+
const projectStructure = await this.yuanMemory.analyzeProject();
|
|
620
|
+
// analyzeProject 완료 후 시스템 프롬프트 재빌드 (WorldState 아직 없어도 됨)
|
|
621
|
+
const yuanMdContent = (await this.yuanMemory.load().catch(() => null))?.raw;
|
|
622
|
+
const updatedPrompt = buildSystemPrompt({
|
|
623
|
+
projectStructure,
|
|
624
|
+
yuanMdContent,
|
|
625
|
+
tools: [...this.config.loop.tools, ...this.mcpToolDefinitions, SPAWN_SUB_AGENT_TOOL],
|
|
626
|
+
projectPath,
|
|
627
|
+
environment: this.environment,
|
|
628
|
+
});
|
|
629
|
+
this.contextManager.replaceSystemMessage(updatedPrompt);
|
|
630
|
+
}
|
|
631
|
+
catch {
|
|
632
|
+
// non-fatal
|
|
633
|
+
}
|
|
634
|
+
}
|
|
538
635
|
// WorldState 수집 → system prompt에 주입
|
|
539
636
|
try {
|
|
540
637
|
const worldStateCollector = new WorldStateCollector({
|
|
@@ -543,6 +640,17 @@ export class AgentLoop extends EventEmitter {
|
|
|
543
640
|
skipTest: true,
|
|
544
641
|
});
|
|
545
642
|
this.worldState = await worldStateCollector.collect();
|
|
643
|
+
// WorldState 섹션 시스템 프롬프트에 추가
|
|
644
|
+
if (this.worldState) {
|
|
645
|
+
const collector = new WorldStateCollector({ projectPath });
|
|
646
|
+
const worldStateSection = "\n\n" + collector.formatForPrompt(this.worldState);
|
|
647
|
+
// 현재 시스템 메시지에 WorldState 추가
|
|
648
|
+
const currentMsgs = this.contextManager.getMessages();
|
|
649
|
+
const sysMsg = currentMsgs.find((m) => m.role === "system");
|
|
650
|
+
if (sysMsg && !String(sysMsg.content).includes("## Current Environment")) {
|
|
651
|
+
this.contextManager.replaceSystemMessage(String(sysMsg.content) + worldStateSection);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
546
654
|
}
|
|
547
655
|
catch {
|
|
548
656
|
// WorldState 수집 실패는 치명적이지 않음
|
|
@@ -573,34 +681,12 @@ export class AgentLoop extends EventEmitter {
|
|
|
573
681
|
catch {
|
|
574
682
|
// Not a git repo or git unavailable — FailureRecovery will use file-level rollback only
|
|
575
683
|
}
|
|
576
|
-
//
|
|
577
|
-
this.impactAnalyzer = new ImpactAnalyzer({ projectPath });
|
|
578
|
-
// ContinuationEngine 생성
|
|
579
|
-
this.continuationEngine = new ContinuationEngine({ projectPath });
|
|
580
|
-
// 이전 세션 체크포인트 복원
|
|
581
|
-
try {
|
|
582
|
-
const latestCheckpoint = await this.continuationEngine.findLatestCheckpoint();
|
|
583
|
-
if (latestCheckpoint) {
|
|
584
|
-
const continuationPrompt = this.continuationEngine.formatContinuationPrompt(latestCheckpoint);
|
|
585
|
-
this.contextManager.addMessage({
|
|
586
|
-
role: "system",
|
|
587
|
-
content: continuationPrompt,
|
|
588
|
-
});
|
|
589
|
-
// 복원 후 체크포인트 정리
|
|
590
|
-
await this.continuationEngine.pruneOldCheckpoints();
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
catch {
|
|
594
|
-
// 체크포인트 복원 실패는 치명적이지 않음
|
|
595
|
-
}
|
|
596
|
-
// MCP 클라이언트 연결
|
|
597
|
-
// Auto-load ~/.yuan/mcp.json and merge with any programmatically supplied configs
|
|
684
|
+
// MCP 클라이언트 연결 (connectAll은 네트워크 I/O라 느릴 수 있음)
|
|
598
685
|
{
|
|
599
686
|
let mergedMCPConfigs = [...this.mcpServerConfigs];
|
|
600
687
|
try {
|
|
601
688
|
const fileConfig = await loadMCPConfig();
|
|
602
689
|
if (fileConfig && fileConfig.servers.length > 0) {
|
|
603
|
-
// Deduplicate by name — programmatic configs take precedence
|
|
604
690
|
const existingNames = new Set(mergedMCPConfigs.map((s) => s.name));
|
|
605
691
|
for (const server of fileConfig.servers) {
|
|
606
692
|
if (!existingNames.has(server.name)) {
|
|
@@ -610,7 +696,6 @@ export class AgentLoop extends EventEmitter {
|
|
|
610
696
|
}
|
|
611
697
|
}
|
|
612
698
|
catch (mcpLoadErr) {
|
|
613
|
-
// Config parse error — warn and continue without file-based servers
|
|
614
699
|
this.emitEvent({
|
|
615
700
|
kind: "agent:error",
|
|
616
701
|
message: `MCP config load warning: ${mcpLoadErr instanceof Error ? mcpLoadErr.message : String(mcpLoadErr)}`,
|
|
@@ -630,16 +715,13 @@ export class AgentLoop extends EventEmitter {
|
|
|
630
715
|
});
|
|
631
716
|
}
|
|
632
717
|
catch {
|
|
633
|
-
// MCP 연결 실패는 치명적이지 않음 — 로컬 도구만 사용
|
|
634
718
|
this.mcpClient = null;
|
|
635
719
|
this.mcpToolDefinitions = [];
|
|
636
720
|
}
|
|
637
721
|
}
|
|
638
722
|
}
|
|
639
723
|
// ReflexionEngine 생성
|
|
640
|
-
|
|
641
|
-
this.reflexionEngine = new ReflexionEngine({ projectPath });
|
|
642
|
-
}
|
|
724
|
+
this.reflexionEngine = new ReflexionEngine({ projectPath });
|
|
643
725
|
// SelfReflection 생성 (6D deep verify + quick verify)
|
|
644
726
|
if (this.enableSelfReflection) {
|
|
645
727
|
const sessionId = `session-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
@@ -650,7 +732,6 @@ export class AgentLoop extends EventEmitter {
|
|
|
650
732
|
minScoreToPass: 70,
|
|
651
733
|
criticalDimensions: ["correctness", "security"],
|
|
652
734
|
});
|
|
653
|
-
// 메모리에서 기존 학습 복원
|
|
654
735
|
if (this.memoryManager) {
|
|
655
736
|
try {
|
|
656
737
|
const memory = await this.memoryManager.load();
|
|
@@ -674,41 +755,12 @@ export class AgentLoop extends EventEmitter {
|
|
|
674
755
|
totalTokenBudget: Math.floor(this.config.loop.totalTokenBudget * 0.3),
|
|
675
756
|
});
|
|
676
757
|
}
|
|
677
|
-
// 향상된 시스템 프롬프트 생성
|
|
678
|
-
const enhancedPrompt = buildSystemPrompt({
|
|
679
|
-
projectStructure,
|
|
680
|
-
yuanMdContent,
|
|
681
|
-
tools: [...this.config.loop.tools, ...this.mcpToolDefinitions, SPAWN_SUB_AGENT_TOOL],
|
|
682
|
-
projectPath,
|
|
683
|
-
environment: this.environment,
|
|
684
|
-
});
|
|
685
|
-
// WorldState를 시스템 프롬프트에 추가
|
|
686
|
-
let worldStateSection = "";
|
|
687
|
-
if (this.worldState) {
|
|
688
|
-
const collector = new WorldStateCollector({ projectPath });
|
|
689
|
-
worldStateSection = "\n\n" + collector.formatForPrompt(this.worldState);
|
|
690
|
-
}
|
|
691
|
-
// 기존 시스템 메시지를 향상된 프롬프트로 교체
|
|
692
|
-
this.contextManager.replaceSystemMessage(enhancedPrompt + worldStateSection);
|
|
693
|
-
// MemoryManager의 관련 학습/경고를 추가 컨텍스트로 주입
|
|
694
|
-
if (this.memoryManager) {
|
|
695
|
-
const memory = this.memoryManager.getMemory();
|
|
696
|
-
if (memory.learnings.length > 0 || memory.failedApproaches.length > 0) {
|
|
697
|
-
const memoryContext = this.buildMemoryContext(memory);
|
|
698
|
-
if (memoryContext) {
|
|
699
|
-
this.contextManager.addMessage({
|
|
700
|
-
role: "system",
|
|
701
|
-
content: memoryContext,
|
|
702
|
-
});
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
758
|
// Self-model weakness context injection
|
|
707
759
|
const weaknessCtx = getSelfWeaknessContext(this.capabilitySelfModel);
|
|
708
760
|
if (weaknessCtx) {
|
|
709
761
|
this.contextManager.addMessage({ role: "system", content: weaknessCtx });
|
|
710
762
|
}
|
|
711
|
-
// SkillLearner 초기화 (경험에서 학습된 스킬 자동 로드)
|
|
763
|
+
// SkillLearner 초기화 (경험에서 학습된 스킬 자동 로드 — slow disk I/O)
|
|
712
764
|
if (this.enableSkillLearning && projectPath) {
|
|
713
765
|
try {
|
|
714
766
|
this.skillLearner = new SkillLearner(projectPath);
|
|
@@ -724,12 +776,9 @@ export class AgentLoop extends EventEmitter {
|
|
|
724
776
|
this.failureSigMemory = new FailureSignatureMemory({ projectPath });
|
|
725
777
|
this.playbookLibrary = new PlaybookLibrary();
|
|
726
778
|
this.projectExecutive = new ProjectExecutive(projectPath);
|
|
727
|
-
// Estimated iterations from config or default 20
|
|
728
779
|
const estimatedIter = this.config.loop.maxIterations ?? 20;
|
|
729
780
|
this.stallDetector = new StallDetector(estimatedIter);
|
|
730
|
-
// Forward project executive events
|
|
731
781
|
this.projectExecutive.on("event", (ev) => this.emitEvent(ev));
|
|
732
|
-
// Phase 4 remaining: SelfImprovementLoop, MetaLearningCollector, TrustEconomics
|
|
733
782
|
this.selfImprovementLoop = new SelfImprovementLoop({ projectPath });
|
|
734
783
|
this.selfImprovementLoop.on("event", (ev) => this.emitEvent(ev));
|
|
735
784
|
this.metaLearningCollector = new MetaLearningCollector({ projectPath });
|
|
@@ -743,7 +792,6 @@ export class AgentLoop extends EventEmitter {
|
|
|
743
792
|
try {
|
|
744
793
|
this.strategyLearner = new StrategyLearner();
|
|
745
794
|
this.skillRegistry = new SkillRegistry();
|
|
746
|
-
// Forward Phase 5 events
|
|
747
795
|
this.strategyLearner.on("event", (ev) => this.emitEvent(ev));
|
|
748
796
|
this.skillRegistry.on("event", (ev) => this.emitEvent(ev));
|
|
749
797
|
}
|
|
@@ -758,7 +806,6 @@ export class AgentLoop extends EventEmitter {
|
|
|
758
806
|
strategyLearner: this.strategyLearner ?? undefined,
|
|
759
807
|
});
|
|
760
808
|
this.toolSynthesizer = new ToolSynthesizer();
|
|
761
|
-
// Forward Phase 5 extended events
|
|
762
809
|
this.tracePatternExtractor.on("event", (ev) => this.emitEvent(ev));
|
|
763
810
|
this.metaLearningEngine.on("event", (ev) => this.emitEvent(ev));
|
|
764
811
|
this.toolSynthesizer.on("event", (ev) => this.emitEvent(ev));
|
|
@@ -776,7 +823,6 @@ export class AgentLoop extends EventEmitter {
|
|
|
776
823
|
this.capabilityGraph.on("event", (ev) => this.emitEvent(ev));
|
|
777
824
|
this.capabilitySelfModel.on("event", (ev) => this.emitEvent(ev));
|
|
778
825
|
this.strategyMarket.on("event", (ev) => this.emitEvent(ev));
|
|
779
|
-
// Register known tools in capability graph
|
|
780
826
|
const toolNames = this.config.loop.tools.map((t) => t.name);
|
|
781
827
|
registerToolsInGraph(this.capabilityGraph, toolNames);
|
|
782
828
|
}
|
|
@@ -813,29 +859,22 @@ export class AgentLoop extends EventEmitter {
|
|
|
813
859
|
}
|
|
814
860
|
}
|
|
815
861
|
// RepoKnowledgeGraph 초기화 (코드 구조 그래프 — 비동기 빌드)
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
});
|
|
823
|
-
}
|
|
824
|
-
catch {
|
|
825
|
-
this.repoGraph = null;
|
|
826
|
-
}
|
|
862
|
+
try {
|
|
863
|
+
this.repoGraph = new RepoKnowledgeGraph(projectPath);
|
|
864
|
+
this.repoGraph.buildFromProject(projectPath).catch(() => { });
|
|
865
|
+
}
|
|
866
|
+
catch {
|
|
867
|
+
this.repoGraph = null;
|
|
827
868
|
}
|
|
828
869
|
// BackgroundAgentManager 초기화 (opt-in)
|
|
829
870
|
if (this.enableBackgroundAgents && projectPath) {
|
|
830
871
|
try {
|
|
831
872
|
this.backgroundAgentManager = new BackgroundAgentManager();
|
|
832
873
|
this.backgroundAgentManager.createDefaults(projectPath);
|
|
833
|
-
// Background events → agent loop events
|
|
834
874
|
for (const agent of this.backgroundAgentManager.list()) {
|
|
835
875
|
const bgAgent = this.backgroundAgentManager.get(agent.id);
|
|
836
876
|
if (bgAgent) {
|
|
837
877
|
bgAgent.on("event", (event) => {
|
|
838
|
-
// Emit structured bg_update for TUI task panel
|
|
839
878
|
this.emitEvent({
|
|
840
879
|
kind: "agent:bg_update",
|
|
841
880
|
agentId: event.agentId,
|
|
@@ -853,7 +892,6 @@ export class AgentLoop extends EventEmitter {
|
|
|
853
892
|
}
|
|
854
893
|
}
|
|
855
894
|
// Inject active plugin skills into system prompt (lazy: names only)
|
|
856
|
-
// Full skill content is loaded on-demand when triggered (file-pattern or error match)
|
|
857
895
|
const activeSkills = this.pluginRegistry.getAllSkills();
|
|
858
896
|
if (activeSkills.length > 0) {
|
|
859
897
|
const skillSummary = activeSkills
|
|
@@ -867,7 +905,7 @@ export class AgentLoop extends EventEmitter {
|
|
|
867
905
|
// ContinuousReflection 생성 (1분 간격 체크포인트 + 자기검증 + 컨텍스트 모니터)
|
|
868
906
|
this.continuousReflection = new ContinuousReflection({
|
|
869
907
|
getState: () => this.getStateSnapshot(),
|
|
870
|
-
checkpoint: async (state,
|
|
908
|
+
checkpoint: async (state, _emergency) => {
|
|
871
909
|
if (!this.continuationEngine)
|
|
872
910
|
return;
|
|
873
911
|
const checkpoint = {
|
|
@@ -890,7 +928,6 @@ export class AgentLoop extends EventEmitter {
|
|
|
890
928
|
await this.continuationEngine.saveCheckpoint(checkpoint);
|
|
891
929
|
},
|
|
892
930
|
selfVerify: async (prompt) => {
|
|
893
|
-
// 경량 LLM 호출 (~200 토큰)로 자기검증
|
|
894
931
|
try {
|
|
895
932
|
const response = await this.llmClient.chat([{ role: "user", content: prompt }], []);
|
|
896
933
|
const text = typeof response.content === "string"
|
|
@@ -932,8 +969,7 @@ export class AgentLoop extends EventEmitter {
|
|
|
932
969
|
this.continuousReflection.on("reflection:context_overflow", () => {
|
|
933
970
|
void this.handleSoftContextOverflow();
|
|
934
971
|
});
|
|
935
|
-
// Mark fully initialized
|
|
936
|
-
// runs can detect that init completed (partialInit=false + initialized=true).
|
|
972
|
+
// Mark fully initialized
|
|
937
973
|
this.initialized = true;
|
|
938
974
|
this.partialInit = false;
|
|
939
975
|
}
|
|
@@ -1015,15 +1051,18 @@ export class AgentLoop extends EventEmitter {
|
|
|
1015
1051
|
dlog("AGENT-LOOP", `emitting agent:start, sessionId=${this.sessionId}`);
|
|
1016
1052
|
this.emitEvent({ kind: "agent:start", goal: userMessage });
|
|
1017
1053
|
// 첫 실행 시 메모리/프로젝트 컨텍스트 자동 로드
|
|
1018
|
-
//
|
|
1054
|
+
// criticalInit은 최대 1초만 블로킹 — LLM 호출 TTFT 최소화
|
|
1055
|
+
// backgroundInit은 fire-and-forget — LLM 호출을 블로킹하지 않음
|
|
1019
1056
|
await Promise.race([
|
|
1020
|
-
this.
|
|
1021
|
-
new Promise(resolve => setTimeout(resolve,
|
|
1057
|
+
this.criticalInit(),
|
|
1058
|
+
new Promise(resolve => setTimeout(resolve, 1_000)),
|
|
1022
1059
|
]);
|
|
1023
|
-
// If
|
|
1060
|
+
// If criticalInit timed out (partialInit still true), allow retry on next run
|
|
1024
1061
|
if (this.partialInit && !this.initialized) {
|
|
1025
1062
|
this.partialInit = false;
|
|
1026
1063
|
}
|
|
1064
|
+
// Background init — does NOT block LLM call
|
|
1065
|
+
this.backgroundInit().catch(() => { });
|
|
1027
1066
|
// Always generate a fresh sessionId per run — prevents BudgetGovernorV2
|
|
1028
1067
|
// from accumulating exhausted task budget across multiple runs on the same instance.
|
|
1029
1068
|
this.sessionId = randomUUID();
|
|
@@ -3577,9 +3616,7 @@ export class AgentLoop extends EventEmitter {
|
|
|
3577
3616
|
// ─── Step 1: Build execution plan ───────────────────────────────────────
|
|
3578
3617
|
// Strategy:
|
|
3579
3618
|
// • Read-only tools (low-risk) → batch together, run all in parallel
|
|
3580
|
-
// • Write tools
|
|
3581
|
-
// run each independent group in parallel
|
|
3582
|
-
// • Write tools (dependent files) → run sequentially after their deps
|
|
3619
|
+
// • Write tools → run sequentially (wave 99)
|
|
3583
3620
|
// • shell_exec / git_ops / etc. → always sequential (side-effects)
|
|
3584
3621
|
const READ_ONLY = new Set(['file_read', 'grep', 'glob', 'code_search', 'security_scan']);
|
|
3585
3622
|
const WRITE_TOOLS = new Set(['file_write', 'file_edit']);
|
|
@@ -3588,45 +3625,9 @@ export class AgentLoop extends EventEmitter {
|
|
|
3588
3625
|
// ─── Step 2: Dependency-aware write tool batching ────────────────────────
|
|
3589
3626
|
// Map each write tool call to a "wave index" (0 = can run first, 1 = needs wave-0 done, etc.)
|
|
3590
3627
|
const writeBatchMap = new Map(); // tc.id → wave index
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
const depGraph = await depAnalyzer.analyze(this.config.loop.projectPath);
|
|
3595
|
-
// Collect target file paths from write tool args
|
|
3596
|
-
const writeFilePaths = writeToolCalls.flatMap((tc) => {
|
|
3597
|
-
const args = this.parseToolArgs(tc.arguments);
|
|
3598
|
-
const p = typeof args.path === "string" ? args.path
|
|
3599
|
-
: typeof args.file_path === "string" ? args.file_path
|
|
3600
|
-
: null;
|
|
3601
|
-
return p ? [p] : [];
|
|
3602
|
-
});
|
|
3603
|
-
if (writeFilePaths.length > 1) {
|
|
3604
|
-
const groups = depAnalyzer.groupIndependentFiles(depGraph, writeFilePaths);
|
|
3605
|
-
// Assign wave indices: independent groups get wave 0,
|
|
3606
|
-
// dependent groups get wave = max(their dep waves) + 1
|
|
3607
|
-
// For simplicity: canParallelize=true → wave 0, else sequential waves
|
|
3608
|
-
let wave = 0;
|
|
3609
|
-
for (const group of groups) {
|
|
3610
|
-
if (!group.canParallelize)
|
|
3611
|
-
wave++;
|
|
3612
|
-
for (const filePath of group.files) {
|
|
3613
|
-
const tc = writeToolCalls.find((c) => {
|
|
3614
|
-
const args = this.parseToolArgs(c.arguments);
|
|
3615
|
-
const p = args.path ?? args.file_path;
|
|
3616
|
-
return p === filePath;
|
|
3617
|
-
});
|
|
3618
|
-
if (tc)
|
|
3619
|
-
writeBatchMap.set(tc.id, wave);
|
|
3620
|
-
}
|
|
3621
|
-
if (group.canParallelize)
|
|
3622
|
-
wave = 0; // reset: next independent group is also wave 0
|
|
3623
|
-
}
|
|
3624
|
-
}
|
|
3625
|
-
}
|
|
3626
|
-
catch {
|
|
3627
|
-
// DependencyAnalyzer failure is non-fatal — all writes run sequentially
|
|
3628
|
-
}
|
|
3629
|
-
}
|
|
3628
|
+
// DependencyAnalyzer removed: it scanned the entire filesystem (50-1000ms blocking).
|
|
3629
|
+
// Write tools run sequentially (wave 0) — no dependency analysis overhead.
|
|
3630
|
+
// writeBatchMap stays empty → all writes default to wave 99 (sequential).
|
|
3630
3631
|
// ─── Step 3: Build ordered batch list ────────────────────────────────────
|
|
3631
3632
|
// Final structure: array of batches, each batch runs in parallel.
|
|
3632
3633
|
// Reads accumulate until interrupted by a non-read tool.
|