@yuaone/core 0.9.38 → 0.9.40

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.
@@ -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
  */
@@ -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,EAC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;;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"}
@@ -50,8 +50,6 @@ import { BackgroundAgentManager } from "./background-agent.js";
50
50
  import { SubAgent } from "./sub-agent.js";
51
51
  import { ReasoningAggregator } from "./reasoning-aggregator.js";
52
52
  import { ReasoningTree } from "./reasoning-tree.js";
53
- import { ContextCompressor } from "./context-compressor.js";
54
- import { DependencyAnalyzer } from "./dependency-analyzer.js";
55
53
  import { CrossFileRefactor } from "./cross-file-refactor.js";
56
54
  import { ContextBudgetManager } from "./context-budget.js";
57
55
  import { QAPipeline } from "./qa-pipeline.js";
@@ -445,19 +443,32 @@ export class AgentLoop extends EventEmitter {
445
443
  * Memory와 프로젝트 컨텍스트를 로드하여 시스템 프롬프트를 갱신.
446
444
  * run() 호출 전에 한 번 호출하면 메모리가 자동으로 주입된다.
447
445
  * 이미 초기화되었으면 스킵.
446
+ * @deprecated run()은 내부적으로 criticalInit() + backgroundInit()을 직접 호출함.
447
+ * 외부에서 호출 시 하위호환을 위해 유지.
448
448
  */
449
449
  async init() {
450
+ await this.criticalInit();
451
+ await this.backgroundInit();
452
+ }
453
+ /**
454
+ * TTFT 최적화: LLM 호출 전 반드시 완료되어야 하는 최소 초기화.
455
+ * - 메모리/페르소나 로드 (YUAN.md, MemoryManager, PersonaManager)
456
+ * - ExecutionPolicyEngine (FailureRecovery 설정)
457
+ * - ImpactAnalyzer, ContinuationEngine + 체크포인트 복원
458
+ * - buildSystemPrompt (projectStructure 없이 — background에서 보완)
459
+ * 목표: 1초 이내 완료.
460
+ */
461
+ async criticalInit() {
450
462
  if (this.initialized)
451
463
  return;
452
- // Guard against concurrent re-entry while init is already running
453
464
  if (this.partialInit)
454
465
  return;
455
466
  this.partialInit = true;
456
- // Task 1: Initialize ContextBudgetManager with the total token budget
467
+ // ContextBudgetManager 초기화
457
468
  this.contextBudgetManager = new ContextBudgetManager({
458
469
  totalBudget: this.config.loop.totalTokenBudget,
459
470
  enableSummarization: true,
460
- summarizationThreshold: 0.60, // trigger summarize() at 60% (before ContextCompressor at 70%)
471
+ summarizationThreshold: 0.60,
461
472
  });
462
473
  const projectPath = this.config.loop.projectPath;
463
474
  if (!projectPath)
@@ -470,8 +481,7 @@ export class AgentLoop extends EventEmitter {
470
481
  this.sessionPersistence = null;
471
482
  }
472
483
  let yuanMdContent;
473
- let projectStructure;
474
- // Memory 로드
484
+ // Memory 로드 (YUAN.md + MemoryManager + PersonaManager — fast file I/O only)
475
485
  if (this.enableMemory) {
476
486
  try {
477
487
  // YUAN.md (raw markdown)
@@ -491,24 +501,6 @@ export class AgentLoop extends EventEmitter {
491
501
  enableLearning: true,
492
502
  });
493
503
  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
504
  }
513
505
  catch (memErr) {
514
506
  // 메모리 로드 실패는 치명적이지 않음 — 경고만 출력
@@ -522,7 +514,7 @@ export class AgentLoop extends EventEmitter {
522
514
  // ExecutionPolicyEngine 로드
523
515
  try {
524
516
  this.policyEngine = new ExecutionPolicyEngine(projectPath);
525
- const policy = await this.policyEngine.load();
517
+ await this.policyEngine.load();
526
518
  if (this.policyOverrides) {
527
519
  for (const [section, values] of Object.entries(this.policyOverrides)) {
528
520
  this.policyEngine.override(section, values);
@@ -535,6 +527,110 @@ export class AgentLoop extends EventEmitter {
535
527
  catch {
536
528
  // 정책 로드 실패 → 기본값 사용
537
529
  }
530
+ // ImpactAnalyzer 생성
531
+ this.impactAnalyzer = new ImpactAnalyzer({ projectPath });
532
+ // ContinuationEngine 생성 + 체크포인트 복원
533
+ this.continuationEngine = new ContinuationEngine({ projectPath });
534
+ try {
535
+ const latestCheckpoint = await this.continuationEngine.findLatestCheckpoint();
536
+ if (latestCheckpoint) {
537
+ const continuationPrompt = this.continuationEngine.formatContinuationPrompt(latestCheckpoint);
538
+ this.contextManager.addMessage({
539
+ role: "system",
540
+ content: continuationPrompt,
541
+ });
542
+ // 복원 후 체크포인트 정리
543
+ await this.continuationEngine.pruneOldCheckpoints();
544
+ }
545
+ }
546
+ catch {
547
+ // 체크포인트 복원 실패는 치명적이지 않음
548
+ }
549
+ // 향상된 시스템 프롬프트 생성 (projectStructure/worldState는 background에서 보완)
550
+ const enhancedPrompt = buildSystemPrompt({
551
+ projectStructure: undefined, // background에서 analyzeProject() 후 갱신
552
+ yuanMdContent,
553
+ tools: [...this.config.loop.tools, ...this.mcpToolDefinitions, SPAWN_SUB_AGENT_TOOL],
554
+ projectPath,
555
+ environment: this.environment,
556
+ });
557
+ // 기존 시스템 메시지를 향상된 프롬프트로 교체
558
+ this.contextManager.replaceSystemMessage(enhancedPrompt);
559
+ // MemoryManager의 관련 학습/경고를 추가 컨텍스트로 주입
560
+ if (this.memoryManager) {
561
+ const memory = this.memoryManager.getMemory();
562
+ if (memory.learnings.length > 0 || memory.failedApproaches.length > 0) {
563
+ const memoryContext = this.buildMemoryContext(memory);
564
+ if (memoryContext) {
565
+ this.contextManager.addMessage({
566
+ role: "system",
567
+ content: memoryContext,
568
+ });
569
+ }
570
+ }
571
+ }
572
+ // criticalInit 완료 — LLM 호출 가능 상태
573
+ // initialized=true는 backgroundInit() 완료 후 설정됨
574
+ // partialInit은 backgroundInit이 시작될 때까지 유지
575
+ }
576
+ /**
577
+ * TTFT 최적화: LLM 호출을 블로킹하지 않는 백그라운드 초기화.
578
+ * - VectorStore.load() + CodeIndexer
579
+ * - analyzeProject() + WorldState 수집
580
+ * - MCP connectAll()
581
+ * - CapabilityGraph, SkillLearner, Phase 4/5/6
582
+ * - HierarchicalPlanner, ContinuousReflection
583
+ * criticalInit() 완료 후 fire-and-forget으로 실행됨.
584
+ */
585
+ async backgroundInit() {
586
+ // backgroundInit은 criticalInit이 완료된 후에만 의미 있음
587
+ // initialized=true이면 이미 완료된 것
588
+ if (this.initialized)
589
+ return;
590
+ const projectPath = this.config.loop.projectPath;
591
+ if (!projectPath) {
592
+ this.initialized = true;
593
+ this.partialInit = false;
594
+ return;
595
+ }
596
+ // partialInit을 false로 — backgroundInit 실행 중이므로 재진입 방어 불필요
597
+ this.partialInit = false;
598
+ // VectorStore — RAG semantic code context (Ollama 느릴 수 있음)
599
+ if (this.enableMemory && this.yuanMemory) {
600
+ try {
601
+ const personaUserId = basename(projectPath) || "default";
602
+ this.vectorStore = new InMemoryVectorStore({
603
+ projectId: personaUserId,
604
+ projectPath,
605
+ embeddingProvider: new OllamaEmbeddingProvider(),
606
+ });
607
+ await Promise.race([
608
+ this.vectorStore.load(),
609
+ new Promise(resolve => setTimeout(resolve, 1_500)),
610
+ ]).catch(() => { });
611
+ // Background code indexing — fire and forget
612
+ const vectorStoreRef = this.vectorStore;
613
+ import("./code-indexer.js").then(({ CodeIndexer }) => {
614
+ const indexer = new CodeIndexer({});
615
+ indexer.indexProject(projectPath, vectorStoreRef).catch(() => { });
616
+ }).catch(() => { });
617
+ // 프로젝트 구조 분석 (느림 — file scan)
618
+ const projectStructure = await this.yuanMemory.analyzeProject();
619
+ // analyzeProject 완료 후 시스템 프롬프트 재빌드 (WorldState 아직 없어도 됨)
620
+ const yuanMdContent = (await this.yuanMemory.load().catch(() => null))?.raw;
621
+ const updatedPrompt = buildSystemPrompt({
622
+ projectStructure,
623
+ yuanMdContent,
624
+ tools: [...this.config.loop.tools, ...this.mcpToolDefinitions, SPAWN_SUB_AGENT_TOOL],
625
+ projectPath,
626
+ environment: this.environment,
627
+ });
628
+ this.contextManager.replaceSystemMessage(updatedPrompt);
629
+ }
630
+ catch {
631
+ // non-fatal
632
+ }
633
+ }
538
634
  // WorldState 수집 → system prompt에 주입
539
635
  try {
540
636
  const worldStateCollector = new WorldStateCollector({
@@ -543,10 +639,34 @@ export class AgentLoop extends EventEmitter {
543
639
  skipTest: true,
544
640
  });
545
641
  this.worldState = await worldStateCollector.collect();
642
+ // WorldState 섹션 시스템 프롬프트에 추가
643
+ if (this.worldState) {
644
+ const collector = new WorldStateCollector({ projectPath });
645
+ const worldStateSection = "\n\n" + collector.formatForPrompt(this.worldState);
646
+ // 현재 시스템 메시지에 WorldState 추가
647
+ const currentMsgs = this.contextManager.getMessages();
648
+ const sysMsg = currentMsgs.find((m) => m.role === "system");
649
+ if (sysMsg && !String(sysMsg.content).includes("## Current Environment")) {
650
+ this.contextManager.replaceSystemMessage(String(sysMsg.content) + worldStateSection);
651
+ }
652
+ }
546
653
  }
547
654
  catch {
548
655
  // WorldState 수집 실패는 치명적이지 않음
549
656
  }
657
+ // CodeOrchestrator: 언어별 코딩 표준 + 프로젝트 컨텍스트 주입
658
+ try {
659
+ const { codeOrchestrator } = await import('./code-orchestrator.js');
660
+ const codeCtx = await codeOrchestrator.getContextForLLM(projectPath ?? '');
661
+ if (codeCtx) {
662
+ const currentMsgs = this.contextManager.getMessages();
663
+ const sysMsg = currentMsgs.find((m) => m.role === "system");
664
+ if (sysMsg) {
665
+ this.contextManager.replaceSystemMessage(String(sysMsg.content) + '\n\n' + codeCtx);
666
+ }
667
+ }
668
+ }
669
+ catch { /* non-fatal */ }
550
670
  // Initialize World Model
551
671
  if (this.worldState && projectPath) {
552
672
  try {
@@ -573,34 +693,12 @@ export class AgentLoop extends EventEmitter {
573
693
  catch {
574
694
  // Not a git repo or git unavailable — FailureRecovery will use file-level rollback only
575
695
  }
576
- // ImpactAnalyzer 생성
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
696
+ // MCP 클라이언트 연결 (connectAll은 네트워크 I/O라 느릴 수 있음)
598
697
  {
599
698
  let mergedMCPConfigs = [...this.mcpServerConfigs];
600
699
  try {
601
700
  const fileConfig = await loadMCPConfig();
602
701
  if (fileConfig && fileConfig.servers.length > 0) {
603
- // Deduplicate by name — programmatic configs take precedence
604
702
  const existingNames = new Set(mergedMCPConfigs.map((s) => s.name));
605
703
  for (const server of fileConfig.servers) {
606
704
  if (!existingNames.has(server.name)) {
@@ -610,7 +708,6 @@ export class AgentLoop extends EventEmitter {
610
708
  }
611
709
  }
612
710
  catch (mcpLoadErr) {
613
- // Config parse error — warn and continue without file-based servers
614
711
  this.emitEvent({
615
712
  kind: "agent:error",
616
713
  message: `MCP config load warning: ${mcpLoadErr instanceof Error ? mcpLoadErr.message : String(mcpLoadErr)}`,
@@ -630,16 +727,13 @@ export class AgentLoop extends EventEmitter {
630
727
  });
631
728
  }
632
729
  catch {
633
- // MCP 연결 실패는 치명적이지 않음 — 로컬 도구만 사용
634
730
  this.mcpClient = null;
635
731
  this.mcpToolDefinitions = [];
636
732
  }
637
733
  }
638
734
  }
639
735
  // ReflexionEngine 생성
640
- if (projectPath) {
641
- this.reflexionEngine = new ReflexionEngine({ projectPath });
642
- }
736
+ this.reflexionEngine = new ReflexionEngine({ projectPath });
643
737
  // SelfReflection 생성 (6D deep verify + quick verify)
644
738
  if (this.enableSelfReflection) {
645
739
  const sessionId = `session-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
@@ -650,7 +744,6 @@ export class AgentLoop extends EventEmitter {
650
744
  minScoreToPass: 70,
651
745
  criticalDimensions: ["correctness", "security"],
652
746
  });
653
- // 메모리에서 기존 학습 복원
654
747
  if (this.memoryManager) {
655
748
  try {
656
749
  const memory = await this.memoryManager.load();
@@ -674,41 +767,12 @@ export class AgentLoop extends EventEmitter {
674
767
  totalTokenBudget: Math.floor(this.config.loop.totalTokenBudget * 0.3),
675
768
  });
676
769
  }
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
770
  // Self-model weakness context injection
707
771
  const weaknessCtx = getSelfWeaknessContext(this.capabilitySelfModel);
708
772
  if (weaknessCtx) {
709
773
  this.contextManager.addMessage({ role: "system", content: weaknessCtx });
710
774
  }
711
- // SkillLearner 초기화 (경험에서 학습된 스킬 자동 로드)
775
+ // SkillLearner 초기화 (경험에서 학습된 스킬 자동 로드 — slow disk I/O)
712
776
  if (this.enableSkillLearning && projectPath) {
713
777
  try {
714
778
  this.skillLearner = new SkillLearner(projectPath);
@@ -724,12 +788,9 @@ export class AgentLoop extends EventEmitter {
724
788
  this.failureSigMemory = new FailureSignatureMemory({ projectPath });
725
789
  this.playbookLibrary = new PlaybookLibrary();
726
790
  this.projectExecutive = new ProjectExecutive(projectPath);
727
- // Estimated iterations from config or default 20
728
791
  const estimatedIter = this.config.loop.maxIterations ?? 20;
729
792
  this.stallDetector = new StallDetector(estimatedIter);
730
- // Forward project executive events
731
793
  this.projectExecutive.on("event", (ev) => this.emitEvent(ev));
732
- // Phase 4 remaining: SelfImprovementLoop, MetaLearningCollector, TrustEconomics
733
794
  this.selfImprovementLoop = new SelfImprovementLoop({ projectPath });
734
795
  this.selfImprovementLoop.on("event", (ev) => this.emitEvent(ev));
735
796
  this.metaLearningCollector = new MetaLearningCollector({ projectPath });
@@ -743,7 +804,6 @@ export class AgentLoop extends EventEmitter {
743
804
  try {
744
805
  this.strategyLearner = new StrategyLearner();
745
806
  this.skillRegistry = new SkillRegistry();
746
- // Forward Phase 5 events
747
807
  this.strategyLearner.on("event", (ev) => this.emitEvent(ev));
748
808
  this.skillRegistry.on("event", (ev) => this.emitEvent(ev));
749
809
  }
@@ -758,7 +818,6 @@ export class AgentLoop extends EventEmitter {
758
818
  strategyLearner: this.strategyLearner ?? undefined,
759
819
  });
760
820
  this.toolSynthesizer = new ToolSynthesizer();
761
- // Forward Phase 5 extended events
762
821
  this.tracePatternExtractor.on("event", (ev) => this.emitEvent(ev));
763
822
  this.metaLearningEngine.on("event", (ev) => this.emitEvent(ev));
764
823
  this.toolSynthesizer.on("event", (ev) => this.emitEvent(ev));
@@ -776,7 +835,6 @@ export class AgentLoop extends EventEmitter {
776
835
  this.capabilityGraph.on("event", (ev) => this.emitEvent(ev));
777
836
  this.capabilitySelfModel.on("event", (ev) => this.emitEvent(ev));
778
837
  this.strategyMarket.on("event", (ev) => this.emitEvent(ev));
779
- // Register known tools in capability graph
780
838
  const toolNames = this.config.loop.tools.map((t) => t.name);
781
839
  registerToolsInGraph(this.capabilityGraph, toolNames);
782
840
  }
@@ -813,29 +871,22 @@ export class AgentLoop extends EventEmitter {
813
871
  }
814
872
  }
815
873
  // RepoKnowledgeGraph 초기화 (코드 구조 그래프 — 비동기 빌드)
816
- if (projectPath) {
817
- try {
818
- this.repoGraph = new RepoKnowledgeGraph(projectPath);
819
- // 백그라운드에서 그래프 빌드 (블로킹하지 않음)
820
- this.repoGraph.buildFromProject(projectPath).catch(() => {
821
- // 그래프 빌드 실패는 치명적이지 않음
822
- });
823
- }
824
- catch {
825
- this.repoGraph = null;
826
- }
874
+ try {
875
+ this.repoGraph = new RepoKnowledgeGraph(projectPath);
876
+ this.repoGraph.buildFromProject(projectPath).catch(() => { });
877
+ }
878
+ catch {
879
+ this.repoGraph = null;
827
880
  }
828
881
  // BackgroundAgentManager 초기화 (opt-in)
829
882
  if (this.enableBackgroundAgents && projectPath) {
830
883
  try {
831
884
  this.backgroundAgentManager = new BackgroundAgentManager();
832
885
  this.backgroundAgentManager.createDefaults(projectPath);
833
- // Background events → agent loop events
834
886
  for (const agent of this.backgroundAgentManager.list()) {
835
887
  const bgAgent = this.backgroundAgentManager.get(agent.id);
836
888
  if (bgAgent) {
837
889
  bgAgent.on("event", (event) => {
838
- // Emit structured bg_update for TUI task panel
839
890
  this.emitEvent({
840
891
  kind: "agent:bg_update",
841
892
  agentId: event.agentId,
@@ -853,7 +904,6 @@ export class AgentLoop extends EventEmitter {
853
904
  }
854
905
  }
855
906
  // 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
907
  const activeSkills = this.pluginRegistry.getAllSkills();
858
908
  if (activeSkills.length > 0) {
859
909
  const skillSummary = activeSkills
@@ -867,7 +917,7 @@ export class AgentLoop extends EventEmitter {
867
917
  // ContinuousReflection 생성 (1분 간격 체크포인트 + 자기검증 + 컨텍스트 모니터)
868
918
  this.continuousReflection = new ContinuousReflection({
869
919
  getState: () => this.getStateSnapshot(),
870
- checkpoint: async (state, emergency) => {
920
+ checkpoint: async (state, _emergency) => {
871
921
  if (!this.continuationEngine)
872
922
  return;
873
923
  const checkpoint = {
@@ -890,7 +940,6 @@ export class AgentLoop extends EventEmitter {
890
940
  await this.continuationEngine.saveCheckpoint(checkpoint);
891
941
  },
892
942
  selfVerify: async (prompt) => {
893
- // 경량 LLM 호출 (~200 토큰)로 자기검증
894
943
  try {
895
944
  const response = await this.llmClient.chat([{ role: "user", content: prompt }], []);
896
945
  const text = typeof response.content === "string"
@@ -932,8 +981,7 @@ export class AgentLoop extends EventEmitter {
932
981
  this.continuousReflection.on("reflection:context_overflow", () => {
933
982
  void this.handleSoftContextOverflow();
934
983
  });
935
- // Mark fully initialized — partialInit is cleared so timeout-interrupted
936
- // runs can detect that init completed (partialInit=false + initialized=true).
984
+ // Mark fully initialized
937
985
  this.initialized = true;
938
986
  this.partialInit = false;
939
987
  }
@@ -1015,15 +1063,18 @@ export class AgentLoop extends EventEmitter {
1015
1063
  dlog("AGENT-LOOP", `emitting agent:start, sessionId=${this.sessionId}`);
1016
1064
  this.emitEvent({ kind: "agent:start", goal: userMessage });
1017
1065
  // 첫 실행 시 메모리/프로젝트 컨텍스트 자동 로드
1018
- // init은 최대 5초만 블로킹 — Ollama/analyzeProject 느린 작업은 백그라운드 계속
1066
+ // criticalInit은 최대 1초만 블로킹 — LLM 호출 TTFT 최소화
1067
+ // backgroundInit은 fire-and-forget — LLM 호출을 블로킹하지 않음
1019
1068
  await Promise.race([
1020
- this.init(),
1021
- new Promise(resolve => setTimeout(resolve, 5_000)),
1069
+ this.criticalInit(),
1070
+ new Promise(resolve => setTimeout(resolve, 1_000)),
1022
1071
  ]);
1023
- // If init timed out (partialInit still true), allow retry on next run
1072
+ // If criticalInit timed out (partialInit still true), allow retry on next run
1024
1073
  if (this.partialInit && !this.initialized) {
1025
1074
  this.partialInit = false;
1026
1075
  }
1076
+ // Background init — does NOT block LLM call
1077
+ this.backgroundInit().catch(() => { });
1027
1078
  // Always generate a fresh sessionId per run — prevents BudgetGovernorV2
1028
1079
  // from accumulating exhausted task budget across multiple runs on the same instance.
1029
1080
  this.sessionId = randomUUID();
@@ -2217,39 +2268,8 @@ export class AgentLoop extends EventEmitter {
2217
2268
  });
2218
2269
  }
2219
2270
  }
2220
- // Bug 5 fix: use ContextCompressor as an alternative when context pressure is high (>70%)
2221
- // At 70-84% we apply intelligent priority-based compression before falling back to truncation.
2222
- if (contextUsageRatio >= 0.70 && contextUsageRatio < 0.85) {
2223
- try {
2224
- // Estimate maxTokens from the usage ratio and current message count
2225
- // contextUsageRatio = estimatedTokens / (maxTokens - outputReserve)
2226
- // We use a conservative 128_000 as a safe upper bound
2227
- const estimatedMaxTokens = 128_000;
2228
- const contextCompressor = new ContextCompressor({
2229
- maxTokens: estimatedMaxTokens,
2230
- reserveTokens: Math.ceil(estimatedMaxTokens * 0.15),
2231
- });
2232
- const currentMessages = this.contextManager.getMessages();
2233
- const currentTokenEstimate = Math.ceil(estimatedMaxTokens * contextUsageRatio);
2234
- const compressed = contextCompressor.compress(currentMessages, currentTokenEstimate);
2235
- if (compressed.evicted > 0 || compressed.summarized > 0) {
2236
- // Replace messages in contextManager with compressed version
2237
- // by clearing and re-adding (contextManager.addMessages is the public API)
2238
- const internalMessages = this.contextManager.messages;
2239
- if (internalMessages) {
2240
- internalMessages.length = 0;
2241
- internalMessages.push(...compressed.messages);
2242
- }
2243
- this.emitEvent({
2244
- kind: "agent:thinking",
2245
- content: `Context pressure ${Math.round(contextUsageRatio * 100)}%: ContextCompressor applied (evicted ${compressed.evicted}, summarized ${compressed.summarized} messages).`,
2246
- });
2247
- }
2248
- }
2249
- catch {
2250
- // ContextCompressor failure is non-fatal; ContextManager will handle via compactHistory
2251
- }
2252
- }
2271
+ // ContextCompressor block removed: prepareForLLM() already handles compression internally.
2272
+ // Double compression (ContextCompressor + prepareForLLM) caused redundant message eviction.
2253
2273
  if (contextUsageRatio >= 0.85) {
2254
2274
  if (!this.checkpointSaved) {
2255
2275
  await this.saveAutoCheckpoint(iteration);
@@ -3577,9 +3597,7 @@ export class AgentLoop extends EventEmitter {
3577
3597
  // ─── Step 1: Build execution plan ───────────────────────────────────────
3578
3598
  // Strategy:
3579
3599
  // • Read-only tools (low-risk) → batch together, run all in parallel
3580
- // • Write tools (independent files) use DependencyAnalyzer to group,
3581
- // run each independent group in parallel
3582
- // • Write tools (dependent files) → run sequentially after their deps
3600
+ // • Write tools run sequentially (wave 99)
3583
3601
  // • shell_exec / git_ops / etc. → always sequential (side-effects)
3584
3602
  const READ_ONLY = new Set(['file_read', 'grep', 'glob', 'code_search', 'security_scan']);
3585
3603
  const WRITE_TOOLS = new Set(['file_write', 'file_edit']);
@@ -3588,45 +3606,9 @@ export class AgentLoop extends EventEmitter {
3588
3606
  // ─── Step 2: Dependency-aware write tool batching ────────────────────────
3589
3607
  // Map each write tool call to a "wave index" (0 = can run first, 1 = needs wave-0 done, etc.)
3590
3608
  const writeBatchMap = new Map(); // tc.id → wave index
3591
- if (writeToolCalls.length > 1 && this.config.loop.projectPath) {
3592
- try {
3593
- const depAnalyzer = new DependencyAnalyzer();
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
- }
3609
+ // DependencyAnalyzer removed: it scanned the entire filesystem (50-1000ms blocking).
3610
+ // Write tools run sequentially (wave 0) — no dependency analysis overhead.
3611
+ // writeBatchMap stays empty → all writes default to wave 99 (sequential).
3630
3612
  // ─── Step 3: Build ordered batch list ────────────────────────────────────
3631
3613
  // Final structure: array of batches, each batch runs in parallel.
3632
3614
  // Reads accumulate until interrupted by a non-read tool.