990ea0ae5f
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>
170 lines
7.0 KiB
TypeScript
170 lines
7.0 KiB
TypeScript
/**
|
|
* Google Tasks API v1 — task create 호출.
|
|
*
|
|
* Calendar / Sheets 와 같은 OAuth 토큰을 공유한다 (scope 에 `tasks` 포함).
|
|
* Tasks 는 date-only 모델(시간 없음)이라 /meet 의 액션 아이템처럼 "시간 없이
|
|
* 마감일만 있는 할 일" 에 자연스럽게 맞는다.
|
|
*
|
|
* 외부 라이브러리 안 씀 — Tasks API 도 REST 라 native fetch 면 충분.
|
|
*/
|
|
|
|
import * as vscode from 'vscode';
|
|
import { getFreshAccessToken } from './calendarApi';
|
|
|
|
const API_BASE = 'https://tasks.googleapis.com/tasks/v1';
|
|
|
|
export interface TaskInput {
|
|
/** 작업 제목 (필수). */
|
|
title: string;
|
|
/** 마감일 'YYYY-MM-DD' — Google Tasks 는 시간 무시, 날짜만 사용. */
|
|
due: string;
|
|
/** 메모 (옵션) — Tasks UI 에서 작업 본문 아래 노트로 표시. */
|
|
notes?: string;
|
|
/**
|
|
* 작업이 들어갈 task list ID. default `@default` — 기본 list ("내 할 일").
|
|
* 사용자가 별도 list 를 만들었으면 그 ID 를 넣으면 됨.
|
|
*/
|
|
taskListId?: string;
|
|
}
|
|
|
|
export interface CreatedTask {
|
|
/** Google 이 발급한 task id. */
|
|
id: string;
|
|
title: string;
|
|
due: string;
|
|
/** Google Tasks API 의 self link (API 용). 사용자용 deep link 는 별도로 없음. */
|
|
selfLink?: string;
|
|
}
|
|
|
|
/**
|
|
* Google Tasks 에 작업 생성. config 에 refresh token 있어야 함. access token 자동 갱신.
|
|
*
|
|
* 사용자가 Tasks 스코프 미동의(예전 OAuth 만 한 사용자) 면 Google 이 401/403 으로
|
|
* 거부 → `error` 에 그 메시지가 친화적 형태로 전달되고, 사용자는 OAuth 재연결 안내를 본다.
|
|
*
|
|
* 반환값:
|
|
* ok: true → CreatedTask
|
|
* ok: false → 에러 메시지 (UI 표시용)
|
|
*/
|
|
export async function createTask(
|
|
context: vscode.ExtensionContext,
|
|
input: TaskInput,
|
|
): Promise<{ ok: true; task: CreatedTask } | { ok: false; error: string }> {
|
|
if (!input.title?.trim()) return { ok: false, error: 'title 비어 있음' };
|
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(input.due)) {
|
|
return { ok: false, error: `due 는 'YYYY-MM-DD' 형식이어야 함 (받은 값: ${input.due})` };
|
|
}
|
|
|
|
const tokenResult = await getFreshAccessToken(context);
|
|
if (!tokenResult.ok) return { ok: false, error: tokenResult.error };
|
|
|
|
const taskListId = (input.taskListId || '@default').trim() || '@default';
|
|
const url = `${API_BASE}/lists/${encodeURIComponent(taskListId)}/tasks`;
|
|
const body = {
|
|
title: input.title.trim(),
|
|
// Tasks API 의 `due` 는 RFC3339 timestamp 인데 시간 부분은 서버에서 무시되고
|
|
// 날짜만 사용. UTC midnight 으로 보내는 게 표준 패턴.
|
|
due: `${input.due}T00:00:00.000Z`,
|
|
...(input.notes ? { notes: input.notes } : {}),
|
|
};
|
|
|
|
try {
|
|
const res = await fetch(url, {
|
|
method: 'POST',
|
|
headers: {
|
|
Authorization: `Bearer ${tokenResult.accessToken}`,
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify(body),
|
|
signal: AbortSignal.timeout(15000),
|
|
});
|
|
const json: any = await res.json().catch(() => ({}));
|
|
if (!res.ok) {
|
|
const msg: string = json?.error?.message || `HTTP ${res.status}`;
|
|
// 스코프/권한 부족이면 사용자 친화 안내로 변환 — 어떤 명령을 다시 실행해야 하는지 명시.
|
|
if (res.status === 401 || res.status === 403 || /insufficient|scope|disabled|enable/i.test(msg)) {
|
|
return {
|
|
ok: false,
|
|
error: `Tasks API 권한 부족 — "Astra: Google Calendar OAuth 연결 (쓰기)" 명령을 다시 실행해 Tasks 스코프 동의가 필요합니다. (Google Cloud Console 에서 Tasks API 활성화도 함께 확인) 원인: ${msg}`,
|
|
};
|
|
}
|
|
return { ok: false, error: msg };
|
|
}
|
|
return {
|
|
ok: true,
|
|
task: {
|
|
id: json.id,
|
|
title: json.title,
|
|
due: input.due,
|
|
selfLink: json.selfLink,
|
|
},
|
|
};
|
|
} catch (e: any) {
|
|
return { ok: false, error: e?.message || String(e) };
|
|
}
|
|
}
|
|
|
|
export interface ListedTask {
|
|
id: string;
|
|
title: string;
|
|
status: 'needsAction' | 'completed';
|
|
/** 'YYYY-MM-DD' 형식. due 가 없는 task 는 undefined. */
|
|
due?: string;
|
|
/** 완료 시각 ISO timestamp. status 'completed' 일 때만 있음. */
|
|
completed?: string;
|
|
notes?: string;
|
|
}
|
|
|
|
/**
|
|
* Google Tasks 목록 조회 — /onesie 1:1 카드 등에서 멤버별 필터링용.
|
|
*
|
|
* 기본 default list 의 task 들을 가져온다 (완료 포함). 호출자가 클라이언트 측에서
|
|
* 제목 prefix `[멤버]` 나 notes 의 `@멤버` / `담당: 멤버` 패턴으로 필터하면 됨.
|
|
*/
|
|
export async function listTasks(
|
|
context: vscode.ExtensionContext,
|
|
options: { taskListId?: string; showCompleted?: boolean; maxResults?: number } = {},
|
|
): Promise<{ ok: true; tasks: ListedTask[] } | { ok: false; error: string }> {
|
|
const tokenResult = await getFreshAccessToken(context);
|
|
if (!tokenResult.ok) return { ok: false, error: tokenResult.error };
|
|
|
|
const taskListId = (options.taskListId || '@default').trim() || '@default';
|
|
const params = new URLSearchParams({
|
|
maxResults: String(options.maxResults ?? 100),
|
|
showCompleted: options.showCompleted !== false ? 'true' : 'false',
|
|
showHidden: 'true', // 완료 후 숨김 처리된 것도 포함 — 1:1 회고에 최근 완료가 중요.
|
|
});
|
|
const url = `${API_BASE}/lists/${encodeURIComponent(taskListId)}/tasks?${params.toString()}`;
|
|
|
|
try {
|
|
const res = await fetch(url, {
|
|
method: 'GET',
|
|
headers: { Authorization: `Bearer ${tokenResult.accessToken}` },
|
|
signal: AbortSignal.timeout(15000),
|
|
});
|
|
const json: any = await res.json().catch(() => ({}));
|
|
if (!res.ok) {
|
|
const msg: string = json?.error?.message || `HTTP ${res.status}`;
|
|
if (res.status === 401 || res.status === 403 || /insufficient|scope/i.test(msg)) {
|
|
return {
|
|
ok: false,
|
|
error: `Tasks API 권한 부족 — "Astra: Google Calendar OAuth 연결 (쓰기)" 명령 재실행 + Tasks 스코프 동의 필요. (원인: ${msg})`,
|
|
};
|
|
}
|
|
return { ok: false, error: msg };
|
|
}
|
|
const items: any[] = Array.isArray(json.items) ? json.items : [];
|
|
const tasks: ListedTask[] = items.map((item: any) => ({
|
|
id: String(item.id || ''),
|
|
title: String(item.title || ''),
|
|
status: item.status === 'completed' ? 'completed' : 'needsAction',
|
|
due: typeof item.due === 'string' ? item.due.slice(0, 10) : undefined,
|
|
completed: typeof item.completed === 'string' ? item.completed : undefined,
|
|
notes: typeof item.notes === 'string' ? item.notes : undefined,
|
|
}));
|
|
return { ok: true, tasks };
|
|
} catch (e: any) {
|
|
return { ok: false, error: e?.message || String(e) };
|
|
}
|
|
}
|