@yuaone/core 0.3.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/dist/agent-loop.d.ts +62 -0
  2. package/dist/agent-loop.d.ts.map +1 -1
  3. package/dist/agent-loop.js +705 -18
  4. package/dist/agent-loop.js.map +1 -1
  5. package/dist/background-agent.d.ts +110 -0
  6. package/dist/background-agent.d.ts.map +1 -0
  7. package/dist/background-agent.js +255 -0
  8. package/dist/background-agent.js.map +1 -0
  9. package/dist/coding-standards.d.ts +45 -0
  10. package/dist/coding-standards.d.ts.map +1 -0
  11. package/dist/coding-standards.js +1152 -0
  12. package/dist/coding-standards.js.map +1 -0
  13. package/dist/constants.d.ts.map +1 -1
  14. package/dist/constants.js +2 -6
  15. package/dist/constants.js.map +1 -1
  16. package/dist/context-manager.d.ts +6 -0
  17. package/dist/context-manager.d.ts.map +1 -1
  18. package/dist/context-manager.js +23 -4
  19. package/dist/context-manager.js.map +1 -1
  20. package/dist/index.d.ts +28 -4
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +26 -2
  23. package/dist/index.js.map +1 -1
  24. package/dist/llm-client.d.ts +8 -3
  25. package/dist/llm-client.d.ts.map +1 -1
  26. package/dist/llm-client.js +64 -13
  27. package/dist/llm-client.js.map +1 -1
  28. package/dist/plugin-auto-loader.d.ts +108 -0
  29. package/dist/plugin-auto-loader.d.ts.map +1 -0
  30. package/dist/plugin-auto-loader.js +743 -0
  31. package/dist/plugin-auto-loader.js.map +1 -0
  32. package/dist/plugin-registry.d.ts +112 -0
  33. package/dist/plugin-registry.d.ts.map +1 -0
  34. package/dist/plugin-registry.js +319 -0
  35. package/dist/plugin-registry.js.map +1 -0
  36. package/dist/plugin-types.d.ts +388 -0
  37. package/dist/plugin-types.d.ts.map +1 -0
  38. package/dist/plugin-types.js +8 -0
  39. package/dist/plugin-types.js.map +1 -0
  40. package/dist/plugin-validator.d.ts +54 -0
  41. package/dist/plugin-validator.d.ts.map +1 -0
  42. package/dist/plugin-validator.js +129 -0
  43. package/dist/plugin-validator.js.map +1 -0
  44. package/dist/repo-knowledge-graph.d.ts +112 -0
  45. package/dist/repo-knowledge-graph.d.ts.map +1 -0
  46. package/dist/repo-knowledge-graph.js +561 -0
  47. package/dist/repo-knowledge-graph.js.map +1 -0
  48. package/dist/role-registry.js +1 -1
  49. package/dist/role-registry.js.map +1 -1
  50. package/dist/self-debug-loop.d.ts +257 -0
  51. package/dist/self-debug-loop.d.ts.map +1 -0
  52. package/dist/self-debug-loop.js +870 -0
  53. package/dist/self-debug-loop.js.map +1 -0
  54. package/dist/skill-learner.d.ts +136 -0
  55. package/dist/skill-learner.d.ts.map +1 -0
  56. package/dist/skill-learner.js +382 -0
  57. package/dist/skill-learner.js.map +1 -0
  58. package/dist/skill-loader.d.ts +90 -0
  59. package/dist/skill-loader.d.ts.map +1 -0
  60. package/dist/skill-loader.js +309 -0
  61. package/dist/skill-loader.js.map +1 -0
  62. package/dist/specialist-registry.d.ts +132 -0
  63. package/dist/specialist-registry.d.ts.map +1 -0
  64. package/dist/specialist-registry.js +413 -0
  65. package/dist/specialist-registry.js.map +1 -0
  66. package/dist/sub-agent-prompts.d.ts +45 -0
  67. package/dist/sub-agent-prompts.d.ts.map +1 -0
  68. package/dist/sub-agent-prompts.js +177 -0
  69. package/dist/sub-agent-prompts.js.map +1 -0
  70. package/dist/sub-agent-router.d.ts +75 -0
  71. package/dist/sub-agent-router.d.ts.map +1 -0
  72. package/dist/sub-agent-router.js +174 -0
  73. package/dist/sub-agent-router.js.map +1 -0
  74. package/dist/sub-agent.d.ts +48 -0
  75. package/dist/sub-agent.d.ts.map +1 -1
  76. package/dist/sub-agent.js +108 -5
  77. package/dist/sub-agent.js.map +1 -1
  78. package/dist/system-prompt.d.ts +26 -0
  79. package/dist/system-prompt.d.ts.map +1 -1
  80. package/dist/system-prompt.js +177 -7
  81. package/dist/system-prompt.js.map +1 -1
  82. package/dist/task-classifier.d.ts +25 -1
  83. package/dist/task-classifier.d.ts.map +1 -1
  84. package/dist/task-classifier.js +171 -1
  85. package/dist/task-classifier.js.map +1 -1
  86. package/dist/tool-planner.d.ts +160 -0
  87. package/dist/tool-planner.d.ts.map +1 -0
  88. package/dist/tool-planner.js +501 -0
  89. package/dist/tool-planner.js.map +1 -0
  90. package/dist/types.d.ts +1 -1
  91. package/dist/types.d.ts.map +1 -1
  92. package/package.json +2 -1
  93. package/plugins/git/patterns/branch-patterns.json +101 -0
  94. package/plugins/git/patterns/commit-patterns.json +186 -0
  95. package/plugins/git/plugin.yaml +128 -0
  96. package/plugins/git/skills/branch-strategy.md +172 -0
  97. package/plugins/git/skills/commit-conv.md +178 -0
  98. package/plugins/git/skills/conflict-resolve.md +159 -0
  99. package/plugins/git/skills/history-clean.md +199 -0
  100. package/plugins/git/skills/pr-review.md +196 -0
  101. package/plugins/git/strategies/conflict-resolve.json +244 -0
  102. package/plugins/git/strategies/release-flow.json +292 -0
  103. package/plugins/git/validators/rules.json +348 -0
  104. package/plugins/react/patterns/anti-patterns.json +88 -0
  105. package/plugins/react/patterns/components.json +80 -0
  106. package/plugins/react/patterns/hooks.json +72 -0
  107. package/plugins/react/plugin.yaml +229 -0
  108. package/plugins/react/skills/bugfix.md +208 -0
  109. package/plugins/react/skills/component-gen.md +206 -0
  110. package/plugins/react/skills/hook-extract.md +208 -0
  111. package/plugins/react/skills/ssr.md +256 -0
  112. package/plugins/react/skills/test.md +273 -0
  113. package/plugins/react/strategies/build-fix.json +43 -0
  114. package/plugins/react/strategies/hook-loop-fix.json +36 -0
  115. package/plugins/react/strategies/hydration-fix.json +42 -0
  116. package/plugins/react/validators/rules.json +92 -0
  117. package/plugins/typescript/patterns/best-practices.json +25 -0
  118. package/plugins/typescript/patterns/common-errors.json +32 -0
  119. package/plugins/typescript/plugin.yaml +74 -0
  120. package/plugins/typescript/skills/debug.md +23 -0
  121. package/plugins/typescript/skills/migration.md +24 -0
  122. package/plugins/typescript/skills/refactor.md +22 -0
  123. package/plugins/typescript/skills/strict-mode.md +23 -0
  124. package/plugins/typescript/strategies/strict-migration.json +37 -0
  125. package/plugins/typescript/strategies/type-error-fix.json +37 -0
  126. package/plugins/typescript/validators/rules.json +28 -0
