Files
connectai/src/features/feedback/feedbackStore.ts
T
koriweb 990ea0ae5f feat: v2.2.173-193 — 4인 팀 운영 슬래시 13개 + ASTRA 검증 엔진 6종
4인 팀 운영 슬래시 (v2.2.173~189):
- 일과 리듬: /morning, /evening, /weekly, /standup
- 트래커 (event-sourced .astra/*.jsonl): /runway, /customers, /hire
- 작업·결정: /task, /blocked, /onesie, /decisions
- 외부 출력: /draft, /feedback
- 분석: /cohort (MoM 추세)

ASTRA 추론·검색 엔진 (v2.2.183~192):
- v2.2.183 Conflict Surface — scoring.conflictSeverity 를 [CONFLICT WARNINGS] 블록으로
  서피스 + 교차-문서 발산(Jaccard) 감지
- v2.2.184 Chain-of-Verification — [VERIFICATION CHECKLIST] 답변 작성 전 그라운딩 자기 점검
  (instructional, strictMode 옵션)
- v2.2.185 Actionability Scoring — 최근 슬래시 명령 + 열린 파일 신호로 검색 결과 재가중
- v2.2.186 Temporal Markers + Distillation Loop — LongTerm/Episodic 만료 필터 +
  30일+ stale episode → LongTerm 'episode-digest' 승급 (수동 /memory distill + 세션 종료 자동)
- v2.2.187 Hierarchical Context Window + LLM Semantic Re-rank — 3-level 추상도 매칭
  + 토큰 예산 통과 후 LLM 1회로 의도-부합 재정렬 (opt-in)
- v2.2.190 Intent Clarification + Citation Trace — 모호 차원 감지 시 역질문 우선
  + 답변 끝 사용 출처 한 줄 정리
- v2.2.191 Post-hoc Self-Check — 답변 완료 후 별도 LLM 호출 1회로 답함/그라운딩/모순 평가,
  footer 한 줄로 표시 (opt-in, semantic re-rank 와 같은 안전 fallback 패턴)
- v2.2.192 Terminology Dictionary — .astra/glossary.md 사용자 편집 파일 + Term Check
  지침 통합 + /glossary init/path/reload
- v2.2.193 /help — 카테고리별 명령 목록 + 6종 verification 블록 현재 on/off

신규 모듈:
- src/retrieval/{conflictBlock,coveBlock,actionabilityScoring,hierarchicalLevel,
  semanticRerank,intentClarification,citationTrace,terminologyBlock}.ts
- src/memory/distillation.ts + types.ts 에 expiresAt/promoted/episode-digest 추가
- src/agent/postHocSelfCheck.ts
- src/features/{customers,feedback,hire,runway}/*.ts (event-sourced stores)

ASTRA 검증 5종 자동 주입 (buildAstraModeSystemPrompt, casual 모드 제외):
[INTENT CLARIFICATION GUIDANCE] (답변 시작 전) → [TERMINOLOGY DICTIONARY] +
[CONFLICT WARNINGS] + [VERIFICATION CHECKLIST] (작성 중) → [CITATION TRACE] (끝)
+ 6번째: Post-hoc Self-Check footer (답변 완료 후, opt-in)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-29 16:05:30 +09:00

82 lines
3.3 KiB
TypeScript

/**
* 고객 피드백 누적 저장소.
*
* 단일 운영자(대표) 모드에서 슬랙·이메일·CS 채널에 흩어진 고객 피드백을
* `/feedback <텍스트>` 한 줄로 모아 둔다. 패턴 분석은 `/feedback summary` 로
* LLM 이 누적 데이터를 보고 카테고리 분포 + 반복 주제를 추출.
*
* 저장 형식: JSON Lines (.jsonl) — 한 줄 = 한 entry. 누적·append-only, 사람이
* 직접 편집 가능, grep / 백업 친화. 위치: `<workspace>/.astra/customer-feedback.jsonl`.
*
* 워크스페이스 폴더가 없으면 저장 불가 (null 반환). 사용자가 `/feedback path` 로
* 위치 확인 가능. 민감 정보 포함 가능성 있으므로 외부로 안 보냄 — 로컬 only.
*/
import * as fs from 'fs';
import * as path from 'path';
import * as vscode from 'vscode';
const STORE_REL_PATH = '.astra/customer-feedback.jsonl';
export interface FeedbackEntry {
/** unique id — timestamp 기반 (정렬·dedup 용도). */
id: string;
/** ISO timestamp of when this entry was captured. */
timestamp: string;
/** 사용자가 입력한 원본 텍스트 (그대로 보존). */
text: string;
/** 선택적 출처 — 'slack' / 'email' / 'cs' / 'review' 등. */
source?: string;
/** LLM 이 부여한 카테고리 (1~3개). */
categories?: string[];
/** LLM 판정 — 'positive' / 'neutral' / 'negative'. */
sentiment?: 'positive' | 'neutral' | 'negative';
}
export function getFeedbackFilePath(): string | null {
const folders = vscode.workspace.workspaceFolders;
if (!folders || folders.length === 0) return null;
return path.join(folders[0].uri.fsPath, STORE_REL_PATH);
}
export function readFeedback(): FeedbackEntry[] {
const filePath = getFeedbackFilePath();
if (!filePath || !fs.existsSync(filePath)) return [];
const out: FeedbackEntry[] = [];
let content = '';
try { content = fs.readFileSync(filePath, 'utf-8'); } catch { return []; }
for (const line of content.split('\n')) {
const trimmed = line.trim();
if (!trimmed) continue;
try {
const entry = JSON.parse(trimmed);
if (entry && typeof entry.id === 'string' && typeof entry.text === 'string') {
out.push(entry as FeedbackEntry);
}
} catch { /* skip malformed line — append-only 라 손상 1줄이 전체 무력화하면 안 됨 */ }
}
return out;
}
export function appendFeedback(entry: FeedbackEntry): { ok: true; filePath: string } | { ok: false; error: string } {
const filePath = getFeedbackFilePath();
if (!filePath) return { ok: false, error: '워크스페이스 폴더가 없어 저장 불가. VS Code 에서 폴더를 열어 주세요.' };
try {
fs.mkdirSync(path.dirname(filePath), { recursive: true });
fs.appendFileSync(filePath, JSON.stringify(entry) + '\n', 'utf-8');
return { ok: true, filePath };
} catch (e: any) {
return { ok: false, error: e?.message || String(e) };
}
}
/** 누적 항목 수 — 빠른 확인용. */
export function countFeedback(): number {
const filePath = getFeedbackFilePath();
if (!filePath || !fs.existsSync(filePath)) return 0;
try {
const content = fs.readFileSync(filePath, 'utf-8');
return content.split('\n').filter((l) => l.trim()).length;
} catch { return 0; }
}