feat: v2.2.92 → v2.2.158 — god-file 분해 + Stocks feature + 대화 연속성

R56–R59: agent.ts 2731→1529줄 god-file 분해 (25 modules)
  · attrParsers + LLM 메서드 8개 (callNonStreaming, streamChatOnce 등)
  · executeActions 415줄 → 8 handler 그룹 (file/run/list/brain/calendar/sheets/tasks)
  · handlePrompt 1100줄 → 7 phase 모듈 (system prompt + budget + autoContinue 등)

R50–R55: extension.ts 1145→349줄 (telegram/settings/provider commands 분리)

Stocks feature 신규: /stocks slash command (v2.2.152~158)
  · .astra/stocks.json 저장소 + Yahoo Finance 현재가 갱신
  · 8 키워드 필터 (ROE/성장성/유동성/수익성/영업효율/기술력/안정성/PBR)
  · Naver 시가총액 페이지 JSON API (m.stock.naver.com) 발굴
  · LLM Top 5 매력도 분석 + Telegram 자동 보고서
  · KST 09:00/15:00 watcher 자동 모니터링

대화 연속성 (v2.2.150~157):
  · [PRIOR TURN CONCLUSION] block 으로 직전 결론 anchor
  · thin follow-up 분류 → boilerplate 헤더 suppression
  · slash 명령 결과 chatHistory mirror (capture wrapper)
  · echo/parrot 금지 system prompt rule

기타: /stocks 슬래시 자동완성 dropdown UI, Naver JSON API 전환 (cheerio 제거)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
g1nation
2026-05-25 09:59:32 +09:00
parent 4153f640c2
commit 0a97324f1b
149 changed files with 14628 additions and 6927 deletions
@@ -0,0 +1,82 @@
import {
isProjectKnowledgeCreationRequest,
buildAstraStanceContext,
} from '../../lib/contextBuilders/localProjectIntent';
import { isThinkingPartnerRequest } from '../../lib/contextBuilders/promptDetection';
import { buildKnowledgeMixPolicy } from '../../retrieval/knowledgeMix';
export interface BuildAstraModeSystemPromptInput {
prompt: string | null;
systemPrompt: string;
modeBridgeCtx: string;
/** [PRIOR TURN CONCLUSION] 블록 — 직전 assistant 답변의 첫 문장. follow-up 정정 대응용. */
priorConclusionCtx: string;
designerCtx: string;
projectArchitectureCtx: string;
secondBrainTraceCtx: string;
memoryCtx: string;
knowledgeContextForPrompt: string;
contextBlock: string;
negativeCtx: string;
isCasualConversation: boolean;
localPathContext: string;
/** From this._turnCtx.knowledgeMix — pass null when absent. */
knowledgeMix: any;
}
export function buildAstraModeSystemPrompt(input: BuildAstraModeSystemPromptInput): string {
const {
prompt,
systemPrompt,
modeBridgeCtx,
priorConclusionCtx,
designerCtx,
projectArchitectureCtx,
secondBrainTraceCtx,
memoryCtx,
knowledgeContextForPrompt,
contextBlock,
negativeCtx,
isCasualConversation,
localPathContext,
knowledgeMix,
} = input;
// 기존 Astra 모드 (에이전트 미선택)
const localProjectKnowledgeCtx = prompt && localPathContext && isProjectKnowledgeCreationRequest(prompt)
? `\n\n[LOCAL PROJECT KNOWLEDGE CREATION OVERRIDE]\nThe user gave an accessible local project path and asked to create project knowledge. Do not ask blocking scope questions. Use a sensible default MVP: create or propose a project overview note from the inspected tree and priority file previews. If writing is not explicitly safe, provide the concrete note draft and target path.`
: '';
const thinkingPartnerCtx = prompt && !isCasualConversation && isThinkingPartnerRequest(prompt)
? `\n\n[JARVIS THINKING PARTNER MODE]\nThe user is using this tool to clarify project direction, not just to receive generic advice. Give a clear opinionated verdict first. Then separate confirmed facts, inferences, concerns, decision forks, and the next small action. Do not merely say the direction is good. If evidence is thin, say exactly what is missing and what file or record should be checked next.`
: '';
const astraStanceCtx = prompt && !isCasualConversation
? `\n\n${buildAstraStanceContext(prompt, localPathContext)}`
: '';
// The v4 knowledge-management policy only matters when knowledge is actually in play —
// skip it for greetings/small talk so it doesn't dilute the [CASUAL CONVERSATION MODE] directive.
const v4PolicyCtx = isCasualConversation ? '' : [
"\n### 🏛️ 지식 관리 정책 v4.0 (Knowledge Management Policy Applied)",
"- [신뢰도] '의도적으로 작성된 글'은 Medium 이상의 신뢰도를 부여하여 최우선 근거로 활용할 것.",
"- [품질] 데이터의 양보다 '추론 기여 밀도'를 중시하여 핵심 위주로 깊이 있게 서술할 것.",
"- [충돌] 지식 간 충돌 발생 시 시스템이 독단적으로 판단하지 말고, 반드시 [CONFLICT WARNING] 플래그와 함께 상충되는 두 관점을 모두 명시하여 사용자에게 판단을 위임할 것."
].join('\n');
// [CONTEXT] … [/CONTEXT] 사이만 컨텍스트 초과 시 trim 대상 — negative constraints 는 보호.
const casualCtx = isCasualConversation
? '\n\n[CASUAL CONVERSATION MODE]\nThe user sent a greeting, acknowledgement, or light conversational message. Reply naturally and briefly to the message itself. Do not use Second Brain, memory, project records, reports, references, or analysis unless the user explicitly asks for them.'
: '';
// Knowledge Mix policy: tells the model how strongly to lean on Second Brain
// evidence vs. its own general knowledge for this turn. Suppressed for casual
// chat — pure greetings don't need to be told anything about RAG balance.
const knowledgeMixCtx = (!isCasualConversation && knowledgeMix)
? (() => {
const block = buildKnowledgeMixPolicy(knowledgeMix);
return block ? `\n\n${block}` : '';
})()
: '';
// memoryCtx(RAG/메모리/lessons)는 [CONTEXT] 안에 — 토큰이 빡빡하면 대화 기록보다 먼저 잘림.
// priorConclusionCtx 는 modeBridgeCtx 와 같은 위치 (base systemPrompt 직후) — 모델이
// 자기 직전 결론을 anchor 로 잡고 사용자의 follow-up 을 그 결론에 대한 정정으로 해석하게.
const priorConclusionBlock = priorConclusionCtx ? '\n\n' + priorConclusionCtx : '';
return `${systemPrompt}${modeBridgeCtx ? '\n\n' + modeBridgeCtx : ''}${priorConclusionBlock}${designerCtx}${projectArchitectureCtx}${localProjectKnowledgeCtx}${thinkingPartnerCtx}${astraStanceCtx}${secondBrainTraceCtx}${v4PolicyCtx}${knowledgeMixCtx}${casualCtx}\n\n[CONTEXT]\n${memoryCtx}\n${knowledgeContextForPrompt}\n${contextBlock}\n[/CONTEXT]\n${negativeCtx}`;
}