Files
2nd/10_Wiki/Topics/Domain_Programming/Topic_Programming/Command_Pattern.md
T
Antigravity Agent c24165b8bc refactor(topics): 멀티 에이전트용 지식 재편 — _Common(공통 기본기) + Domain_* 구조
에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게
[공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류.
문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인).

- Topic_Programming → Domain_Programming (내부 구조 보존)
- Topic_Graphic → Domain_Design
- Topic_Business → Domain_Product
- Topic_General → Domain_General
- _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning),
  Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing)
- 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서)
- 빈 폴더 정리 (memory/procedures)
- 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-11 11:05:56 +09:00

3.2 KiB

id, title, category, status, verification_status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, created_at, updated_at, review_reason, merge_history, tags, raw_sources, applied_in, github_commit
id title category status verification_status canonical_id aliases duplicate_of source_trust_level confidence_score created_at updated_at review_reason merge_history tags raw_sources applied_in github_commit
pattern-command Command Pattern Pattern_Desktop draft applied
command pattern
커맨드 패턴
command registry
undo redo
action
A 0.86 2026-06-13 2026-06-13
pattern
desktop
command
behavioral
platform-independent
일반 소프트웨어 공학 지식
ConnectAI/src/extension.ts(registerCommand), src/agent/actions/* (적용 예)
ConnectAI

Command Pattern

🎯 한 줄 통찰 (One-line insight)

Command 패턴은 "요청(동작)을 객체/등록 항목으로 캡슐화" 해 실행을 호출자와 분리하고, 등록·취소(undo)·큐잉·로깅·단축키 매핑을 일관되게 만든다.

🧠 핵심 개념 (Core concepts)

  1. 명령 캡슐화: 동작을 id+핸들러로 등록.
  2. 레지스트리: id→핸들러 매핑(중앙 디스패치).
  3. undo/redo: 명령에 역연산 정의(선택).
  4. 메타데이터: 단축키·메뉴·가시성 조건.
  5. 분리: UI(버튼/메뉴)는 명령 id 만 알면 됨.

📖 세부 내용 (Details · 패턴 명세)

  • 언제 쓰나: 여러 진입점(메뉴/단축키/팔레트)이 같은 동작을 부를 때, undo/매크로/큐가 필요할 때.
  • 사용 조건: 동작을 id 로 표현; 핸들러 등록 메커니즘.
  • 장점: 호출자-실행자 분리, 재사용, undo/큐/로깅 일관, 확장 용이.
  • 단점: 명령 폭증, 단순 동작엔 과설계, 상태 전달 설계 필요.
  • 대안: 직접 함수 호출(소규모), 이벤트(반응형).
  • 실패 사례: 명령에 무거운 상태 결합; undo 불완전(부분 복원); id 충돌; 등록 해제 누락.

💻 코드 패턴 (Code patterns)

registry.register('app.save', () => save())     # 명령 = id + 핸들러
ui.button(onClick = () => exec('app.save'))     # UI 는 id 만
shortcut('Ctrl+S' -> 'app.save')                # 매핑 일관
# undo 지원 시: command = { do(), undo() }; history.push(command)

적용 예: ConnectAI 의 vscode.commands.registerCommand('g1nation.openChat', ...) (명령 레지스트리)와 action tag 실행기(<create_file> 등을 명령처럼 라우팅) [S2]. → Tool Calling Pattern.

⚖️ 모순 및 업데이트 (Contradictions & updates)

진입점이 하나면 함수 호출이 단순 — 다중 진입점/undo/큐가 필요할 때 Command 가 값을 한다.

🛠️ 적용 사례 (Applied in summary)

ConnectAI VS Code 명령 등록 + action 실행기.

🔗 지식 그래프 (Knowledge Graph)

📚 출처 (Sources)

  • [S1] 일반 Command 패턴(GoF) 지식
  • [S2] ConnectAI/src/extension.ts(registerCommand), agent/actions/* — 적용 예

📝 변경 이력 (Change history)

  • 2026-06-13: 프로젝트 독립 패턴 카드 작성.