Files
connectai/task_plan.md
T

5.2 KiB

📋 Task Plan: Agentic Skill & Negative Prompt Integration

1. 개요 (Overview)

ConnectAI(G1nation) 익스텐션의 사이드바(Webview)에 'Agentic Skill(자율 에이전트 스킬)' 선택 기능과 'Negative Prompt(금지어/금지행동)' 입력 기능을 추가합니다. 사용자가 사이드바에서 직접 새로운 에이전트 프롬프트를 작성하면, 이를 지정된 디렉토리에 Markdown(.md) 파일로 영구 저장하여 유지보수성을 극대화합니다. 생성된 에이전트 스킬과 네거티브 프롬프트는 LLM 질의 시 System Prompt로 동적 병합(Injection)됩니다.

2. 기술 스택 (Tech Stack)

  • Frontend (Webview): HTML, Vanilla JavaScript, VS Code Webview API, TailwindCSS (기존 스타일링 기준)
  • Backend (Extension): TypeScript, Node.js fs (File System), path 모듈
  • Data Storage: 로컬 파일 시스템 (Markdown .md 파일)
  • Target Path: E:\Wiki\Agent\.agent\skills\ (또는 VSCode Workspace 설정에 따른 상대 경로, 기본값으로 활용)

3. UI/UX 상세 설계 (세밀한 텍스트 묘사)

사이드바(sidebarProvider.ts 내부 HTML 템플릿)의 형태가 다음과 같이 변경/추가됩니다.

  1. Agentic Skill 섹션
    • 라벨: Agentic Skill
    • 드롭다운 (<select>): Local Brain 선택창 바로 아래에 위치. 기본값은 None. E:\Wiki\Agent\.agent\skills\ 폴더를 스캔하여 .md 파일 목록을 옵션으로 렌더링.
    • [+ Create Agent] 버튼: 드롭다운 우측 또는 하단에 위치. 80% 너비의 푸른색 계열 버튼(또는 기존 테마에 맞춘 Accent 버튼). 클릭 시 '새 에이전트 생성' 폼(모달 혹은 토글 영역) 노출.
  2. 에이전트 생성 폼 (숨김/노출형)
    • Agent Name (<input>): 에이전트의 이름 (파일명으로 사용됨).
    • Agent Prompt (<textarea>): 에이전트의 역할과 지시사항을 입력하는 넓은 텍스트 에어리어.
    • [Save & Select] 버튼: 저장 후 즉시 드롭다운에서 해당 에이전트를 선택 상태로 변경.
  3. Negative Prompt 섹션
    • 라벨: Negative Prompt (Do NOT do)
    • 입력창 (<textarea>): 프롬프트 창 위에 위치. 3줄 정도 높이의 텍스트 에어리어. 에이전트가 "절대 하지 말아야 할 행동"을 기입.

4. 데이터 플로우 및 ERD (Data Architecture)

sequenceDiagram
    participant User
    participant Webview as VSCode Sidebar (Webview)
    participant ExtHost as Extension (sidebarProvider.ts)
    participant FS as File System (.md)
    participant Agent as Agent Logic (agent.ts)

    %% 새 에이전트 생성 흐름
    User->>Webview: [+ Create Agent] 클릭 및 폼 입력 후 Save
    Webview->>ExtHost: postMessage({ type: 'createAgent', name, prompt })
    ExtHost->>FS: fs.writeFileSync(AgentPath/name.md, prompt)
    ExtHost->>FS: fs.readdirSync(AgentPath)
    FS-->>ExtHost: 갱신된 파일 목록 반환
    ExtHost->>Webview: postMessage({ type: 'updateAgentList', agents })
    Webview-->>User: 드롭다운 업데이트 및 자동 선택

    %% 질의 및 프롬프트 주입 흐름
    User->>Webview: 채팅 입력 후 Submit
    Webview->>ExtHost: postMessage({ type: 'ask', value, agentSkill, negativePrompt })
    ExtHost->>FS: fs.readFileSync(AgentPath/agentSkill.md)
    FS-->>ExtHost: Agent Markdown 내용 반환
    ExtHost->>Agent: ask(query, context, agentContent, negativePrompt)
    Note over Agent: System Prompt 완벽 병합
    Agent-->>Webview: LLM 응답 스트리밍

5. 핵심 로직 명세 (Implementation Details)

A. sidebarProvider.ts 변경 사항

  • 메시지 핸들러 추가 (_webviewView.webview.onDidReceiveMessage):
    • getAgents: 디렉토리 스캔 후 .md 파일 목록 반환.
    • createAgent: 파일명 정규화(공백을 _로 치환 등) 후 fs.writeFileSync를 통해 마크다운 생성. 생성 후 getAgents 동작 수행.
  • Webview HTML 업데이트: 새로운 select, textarea, button 추가. JS 로직에서 VS Code API를 통해 메시지 송수신 이벤트 리스너 부착.

B. agent.ts 변경 사항 (Prompt Injection)

  • systemPrompt 또는 context 조립 단계에서 다음 구조로 병합 수행:
    [Base Extension Instructions]
    ...
    <Local Brain Context (if any)>
    ...
    # [Agent Persona / Instructions]
    {{AgentContent (from .md file)}}
    ...
    # [Negative Prompt / Strict Rules]
    DO NOT do the following:
    {{NegativePrompt}}
    

6. 예상되는 리스크 및 대안 (Pre-mortem)

  1. 경로 문제 (Unknown Path Risk):
    • 문제: E:\Wiki\Agent\.agent\skills 경로가 다른 환경(Mac 등)이나 설정되지 않은 워크스페이스에서 오류를 발생시킬 수 있음.
    • 대안: fs.existsSync로 폴더 존재 여부 우선 체크. 폴더가 없으면 에러를 띄우거나, 워크스페이스 루트 내 .agents 폴더를 임시로 생성하도록 방어 코드(Fallback) 작성.
  2. 에이전트 이름 중복 및 특수문자:
    • 문제: 파일 시스템에 부적절한 이름 저장 시 에러.
    • 대안: 파일명 저장 시 영문/한글/숫자 외 특수문자 제거 정규식 적용. 중복 시 덮어쓰기 로직 처리.