feat(my-deepagent): v0.3 PR #7 — MYDEEPAGENT.md global+project hierarchy

Claude Code 의 CLAUDE.md 글로벌/프로젝트 레이어링 등가.  세션 시작 시 두
파일을 자동 로드해 시스템 프롬프트에 inject:
- Global: <config.data_dir>/MYDEEPAGENT.md (템플릿 자동 생성, idempotent)
- Project: <repo>/MYDEEPAGENT.md (있을 때만 로드, auto-create 안 함)

순서는 [global → project → MEMORY.md → entry .md] 라서 후순위 파일이
deepagents `MemoryMiddleware`의 "later overrides earlier" 규칙에 따라
더 구체적인 맥락으로 일반 지침을 덮을 수 있음.

데이터·라이브러리:
- `instructions.py` (신규):
  - `global_instructions_path(config)`, `project_instructions_path(repo_root)`
  - `ensure_global_instructions_initialized(config)` — 글로벌 템플릿 1회 생성.
    Korean-default 협업·코드 스타일 가이드 시드.  Idempotent (사용자 편집 보존).
  - `resolve_instruction_paths(config, repo_root)` — 존재하는 파일만 절대 경로로
    글로벌 → 프로젝트 순서 반환.

REPL 통합 (`cli/interactive.py`):
- `InteractiveSession.__init__`에서 `ensure_global_instructions_initialized`
  호출.
- `build_agent_if_needed`에서 `[*instructions, *memory]` 순서로
  `memory_paths_override` 구성 → deepagents memory= kwarg 까지 전파.

테스트 (`tests/integration/test_instructions.py`, 6 케이스):
- 글로벌 부트스트랩 + idempotency (수동 편집 보존)
- 프로젝트 파일은 auto-create 안 함
- 0/1/2 개 존재 시 `resolve_instruction_paths` 반환 순서 검증
- global path 가 data_dir 아래에 위치
- **integration**: `build_agent`가 결합 리스트를 `create_deep_agent(memory=...)`
  로 그대로 전달

게이트:
- ruff check / format --check / mypy: PASS
- pytest -q --ignore=tests/integration/test_e2e_workflow.py
  --ignore=tests/integration/test_openrouter_smoke.py: 671 passed (6 신규 포함)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
chungyeong
2026-05-17 20:55:06 +09:00
parent 5e9656e8a3
commit 61b34af0e4
4 changed files with 297 additions and 1 deletions

View File

@@ -2,6 +2,35 @@
## [Unreleased]
### Added
- **v0.3 PR #7 — MYDEEPAGENT.md instruction-file hierarchy**. Claude Code 의
CLAUDE.md 글로벌/프로젝트 레이어링 등가. 세션 시작 시 다음 두 파일을 자동
로드해 시스템 프롬프트에 함께 inject:
- **Global** : `<config.data_dir>/MYDEEPAGENT.md` — 부팅 시 템플릿 자동 생성
- **Project** : `<repo>/MYDEEPAGENT.md` — 존재할 때만 로드. 사용자 repo
안에 자동 생성하지 않음 (invasive 행위 회피).
Memory / MEMORY.md / 개별 entry 보다 *먼저* 인젝트되어 deepagents
`MemoryMiddleware` 의 "later overrides earlier" 규칙에 따라 더 구체적인
맥락이 일반적인 지침을 덮을 수 있음.
- `instructions.py` (신규):
- `global_instructions_path(config)`, `project_instructions_path(repo_root)`
- `ensure_global_instructions_initialized(config)` — 글로벌 템플릿 1회
생성, idempotent. Korean-default 협업·코드 스타일 가이드 시드.
- `resolve_instruction_paths(config, repo_root)` — 존재하는 파일만 절대
경로로 글로벌→프로젝트 순서 반환.
- `cli/interactive.py`:
- `InteractiveSession.__init__`에서 `ensure_global_instructions_initialized`
호출.
- `build_agent_if_needed`에서 `[*instruction_paths, *memory_paths]` 순서로
memory_paths_override 구성.
- `tests/integration/test_instructions.py` (신규, 6 케이스):
- 글로벌 부트스트랩 + idempotency (수동 편집 보존)
- 프로젝트 파일은 절대 auto-create 안 함
- 0/1/2 개 존재 시 `resolve_instruction_paths` 반환 순서 검증
- global path 가 `data_dir` 아래에 위치
- **integration**: `build_agent`가 결합된 [instructions, memory] 리스트를
그대로 `create_deep_agent(memory=...)` 로 전달
### Added
- **v0.3 PR #6 — Sub-agent session linkage (`/agents` / `/spawn <persona>`)**.
Claude Code의 sub-agent (task tool) 와 별개로, my-deepagent 만의 **persisted**