# Phase 0: Config 단일 소스 기반 생성

## 목표
아누 시스템 전체 모듈화의 기반이 되는 config 파일 4개 + Python 로더 1개 생성.
이후 Phase 1~3에서 모든 팀이 이 config를 참조하여 하드코딩을 제거함.

## 생성할 파일 5개

### 1. config/paths.json
```json
{
  "meta": {"version": "1.0", "last_updated": "2026-04-04"},
  "roots": {
    "workspace": "/home/jay/workspace",
    "memory": "/home/jay/workspace/memory",
    "projects": "/home/jay/workspace/projects",
    "dashboard": "/home/jay/workspace/dashboard",
    "tools": "/home/jay/workspace/tools",
    "output": "/home/jay/workspace/output",
    "config": "/home/jay/workspace/config"
  },
  "project_dirs": {
    "threadauto": "/home/jay/projects/ThreadAuto",
    "insuro": "/home/jay/projects/InsuRo"
  },
  "memory_dirs": {
    "tasks": "memory/tasks",
    "reports": "memory/reports",
    "events": "memory/events",
    "daily": "memory/daily",
    "specs": "memory/specs",
    "meetings": "memory/meetings",
    "research": "memory/research"
  }
}
```

### 2. config/constants.json
현재 시스템에서 실제 사용되는 값을 추출하여 작성:
- `chat_id`: "6937032012" (현재 83곳에 하드코딩)
- `cokacdir_key`: 환경변수 참조만 (값 저장 금지)
- `teams`: dispatch.py의 TEAM_BOT dict에서 추출
- `bots`: bot_settings_sync.json에서 봇별 팀/모델 매핑 추출
- `work_levels`: 0~4 레벨 정의
- `thresholds`: task_id_gap(1000), idle_hours(3), ghost_hours(4)

### 3. config/design-system.json
- `palette`: 대시보드 + 배너에서 사용되는 색상 코드 통합
  - dashboard JS에서 실제 사용되는 색상 추출 (SkillView, CampaignSections 등)
- `typography`: Pretendard, Black Han Sans, 나눔명조 등
- `font_rules`: dq-rules.json 참조 (중복 금지, 경로만)

### 4. config/module-registry.json
- `sources`: 각 단일 소스 → 사용 파일 목록 매핑
  - 예: "chat_id" → {"file": "constants.json", "key": "chat_id", "used_by": ["dispatch.py", "chain.py", ...]}
- `rules`: "이 값을 수정하면 used_by 파일 모두 영향"
- 초기 등록 대상: chat_id, workspace_root, team_bot_mapping, dq_rules, design_palette

### 5. config/loader.py
```python
"""Config 통합 로더 — 모든 모듈이 이 로더를 통해 config에 접근"""
import json, os
from pathlib import Path

CONFIG_DIR = Path(__file__).parent

class ConfigManager:
    _instance = None
    
    @classmethod
    def get_instance(cls):
        if cls._instance is None:
            cls._instance = cls()
        return cls._instance
    
    def __init__(self):
        self.paths = self._load("paths.json")
        self.constants = self._load("constants.json")
        self.design = self._load("design-system.json")
        self.registry = self._load("module-registry.json")
    
    def _load(self, filename):
        with open(CONFIG_DIR / filename) as f:
            return json.load(f)
    
    def get_path(self, key):
        """paths.json에서 경로 조회"""
        ...
    
    def get_constant(self, key):
        """constants.json에서 상수 조회"""
        ...
    
    def get_dependents(self, source_id):
        """registry에서 해당 값 사용 파일 목록 반환"""
        return self.registry["sources"].get(source_id, {}).get("used_by", [])
```

## 데이터 추출 작업
config 파일에 넣을 실제 값을 기존 코드에서 추출해야 함:
- `dispatch.py`에서 TEAM_BOT, CHAT_ID, BOT_CHAT_MAPPING 추출
- `dashboard/components/*.js`에서 색상 코드 추출
- `scripts/*.py`에서 CHAT_ID 사용 현황 추출
- `bot_settings_sync.json`에서 봇 매핑 추출

## 검증 기준
1. config 파일 4개 JSON 문법 정상
2. loader.py import 정상 + get_path/get_constant 동작
3. 기존 테스트 전체 통과 (이 Phase에서는 기존 코드 수정 없음, 신규 생성만)
4. 3 Step Why: 왜 4개 파일인가? → 역할 분리(경로/상수/디자인/레지스트리)

## 절대 건드리면 안 되는 파일
- 기존 코드 일체 (이 Phase에서는 신규 생성만)
- bot_settings.json 원본 (읽기만)
- dq-rules.json (이미 완성, 참조만)

## 산출물
1. config/paths.json
2. config/constants.json
3. config/design-system.json
4. config/module-registry.json
5. config/loader.py
6. 보고서