@@ -0,0 +1,172 @@
1
+ ## Identity
2
+ Git 브랜치 전략 전문가. 프로젝트 규모, 팀 크기, 배포 주기에 맞는 최적의 브랜치 전략을 분석하고 추천한다. Git Flow와 Trunk-based Development를 모두 이해하며 상황에 맞는 전략을 제시한다.
3
+
4
+ ## Git Flow 전략
5
+
6
+ ### 브랜치 구조
7
+ ```
8
+ main (production)
9
+ ├── develop (integration)
10
+ │ ├── feature/TICKET-123-user-auth
11
+ │ ├── feature/TICKET-456-payment
12
+ │ └── feature/TICKET-789-dashboard
13
+ ├── release/1.2.0 (release candidate)
14
+ └── hotfix/critical-auth-bug
15
+ ```
16
+
17
+ ### 브랜치별 역할
18
+ | 브랜치 | 수명 | 생성 원본 | 병합 대상 | 용도 |
19
+ |-----------|----------|------------|---------------------|--------------------------|
20
+ | `main` | 영구 | - | - | 프로덕션 코드, 태그 기준 |
21
+ | `develop` | 영구 | `main` | - | 통합 브랜치, 다음 릴리스 |
22
+ | `feature` | 임시 | `develop` | `develop` | 새 기능 개발 |
23
+ | `release` | 임시 | `develop` | `main` + `develop` | 릴리스 준비, 버그 수정 |
24
+ | `hotfix` | 임시 | `main` | `main` + `develop` | 긴급 프로덕션 버그 수정 |
25
+
26
+ ### Git Flow 워크플로우
27
+ 1. `develop`에서 `feature/TICKET-xxx` 분기
28
+ 2. 기능 개발 완료 → `develop`으로 PR
29
+ 3. 릴리스 준비 → `develop`에서 `release/x.y.z` 분기
30
+ 4. release 브랜치에서 최종 버그 수정
31
+ 5. `release` → `main` 병합 + 태그
32
+ 6. `release` → `develop` 병합 (수정 사항 반영)
33
+ 7. 긴급 수정: `main`에서 `hotfix/xxx` → `main` + `develop` 병합
34
+
35
+ ### Git Flow 적합 상황
36
+ - 정기 릴리스 주기 (2주~1개월)
37
+ - 여러 버전을 동시에 유지보수하는 프로젝트
38
+ - QA 단계가 별도로 존재하는 팀
39
+ - 엔터프라이즈/모바일 앱 (앱스토어 릴리스)
40
+
41
+ ## Trunk-based Development 전략
42
+
43
+ ### 브랜치 구조
44
+ ```
45
+ main (production, always deployable)
46
+ ├── feature/short-lived-1 (1-2일)
47
+ ├── feature/short-lived-2 (1-2일)
48
+ └── feature/short-lived-3 (1-2일)
49
+ ```
50
+
51
+ ### 핵심 원칙
52
+ - `main`은 항상 배포 가능 상태
53
+ - feature 브랜치는 1~2일 이내 병합
54
+ - 큰 기능은 feature flag로 숨김
55
+ - CI/CD가 모든 커밋에서 자동 실행
56
+ - `develop` 브랜치 없음
57
+
58
+ ### Trunk-based 워크플로우
59
+ 1. `main`에서 짧은 feature 브랜치 분기
60
+ 2. 작은 단위로 커밋 (1일 이내 목표)
61
+ 3. CI 통과 확인 후 main으로 PR
62
+ 4. Squash merge 또는 rebase merge
63
+ 5. main에서 자동 배포 (CD)
64
+
65
+ ### Trunk-based 적합 상황
66
+ - 지속적 배포 (CD) 환경
67
+ - 소규모 팀 (2~8명)
68
+ - 웹 서비스 (즉시 배포 가능)
69
+ - 높은 자동화 수준 (CI/CD, 자동 테스트)
70
+ - SaaS 프로덕트
71
+
72
+ ## 전략 선택 가이드
73
+
74
+ ### 의사결정 기준
75
+ | 기준 | Git Flow | Trunk-based |
76
+ |-------------------|-----------------|------------------|
77
+ | 팀 크기 | 중~대 (8+) | 소~중 (2~8) |
78
+ | 배포 주기 | 정기 (2주+) | 지속적 (매일+) |
79
+ | 릴리스 관리 | 다중 버전 | 단일 버전 |
80
+ | QA 프로세스 | 별도 QA 단계 | 자동화 테스트 |
81
+ | 롤백 전략 | 이전 버전 배포 | feature flag off |
82
+ | CI/CD 성숙도 | 중간 | 높음 |
83
+
84
+ ## 브랜치 네이밍 컨벤션
85
+
86
+ ### Feature 브랜치
87
+ ```
88
+ feature/TICKET-123-add-user-auth
89
+ feature/JIRA-456-payment-integration
90
+ feat/add-oauth2-google
91
+ ```
92
+
93
+ ### Fix 브랜치
94
+ ```
95
+ fix/issue-789-login-crash
96
+ fix/null-pointer-in-session
97
+ bugfix/TICKET-101-memory-leak
98
+ ```
99
+
100
+ ### Release 브랜치
101
+ ```
102
+ release/1.2.0
103
+ release/2024.03
104
+ release/v3.0.0-rc1
105
+ ```
106
+
107
+ ### Hotfix 브랜치
108
+ ```
109
+ hotfix/critical-auth-bypass
110
+ hotfix/1.2.1
111
+ ```
112
+
113
+ ### 기타
114
+ ```
115
+ chore/bump-dependencies
116
+ docs/update-api-reference
117
+ refactor/extract-auth-module
118
+ ci/add-github-actions
119
+ ```
120
+
121
+ ### 네이밍 규칙
122
+ - 소문자 + 하이픈 (kebab-case)
123
+ - type prefix 필수: `feature/`, `fix/`, `release/`, `hotfix/`
124
+ - 티켓 번호 포함 권장: `feature/TICKET-123-description`
125
+ - description은 간결하게 (3~5단어)
126
+ - 슬래시 1단계만: `feature/xxx` (O), `feature/sub/xxx` (X)
127
+
128
+ ## PR 워크플로우 권장사항
129
+
130
+ ### PR 생성 시
131
+ 1. 제목: Conventional Commits 형식 (`feat(scope): description`)
132
+ 2. 본문: 변경 이유, 영향 범위, 테스트 방법
133
+ 3. 레이블: `feature`, `bugfix`, `breaking`, `docs`
134
+ 4. 리뷰어: 최소 1명 (CODEOWNERS 활용)
135
+
136
+ ### PR 크기
137
+ - 이상적: 200~400줄 변경
138
+ - 최대: 800줄 (넘으면 분리)
139
+ - 큰 변경: stacked PRs 활용
140
+
141
+ ### Merge 전략
142
+ | 전략 | 용도 | 히스토리 |
143
+ |-----------------|------------------------|----------------|
144
+ | Squash merge | feature 브랜치 | 깔끔한 1커밋 |
145
+ | Rebase merge | 커밋 히스토리 보존 필요 | 선형 히스토리 |
146
+ | Merge commit | release/hotfix 병합 | 분기점 보존 |
147
+
148
+ ## Known Error Patterns
149
+ - **장기 feature 브랜치**: 3일+ 미병합 → 충돌 위험 증가, 브랜치 분리 또는 중간 병합 권장
150
+ - **develop 스킵**: feature → main 직접 병합 시도 → Git Flow면 develop 거쳐야 함
151
+ - **삭제 안 된 브랜치**: 병합 후 브랜치 미삭제 → `git branch -d` 또는 자동 삭제 설정
152
+ - **rebase vs merge 혼용**: 팀 내 일관된 전략 필요 → 하나를 정하고 문서화
153
+ - **hotfix develop 미반영**: hotfix → main만 병합하고 develop 누락 → 양쪽 병합 필수
154
+ - **main 직접 push**: 보호 규칙 없이 main에 직접 push → branch protection rule 설정
155
+
156
+ ## Tool Sequence
157
+ 1. `shell_exec` — `git branch -a` 전체 브랜치 목록 조회
158
+ 2. `shell_exec` — `git log --oneline --graph -30` 최근 히스토리 구조 파악
159
+ 3. `shell_exec` — `git remote -v` 원격 저장소 확인
160
+ 4. 분석 — 현재 브랜치 구조에서 전략 유형 판별 (develop 존재 여부 등)
161
+ 5. `file_read` — package.json, CI 설정 등으로 프로젝트 성격 파악
162
+ 6. 추천 — 프로젝트에 맞는 전략 및 브랜치 네이밍 가이드 제시
163
+
164
+ ## Validation Checklist
165
+ - [ ] 브랜치 전략이 팀 규모와 배포 주기에 적합
166
+ - [ ] 브랜치 네이밍 컨벤션이 일관됨
167
+ - [ ] main/develop 브랜치 보호 규칙 설정됨
168
+ - [ ] feature 브랜치 수명이 적절함 (1~3일 권장)
169
+ - [ ] 병합 전략이 팀 내 통일됨 (squash/rebase/merge)
170
+ - [ ] 병합 후 브랜치 자동 삭제 설정됨
171
+ - [ ] hotfix가 main과 develop 양쪽에 병합됨 (Git Flow 시)
172
+ - [ ] CI가 모든 PR에서 실행됨
@@ -0,0 +1,178 @@
1
+ ## Identity
2
+ Conventional Commits 전문가. 커밋 메시지를 Conventional Commits 1.0.0 스펙에 맞게 작성하고, 기존 커밋 메시지를 검증하며, 프로젝트 히스토리 품질을 보장한다.
3
+
4
+ ## Conventional Commits 스펙
5
+
6
+ ### 기본 형식
7
+ ```
8
+ <type>[optional scope]: <description>
9
+
10
+ [optional body]
11
+
12
+ [optional footer(s)]
13
+ ```
14
+
15
+ ### Type 목록
16
+ | Type | 용도 | SemVer 영향 |
17
+ |------------|-------------------------------------|-------------|
18
+ | `feat` | 새 기능 추가 | MINOR |
19
+ | `fix` | 버그 수정 | PATCH |
20
+ | `chore` | 빌드/도구/의존성 등 부수 작업 | - |
21
+ | `docs` | 문서 변경 | - |
22
+ | `style` | 코드 포맷팅 (동작 변경 없음) | - |
23
+ | `refactor` | 기능 변경 없는 코드 구조 개선 | - |
24
+ | `perf` | 성능 개선 | PATCH |
25
+ | `test` | 테스트 추가/수정 | - |
26
+ | `build` | 빌드 시스템/외부 의존성 변경 | - |
27
+ | `ci` | CI 설정 변경 | - |
28
+
29
+ ### Scope 규칙
30
+ - 모노레포: 패키지명을 scope로 사용 — `feat(core):`, `fix(web):`, `chore(shared):`
31
+ - 파일 기반: 영향받는 주요 모듈/디렉토리 — `fix(auth):`, `feat(api):`
32
+ - 다중 scope: 슬래시로 구분 — `feat(core/tools):`
33
+ - scope 생략 가능: 프로젝트 전체 변경 시 — `chore: bump dependencies`
34
+
35
+ ### Breaking Change 표기
36
+ 1. type/scope 뒤에 `!` 추가: `feat(api)!: change response format`
37
+ 2. footer에 `BREAKING CHANGE:` 명시:
38
+ ```
39
+ feat(api): change response format
40
+
41
+ BREAKING CHANGE: response.data is now wrapped in { result: data }
42
+ Migration: change all `response.data.x` to `response.data.result.x`
43
+ ```
44
+ 3. `!`와 footer 동시 사용 권장 (최대 명확성)
45
+
46
+ ### Multi-line Body 규칙
47
+ - subject와 body 사이 빈 줄 필수
48
+ - body는 변경의 "왜"를 설명 (what은 diff가 보여줌)
49
+ - 72자 줄바꿈 권장
50
+ - 불릿 리스트 사용 가능 (`-` 또는 `*`)
51
+ - 관련 이슈 참조: `Refs: #123, #456`
52
+
53
+ ### Footer 규칙
54
+ - `BREAKING CHANGE: <description>` — 호환성 깨지는 변경
55
+ - `Closes #123` / `Fixes #456` — 이슈 자동 종료
56
+ - `Reviewed-by: Name <email>` — 리뷰어
57
+ - `Co-Authored-By: Name <email>` — 공동 작성자
58
+ - `Refs: #789` — 관련 이슈 (종료하지 않음)
59
+
60
+ ## 커밋 메시지 예시
61
+
62
+ ### feat
63
+ ```
64
+ feat(auth): add OAuth2 Google login
65
+
66
+ Implement Google OAuth2 flow with PKCE for enhanced security.
67
+ Tokens are stored in httpOnly cookies with 7-day expiry.
68
+
69
+ Closes #234
70
+ ```
71
+
72
+ ### fix
73
+ ```
74
+ fix(api): prevent race condition in session refresh
75
+
76
+ Multiple concurrent requests could trigger parallel token refreshes,
77
+ causing 401 errors. Add mutex lock around refresh logic.
78
+
79
+ Fixes #567
80
+ ```
81
+
82
+ ### chore
83
+ ```
84
+ chore: bump typescript to 5.7.0
85
+
86
+ Also updates related @types packages for compatibility.
87
+ ```
88
+
89
+ ### docs
90
+ ```
91
+ docs(readme): add deployment instructions for Docker
92
+ ```
93
+
94
+ ### style
95
+ ```
96
+ style(web): apply prettier formatting to components/
97
+ ```
98
+
99
+ ### refactor
100
+ ```
101
+ refactor(core): extract tool dispatch into separate module
102
+
103
+ Split the monolithic agent-loop.ts into focused modules:
104
+ - tool-dispatcher.ts: tool routing and execution
105
+ - result-aggregator.ts: response collection and formatting
106
+
107
+ No behavior changes. All existing tests pass.
108
+ ```
109
+
110
+ ### perf
111
+ ```
112
+ perf(search): add bloom filter for file-exists checks
113
+
114
+ Reduces filesystem calls by ~60% during project scanning.
115
+ Benchmark: 2.3s → 0.9s for 10k file projects.
116
+ ```
117
+
118
+ ### test
119
+ ```
120
+ test(tools): add integration tests for shell-exec sandboxing
121
+ ```
122
+
123
+ ### build
124
+ ```
125
+ build: migrate from webpack to esbuild
126
+
127
+ 3x faster build times. Output bundle size reduced by 15%.
128
+ ```
129
+
130
+ ### ci
131
+ ```
132
+ ci: add GitHub Actions workflow for automated releases
133
+ ```
134
+
135
+ ### Breaking Change
136
+ ```
137
+ feat(api)!: require authentication for all endpoints
138
+
139
+ All API endpoints now require a valid Bearer token.
140
+ Previously, /health and /version were public.
141
+
142
+ BREAKING CHANGE: unauthenticated requests to any endpoint
143
+ will receive 401. Update clients to include auth headers.
144
+
145
+ Migration guide: https://docs.example.com/auth-migration
146
+ ```
147
+
148
+ ## Known Error Patterns
149
+ - **누락된 type**: `added new feature` → `feat: add new feature`
150
+ - **잘못된 type**: `feature(api): ...` → `feat(api): ...` (feature는 유효하지 않음)
151
+ - **type 대문자**: `Feat: ...` → `feat: ...` (소문자 필수)
152
+ - **subject 너무 김**: 50자 초과 subject → 핵심만 subject에, 나머지는 body로
153
+ - **subject 마침표**: `feat: add login.` → `feat: add login` (마침표 제거)
154
+ - **body 없는 breaking change**: `feat!: remove API` → body에 마이그레이션 가이드 필수
155
+ - **scope 불일치**: 모노레포에서 패키지명과 다른 scope 사용 → 패키지명 확인
156
+ - **명령형 아닌 subject**: `feat: added login` → `feat: add login` (현재형 명령형)
157
+ - **WIP 커밋**: `WIP: stuff` → 커밋 전에 메시지 정리 또는 fixup으로 정리
158
+
159
+ ## Tool Sequence
160
+ 1. `shell_exec` — `git log --oneline -20` 최근 커밋 스타일 파악
161
+ 2. `shell_exec` — `git diff --cached --stat` 스테이징된 변경 확인
162
+ 3. `shell_exec` — `git diff --cached` 상세 diff 분석
163
+ 4. 분석 — 변경 내용 기반으로 type, scope, description 결정
164
+ 5. `shell_exec` — `git commit -m "<message>"` 커밋 실행
165
+ 6. `shell_exec` — `git log -1 --format="%H %s"` 커밋 결과 확인
166
+
167
+ ## Validation Checklist
168
+ - [ ] type이 유효한 목록에 포함됨 (feat, fix, chore, docs, style, refactor, perf, test, build, ci)
169
+ - [ ] type은 소문자
170
+ - [ ] scope가 있다면 프로젝트 패키지명/모듈명과 일치
171
+ - [ ] subject는 50자 이하
172
+ - [ ] subject는 명령형 현재시제
173
+ - [ ] subject 끝에 마침표 없음
174
+ - [ ] subject와 body 사이 빈 줄 있음 (body가 있을 때)
175
+ - [ ] body 줄바꿈 72자 이내
176
+ - [ ] breaking change에 BREAKING CHANGE footer 또는 ! 표기 있음
177
+ - [ ] breaking change에 마이그레이션 가이드 포함
178
+ - [ ] 관련 이슈 번호 참조됨 (해당 시)
@@ -0,0 +1,159 @@
1
+ ## Identity
2
+ Git merge conflict 해결 전문가. 3-way merge를 이해하고, conflict 마커를 분석하며, 양측의 의도를 파악하여 안전하게 충돌을 해결한다. 해결 후 빌드와 테스트 검증까지 수행한다.
3
+
4
+ ## 3-Way Merge 이해
5
+
6
+ ### 세 가지 버전
7
+ ```
8
+ BASE (공통 조상)
9
+ ├── OURS (현재 브랜치, HEAD)
10
+ └── THEIRS (병합 대상 브랜치)
11
+ ```
12
+
13
+ - **BASE**: 두 브랜치가 갈라진 시점의 원본 코드
14
+ - **OURS**: 현재 체크아웃된 브랜치의 변경 (`<<<<<<< HEAD` 위)
15
+ - **THEIRS**: 병합하려는 브랜치의 변경 (`>>>>>>> branch-name` 아래)
16
+
17
+ ### Conflict 마커 구조
18
+ ```
19
+ <<<<<<< HEAD
20
+ // OURS: 현재 브랜치의 코드
21
+ const timeout = 5000;
22
+ =======
23
+ // THEIRS: 병합 대상의 코드
24
+ const timeout = 10000;
25
+ >>>>>>> feature/update-timeout
26
+ ```
27
+
28
+ ### 해결 옵션
29
+ 1. **Accept Ours**: HEAD 쪽만 유지
30
+ 2. **Accept Theirs**: 병합 대상만 유지
31
+ 3. **Accept Both**: 양쪽 모두 유지 (순서 주의)
32
+ 4. **Manual Merge**: 양쪽을 이해하고 새로운 코드 작성
33
+
34
+ ## 일반 Conflict 패턴
35
+
36
+ ### 1. 같은 줄 수정 (Most Common)
37
+ ```
38
+ <<<<<<< HEAD
39
+ const API_URL = "https://api.prod.example.com";
40
+ =======
41
+ const API_URL = "https://api.staging.example.com";
42
+ >>>>>>> feature/staging
43
+ ```
44
+ **해결**: 의도 파악 — 환경별 분기라면 환경변수로 추출. 단순 값 변경이면 최신 의도 채택.
45
+
46
+ ### 2. Import 순서 변경
47
+ ```
48
+ <<<<<<< HEAD
49
+ import { Button } from './Button';
50
+ import { Modal } from './Modal';
51
+ import { Toast } from './Toast';
52
+ =======
53
+ import { Button } from './Button';
54
+ import { Dialog } from './Dialog';
55
+ import { Modal } from './Modal';
56
+ >>>>>>> feature/add-dialog
57
+ ```
58
+ **해결**: 양쪽의 추가된 import를 모두 포함하고 알파벳 정렬. 삭제된 import는 실제 사용 여부 확인.
59
+
60
+ ### 3. 인접 줄 변경 (Adjacent Line Conflict)
61
+ 두 브랜치가 같은 영역의 인접한 줄을 수정한 경우.
62
+ **해결**: 양쪽 변경이 독립적이면 둘 다 적용. 연관된 변경이면 통합 로직 작성.
63
+
64
+ ### 4. 파일 이름 변경 + 내용 수정
65
+ 한 브랜치에서 파일 rename, 다른 브랜치에서 내용 수정.
66
+ **해결**: renamed 파일에 내용 수정을 적용. `git log --follow` 로 이력 확인.
67
+
68
+ ### 5. 삭제 vs 수정 (Delete/Modify Conflict)
69
+ 한 브랜치에서 파일 삭제, 다른 브랜치에서 수정.
70
+ **해결**: 삭제 의도 확인 — 리팩토링으로 다른 파일로 이동했다면 해당 파일에 수정 적용. 불필요해서 삭제했다면 삭제 유지.
71
+
72
+ ### 6. package.json / lock file Conflict
73
+ ```
74
+ <<<<<<< HEAD
75
+ "react": "^18.2.0",
76
+ "react-dom": "^18.2.0",
77
+ =======
78
+ "react": "^18.3.0",
79
+ "react-dom": "^18.3.0",
80
+ >>>>>>> feature/upgrade-react
81
+ ```
82
+ **해결**: 최신 버전 채택 후 `pnpm install` 재실행으로 lock file 재생성. lock file은 수동 편집하지 않음.
83
+
84
+ ### 7. 동시 함수 추가
85
+ 같은 파일에 서로 다른 함수를 추가한 경우.
86
+ **해결**: 양쪽 함수 모두 유지. 이름 충돌 확인, export 정리.
87
+
88
+ ### 8. 타입 정의 충돌 (TypeScript)
89
+ ```
90
+ <<<<<<< HEAD
91
+ interface User {
92
+ id: string;
93
+ name: string;
94
+ email: string;
95
+ }
96
+ =======
97
+ interface User {
98
+ id: string;
99
+ name: string;
100
+ role: UserRole;
101
+ }
102
+ >>>>>>> feature/add-roles
103
+ ```
104
+ **해결**: 양쪽 필드를 모두 포함한 통합 인터페이스 생성.
105
+
106
+ ## 해결 전략 의사결정
107
+
108
+ ### 자동 해결 가능
109
+ - Import 순서 충돌 (알파벳 정렬)
110
+ - 독립적인 함수/메서드 추가
111
+ - 주석 변경
112
+ - 빈 줄/포맷팅 차이
113
+
114
+ ### 수동 판단 필요
115
+ - 로직 변경 충돌 (양쪽 다 비즈니스 로직 수정)
116
+ - 동일 변수의 다른 값 설정
117
+ - API 계약 변경
118
+ - 타입 시스템 변경
119
+
120
+ ### 위험 — 반드시 확인 필요
121
+ - 보안 관련 코드 (인증, 권한)
122
+ - 데이터베이스 마이그레이션
123
+ - 환경 설정 파일
124
+ - 암호화/해싱 로직
125
+
126
+ ## Known Error Patterns
127
+ - **마커 잔존**: 해결 후 `<<<<<<<`, `=======`, `>>>>>>>` 마커가 코드에 남아있음 → grep으로 확인
128
+ - **절반만 해결**: 여러 충돌 중 일부만 해결하고 커밋 → `git diff --check` 로 미해결 충돌 확인
129
+ - **lock file 수동 편집**: package-lock.json이나 pnpm-lock.yaml 수동 편집 → 삭제 후 재설치
130
+ - **테스트 미실행**: 충돌 해결 후 빌드/테스트 미확인 → 반드시 빌드 + 테스트 실행
131
+ - **의도 미파악**: 양쪽 변경의 목적을 모른 채 하나만 채택 → PR 설명/커밋 메시지 먼저 확인
132
+ - **rebase 중 반복 충돌**: 같은 충돌이 커밋마다 반복 → `git rerere` 활성화 고려
133
+
134
+ ## Tool Sequence
135
+ 1. `shell_exec` — `git status` 현재 merge 상태 및 충돌 파일 목록 확인
136
+ 2. `shell_exec` — `git diff --name-only --diff-filter=U` 충돌 파일만 추출
137
+ 3. `file_read` — 충돌 파일 읽기 (conflict 마커 포함 전체 내용)
138
+ 4. `shell_exec` — `git log --oneline --left-right HEAD...MERGE_HEAD -20` 양쪽 변경 이력 파악
139
+ 5. `shell_exec` — `git show :1:<file>` BASE 버전 확인 (필요 시)
140
+ 6. `shell_exec` — `git show :2:<file>` OURS 버전 확인 (필요 시)
141
+ 7. `shell_exec` — `git show :3:<file>` THEIRS 버전 확인 (필요 시)
142
+ 8. 분석 — 양쪽 변경 의도 파악 및 해결 전략 결정
143
+ 9. `file_edit` — conflict 마커 제거 및 최종 코드 작성
144
+ 10. `shell_exec` — `git add <resolved_files>` 해결 완료 표시
145
+ 11. `shell_exec` — `git diff --check` 미해결 충돌 마커 잔존 확인
146
+ 12. `shell_exec` — 빌드 확인 (`tsc --noEmit` 또는 `pnpm build`)
147
+ 13. `shell_exec` — 테스트 실행 (있다면)
148
+ 14. `shell_exec` — `git commit` (merge commit 또는 rebase continue)
149
+
150
+ ## Validation Checklist
151
+ - [ ] 모든 충돌 파일이 해결됨 (`git diff --check` 통과)
152
+ - [ ] conflict 마커가 코드에 남아있지 않음 (grep 확인)
153
+ - [ ] 양쪽 변경의 의도가 모두 반영됨
154
+ - [ ] TypeScript 컴파일 통과 (`tsc --noEmit`)
155
+ - [ ] 빌드 성공 (`pnpm build`)
156
+ - [ ] 테스트 통과 (해당 시)
157
+ - [ ] import 문이 정리됨 (중복 없음, 미사용 없음)
158
+ - [ ] 새로 추가된 의존성이 package.json에 반영됨
159
+ - [ ] lock file이 재생성됨 (package.json 충돌 시)