jun-claude-code 0.0.17 → 0.1.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.
package/README.md CHANGED
@@ -2,66 +2,6 @@
2
2
 
3
3
  Claude Code 설정 템플릿 CLI. 미리 정의된 Agents, Skills, Hooks, Workflow를 프로젝트에 설치하여 Claude Code 환경을 빠르게 구축합니다.
4
4
 
5
- ## 포함 내용
6
-
7
- ### Agents (`templates/global/agents/`)
8
-
9
- 작업별 전문 Subagent 13종. Main Agent의 Context Window를 절약하면서 각 작업을 위임합니다.
10
-
11
- | Agent | 역할 |
12
- |-------|------|
13
- | `explore` | 코드베이스 탐색 |
14
- | `task-planner` | 작업 계획 수립 |
15
- | `code-writer` | 코드 작성 (Opus) |
16
- | `simple-code-writer` | 단순 수정 (Haiku) |
17
- | `code-reviewer` | 셀프 코드 리뷰 |
18
- | `git-manager` | Git 커밋/PR |
19
- | `impact-analyzer` | 사이드이펙트 분석 |
20
- | `qa-tester` | 테스트/빌드 검증 |
21
- | `architect` | 아키텍처 설계 |
22
- | `designer` | UI/UX 스타일링 |
23
- | `director` | 작업 총괄 디렉터 |
24
- | `context-collector` | 소스 코드 기반 Context 수집 |
25
- | `context-manager` | Context 문서 관리 |
26
-
27
- ### Skills (`templates/global/skills/`)
28
-
29
- | Skill | 설명 |
30
- |-------|------|
31
- | `Coding` | 공통 코딩 원칙 (SRP, 응집도, 가독성) |
32
- | `Git` | Git 커밋/PR 규칙, PR 리뷰, 피드백 적용 |
33
- | `Backend` | 백엔드 개발 원칙 (레이어, TypeORM) |
34
- | `React` | React 개발 (TanStack Router, React Hook Form, Tailwind) |
35
- | `Documentation` | .claude 문서 작성 가이드 |
36
- | `Director` | 디렉터 Agent 운영 스킬 |
37
-
38
- ### Hooks (`templates/global/hooks/`)
39
-
40
- | Hook | 설명 |
41
- |------|------|
42
- | `workflow-enforced.sh` | 워크플로우 순서 강제 프로토콜 |
43
- | `skill-forced.sh` | Skill/Agent 평가 프로토콜 |
44
-
45
- ### Project Agents (`templates/project/agents/`)
46
-
47
- 프로젝트 `.claude/`에 설치되는 프로젝트별 Agent.
48
-
49
- | Agent | 역할 |
50
- |-------|------|
51
- | `project-task-manager` | GitHub Project 태스크 관리 |
52
- | `context-generator` | Context 자동 생성 |
53
- | `project-context-collector` | .claude/context/ 문서 기반 프로젝트 배경 수집 |
54
-
55
- ### Project Skills (`templates/project/skills/`)
56
-
57
- | Skill | 설명 |
58
- |-------|------|
59
- | `ContextGeneration` | Context 자동 생성 스킬 |
60
-
61
- ### Workflow
62
-
63
- Planning -> Validation -> Implementation -> Review 순서의 작업 워크플로우와 Context 절약 원칙(Subagent 위임 규칙)을 정의합니다.
64
-
65
5
  ## 설치
66
6
 
67
7
  ```bash
@@ -79,6 +19,7 @@ npm install -g jun-claude-code
79
19
  | 명령어 | 설명 | 활성화되는 기능 |
80
20
  |--------|------|----------------|
81
21
  | `jun-claude-code` | 전역 설정 (`~/.claude/`) 설치 | Agents 13종, Skills 6종, Hooks 2종, Workflow |
22
+ | `jun-claude-code --project` | 프로젝트 설정 (`.claude/`) 설치 | 전역과 동일 (프로젝트별 오버라이드용) |
82
23
  | `jun-claude-code init-project` | GitHub Project 연동 | 세션 시작 시 태스크 자동 로드, 태스크 관리 Agent |
83
24
  | `jun-claude-code init-context` | Context 자동 생성 설정 | PR 기반 Context 자동 생성, Codebase/Business 문서화, 별도 브랜치 PR |
84
25
 
@@ -92,6 +33,7 @@ jun-claude-code
92
33
 
93
34
  | 옵션 | 설명 |
94
35
  |------|------|
36
+ | `--project`, `-p` | 전역(`~/.claude/`) 대신 프로젝트(`.claude/`)에 설치 |
95
37
  | `--dry-run`, `-d` | 실제 복사 없이 복사될 파일 목록만 확인 |
96
38
  | `--force`, `-f` | 확인 없이 모든 파일 덮어쓰기 |
97
39
 
@@ -176,6 +118,66 @@ jun-claude-code init-context
176
118
  2. **CLAUDE_CODE_OAUTH_TOKEN 추가**
177
119
  - Settings → Secrets and variables → Actions → New repository secret
178
120
 
121
+ ## 포함 내용
122
+
123
+ ### Agents (`templates/global/agents/`)
124
+
125
+ 작업별 전문 Subagent 13종. Main Agent의 Context Window를 절약하면서 각 작업을 위임합니다.
126
+
127
+ | Agent | 역할 |
128
+ |-------|------|
129
+ | `explore` | 코드베이스 탐색 |
130
+ | `task-planner` | 작업 계획 수립 |
131
+ | `code-writer` | 코드 작성 (Opus) |
132
+ | `simple-code-writer` | 단순 수정 (Haiku) |
133
+ | `code-reviewer` | 셀프 코드 리뷰 |
134
+ | `git-manager` | Git 커밋/PR |
135
+ | `impact-analyzer` | 사이드이펙트 분석 |
136
+ | `qa-tester` | 테스트/빌드 검증 |
137
+ | `architect` | 아키텍처 설계 |
138
+ | `designer` | UI/UX 스타일링 |
139
+ | `director` | 작업 총괄 디렉터 |
140
+ | `context-collector` | 소스 코드 기반 Context 수집 |
141
+ | `context-manager` | Context 문서 관리 |
142
+
143
+ ### Skills (`templates/global/skills/`)
144
+
145
+ | Skill | 설명 |
146
+ |-------|------|
147
+ | `Coding` | 공통 코딩 원칙 (SRP, 응집도, 가독성) |
148
+ | `Git` | Git 커밋/PR 규칙, PR 리뷰, 피드백 적용 |
149
+ | `Backend` | 백엔드 개발 원칙 (레이어, TypeORM) |
150
+ | `React` | React 개발 (TanStack Router, React Hook Form, Tailwind) |
151
+ | `Documentation` | .claude 문서 작성 가이드 |
152
+ | `Director` | 디렉터 Agent 운영 스킬 |
153
+
154
+ ### Hooks (`templates/global/hooks/`)
155
+
156
+ | Hook | 설명 |
157
+ |------|------|
158
+ | `workflow-enforced.sh` | 워크플로우 순서 강제 프로토콜 |
159
+ | `skill-forced.sh` | Skill/Agent 평가 프로토콜 |
160
+
161
+ ### Project Agents (`templates/project/agents/`)
162
+
163
+ 프로젝트 `.claude/`에 설치되는 프로젝트별 Agent.
164
+
165
+ | Agent | 역할 |
166
+ |-------|------|
167
+ | `project-task-manager` | GitHub Project 태스크 관리 |
168
+ | `context-generator` | Context 자동 생성 |
169
+ | `project-context-collector` | .claude/context/ 문서 기반 프로젝트 배경 수집 |
170
+
171
+ ### Project Skills (`templates/project/skills/`)
172
+
173
+ | Skill | 설명 |
174
+ |-------|------|
175
+ | `ContextGeneration` | Context 자동 생성 스킬 |
176
+
177
+ ### Workflow
178
+
179
+ Planning -> Validation -> Implementation -> Review 순서의 작업 워크플로우와 Context 절약 원칙(Subagent 위임 규칙)을 정의합니다.
180
+
179
181
  ## 프로젝트 구조
180
182
 
181
183
  ```
@@ -196,7 +198,7 @@ templates/
196
198
 
197
199
  ## 커스터마이징
198
200
 
199
- 설치 `~/.claude/`에서 필요에 맞게 수정할 수 있습니다. 프로젝트별로는 프로젝트 루트에 `.claude/`를 만들어 설정을 추가합니다.
201
+ `--project` 옵션을 사용하면 전역 템플릿을 프로젝트 `.claude/`에 바로 설치할 수 있습니다. 설치 필요에 맞게 수정하세요.
200
202
 
201
203
  ```
202
204
  your-project/
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,340 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ const vitest_1 = require("vitest");
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ const os = __importStar(require("os"));
40
+ const utils_1 = require("../utils");
41
+ const copy_1 = require("../copy");
42
+ const init_project_1 = require("../init-project");
43
+ function createTmpDir() {
44
+ return fs.mkdtempSync(path.join(os.tmpdir(), 'merge-settings-test-'));
45
+ }
46
+ function cleanupDir(dir) {
47
+ fs.rmSync(dir, { recursive: true, force: true });
48
+ }
49
+ function readJson(filePath) {
50
+ return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
51
+ }
52
+ function writeJson(filePath, data) {
53
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
54
+ fs.writeFileSync(filePath, JSON.stringify(data, null, 2) + '\n', 'utf-8');
55
+ }
56
+ // ─── getHookKey ───
57
+ (0, vitest_1.describe)('getHookKey', () => {
58
+ (0, vitest_1.it)('should generate key for flat hook entry', () => {
59
+ const entry = { type: 'command', command: 'echo hello' };
60
+ (0, vitest_1.expect)((0, utils_1.getHookKey)(entry)).toBe('command:echo hello');
61
+ });
62
+ (0, vitest_1.it)('should generate key for nested hooks entry without matcher', () => {
63
+ const entry = {
64
+ hooks: [
65
+ { type: 'command', command: 'cmd-a' },
66
+ { type: 'command', command: 'cmd-b' },
67
+ ],
68
+ };
69
+ const key = (0, utils_1.getHookKey)(entry);
70
+ (0, vitest_1.expect)(key).toBe('command:cmd-a\ncommand:cmd-b');
71
+ });
72
+ (0, vitest_1.it)('should sort nested hooks for consistent key', () => {
73
+ const entry1 = {
74
+ hooks: [
75
+ { type: 'command', command: 'cmd-b' },
76
+ { type: 'command', command: 'cmd-a' },
77
+ ],
78
+ };
79
+ const entry2 = {
80
+ hooks: [
81
+ { type: 'command', command: 'cmd-a' },
82
+ { type: 'command', command: 'cmd-b' },
83
+ ],
84
+ };
85
+ (0, vitest_1.expect)((0, utils_1.getHookKey)(entry1)).toBe((0, utils_1.getHookKey)(entry2));
86
+ });
87
+ (0, vitest_1.it)('should include matcher in key when present', () => {
88
+ const entry = {
89
+ matcher: 'Bash',
90
+ hooks: [{ type: 'command', command: 'blocker.sh' }],
91
+ };
92
+ (0, vitest_1.expect)((0, utils_1.getHookKey)(entry)).toBe('[Bash]command:blocker.sh');
93
+ });
94
+ (0, vitest_1.it)('should generate different keys for same hooks with different matchers', () => {
95
+ const entryBash = {
96
+ matcher: 'Bash',
97
+ hooks: [{ type: 'command', command: 'blocker.sh' }],
98
+ };
99
+ const entryWrite = {
100
+ matcher: 'Write',
101
+ hooks: [{ type: 'command', command: 'blocker.sh' }],
102
+ };
103
+ (0, vitest_1.expect)((0, utils_1.getHookKey)(entryBash)).not.toBe((0, utils_1.getHookKey)(entryWrite));
104
+ });
105
+ (0, vitest_1.it)('should generate different keys for same hooks with vs without matcher', () => {
106
+ const withMatcher = {
107
+ matcher: 'Bash',
108
+ hooks: [{ type: 'command', command: 'blocker.sh' }],
109
+ };
110
+ const withoutMatcher = {
111
+ hooks: [{ type: 'command', command: 'blocker.sh' }],
112
+ };
113
+ (0, vitest_1.expect)((0, utils_1.getHookKey)(withMatcher)).not.toBe((0, utils_1.getHookKey)(withoutMatcher));
114
+ });
115
+ (0, vitest_1.it)('should handle empty matcher as no matcher', () => {
116
+ const entry = {
117
+ matcher: '',
118
+ hooks: [{ type: 'command', command: 'test.sh' }],
119
+ };
120
+ const entryNoMatcher = {
121
+ hooks: [{ type: 'command', command: 'test.sh' }],
122
+ };
123
+ (0, vitest_1.expect)((0, utils_1.getHookKey)(entry)).toBe((0, utils_1.getHookKey)(entryNoMatcher));
124
+ });
125
+ });
126
+ // ─── copy.ts mergeSettingsJson (global) ───
127
+ (0, vitest_1.describe)('copy.ts mergeSettingsJson', () => {
128
+ let sourceDir;
129
+ let destDir;
130
+ (0, vitest_1.beforeEach)(() => {
131
+ sourceDir = createTmpDir();
132
+ destDir = createTmpDir();
133
+ });
134
+ (0, vitest_1.afterEach)(() => {
135
+ cleanupDir(sourceDir);
136
+ cleanupDir(destDir);
137
+ });
138
+ (0, vitest_1.it)('should create settings.json on fresh install', () => {
139
+ const sourceSettings = {
140
+ statusLine: { type: 'command', command: 'echo test' },
141
+ hooks: {
142
+ UserPromptSubmit: [
143
+ {
144
+ hooks: [{ type: 'command', command: 'skill-forced.sh' }],
145
+ },
146
+ ],
147
+ },
148
+ };
149
+ writeJson(path.join(sourceDir, 'settings.json'), sourceSettings);
150
+ (0, copy_1.mergeSettingsJson)(sourceDir, destDir);
151
+ const result = readJson(path.join(destDir, 'settings.json'));
152
+ (0, vitest_1.expect)(result.statusLine).toEqual(sourceSettings.statusLine);
153
+ (0, vitest_1.expect)(result.hooks.UserPromptSubmit).toHaveLength(1);
154
+ (0, vitest_1.expect)(result.hooks.UserPromptSubmit[0].hooks[0].command).toBe('skill-forced.sh');
155
+ });
156
+ (0, vitest_1.it)('should skip duplicate hooks on re-run', () => {
157
+ const sourceSettings = {
158
+ hooks: {
159
+ UserPromptSubmit: [
160
+ { hooks: [{ type: 'command', command: 'skill-forced.sh' }] },
161
+ ],
162
+ },
163
+ };
164
+ writeJson(path.join(sourceDir, 'settings.json'), sourceSettings);
165
+ // First run
166
+ (0, copy_1.mergeSettingsJson)(sourceDir, destDir);
167
+ // Second run (re-install)
168
+ (0, copy_1.mergeSettingsJson)(sourceDir, destDir);
169
+ const result = readJson(path.join(destDir, 'settings.json'));
170
+ (0, vitest_1.expect)(result.hooks.UserPromptSubmit).toHaveLength(1);
171
+ });
172
+ (0, vitest_1.it)('should distinguish entries with different matchers', () => {
173
+ const sourceSettings = {
174
+ hooks: {
175
+ PreToolUse: [
176
+ {
177
+ matcher: 'Bash',
178
+ hooks: [{ type: 'command', command: 'blocker.sh' }],
179
+ },
180
+ {
181
+ matcher: 'Write',
182
+ hooks: [{ type: 'command', command: 'blocker.sh' }],
183
+ },
184
+ ],
185
+ },
186
+ };
187
+ writeJson(path.join(sourceDir, 'settings.json'), sourceSettings);
188
+ (0, copy_1.mergeSettingsJson)(sourceDir, destDir);
189
+ const result = readJson(path.join(destDir, 'settings.json'));
190
+ (0, vitest_1.expect)(result.hooks.PreToolUse).toHaveLength(2);
191
+ (0, vitest_1.expect)(result.hooks.PreToolUse[0].matcher).toBe('Bash');
192
+ (0, vitest_1.expect)(result.hooks.PreToolUse[1].matcher).toBe('Write');
193
+ });
194
+ (0, vitest_1.it)('should not add duplicate when matcher-entry already exists in dest', () => {
195
+ const sourceSettings = {
196
+ hooks: {
197
+ PreToolUse: [
198
+ {
199
+ matcher: 'Bash',
200
+ hooks: [{ type: 'command', command: 'blocker.sh' }],
201
+ },
202
+ ],
203
+ },
204
+ };
205
+ writeJson(path.join(sourceDir, 'settings.json'), sourceSettings);
206
+ const destSettings = {
207
+ hooks: {
208
+ PreToolUse: [
209
+ {
210
+ matcher: 'Bash',
211
+ hooks: [{ type: 'command', command: 'blocker.sh' }],
212
+ },
213
+ ],
214
+ },
215
+ };
216
+ writeJson(path.join(destDir, 'settings.json'), destSettings);
217
+ (0, copy_1.mergeSettingsJson)(sourceDir, destDir);
218
+ const result = readJson(path.join(destDir, 'settings.json'));
219
+ (0, vitest_1.expect)(result.hooks.PreToolUse).toHaveLength(1);
220
+ });
221
+ (0, vitest_1.it)('should preserve existing hooks in dest that are not in source', () => {
222
+ const sourceSettings = {
223
+ hooks: {
224
+ UserPromptSubmit: [
225
+ { hooks: [{ type: 'command', command: 'new-hook.sh' }] },
226
+ ],
227
+ },
228
+ };
229
+ writeJson(path.join(sourceDir, 'settings.json'), sourceSettings);
230
+ const destSettings = {
231
+ hooks: {
232
+ StartSession: [
233
+ { hooks: [{ type: 'command', command: 'existing-hook.sh' }] },
234
+ ],
235
+ },
236
+ };
237
+ writeJson(path.join(destDir, 'settings.json'), destSettings);
238
+ (0, copy_1.mergeSettingsJson)(sourceDir, destDir);
239
+ const result = readJson(path.join(destDir, 'settings.json'));
240
+ // Source hook merged in
241
+ (0, vitest_1.expect)(result.hooks.UserPromptSubmit).toHaveLength(1);
242
+ // Existing hook preserved
243
+ (0, vitest_1.expect)(result.hooks.StartSession).toHaveLength(1);
244
+ (0, vitest_1.expect)(result.hooks.StartSession[0].hooks[0].command).toBe('existing-hook.sh');
245
+ });
246
+ (0, vitest_1.it)('should preserve existing top-level keys in dest', () => {
247
+ const sourceSettings = {
248
+ statusLine: { type: 'command', command: 'source-status' },
249
+ hooks: {},
250
+ };
251
+ writeJson(path.join(sourceDir, 'settings.json'), sourceSettings);
252
+ const destSettings = {
253
+ statusLine: { type: 'command', command: 'dest-status' },
254
+ customKey: 'preserved',
255
+ };
256
+ writeJson(path.join(destDir, 'settings.json'), destSettings);
257
+ (0, copy_1.mergeSettingsJson)(sourceDir, destDir);
258
+ const result = readJson(path.join(destDir, 'settings.json'));
259
+ // Dest's existing key is preserved (not overwritten)
260
+ (0, vitest_1.expect)(result.statusLine.command).toBe('dest-status');
261
+ (0, vitest_1.expect)(result.customKey).toBe('preserved');
262
+ });
263
+ (0, vitest_1.it)('should skip merge when source settings.json does not exist', () => {
264
+ // No settings.json in sourceDir
265
+ const destSettings = { hooks: { StartSession: [] } };
266
+ writeJson(path.join(destDir, 'settings.json'), destSettings);
267
+ (0, copy_1.mergeSettingsJson)(sourceDir, destDir);
268
+ const result = readJson(path.join(destDir, 'settings.json'));
269
+ (0, vitest_1.expect)(result).toEqual(destSettings);
270
+ });
271
+ });
272
+ // ─── init-project.ts mergeSettingsJson (project) ───
273
+ (0, vitest_1.describe)('init-project.ts mergeSettingsJson', () => {
274
+ let tmpDir;
275
+ (0, vitest_1.beforeEach)(() => {
276
+ tmpDir = createTmpDir();
277
+ });
278
+ (0, vitest_1.afterEach)(() => {
279
+ cleanupDir(tmpDir);
280
+ });
281
+ (0, vitest_1.it)('should create settings.json with StartSession hook on fresh init', () => {
282
+ (0, init_project_1.mergeProjectSettingsJson)(tmpDir);
283
+ const result = readJson(path.join(tmpDir, 'settings.json'));
284
+ (0, vitest_1.expect)(result.hooks.StartSession).toHaveLength(1);
285
+ (0, vitest_1.expect)(result.hooks.StartSession[0].hooks[0].command).toBe('bash .claude/hooks/task-loader.sh');
286
+ });
287
+ (0, vitest_1.it)('should skip duplicate StartSession hook on re-run', () => {
288
+ // First run
289
+ (0, init_project_1.mergeProjectSettingsJson)(tmpDir);
290
+ // Second run
291
+ (0, init_project_1.mergeProjectSettingsJson)(tmpDir);
292
+ const result = readJson(path.join(tmpDir, 'settings.json'));
293
+ (0, vitest_1.expect)(result.hooks.StartSession).toHaveLength(1);
294
+ });
295
+ (0, vitest_1.it)('should preserve existing StartSession hooks while adding new one', () => {
296
+ const existingSettings = {
297
+ hooks: {
298
+ StartSession: [
299
+ {
300
+ hooks: [{ type: 'command', command: 'existing-session-hook.sh' }],
301
+ },
302
+ ],
303
+ },
304
+ };
305
+ writeJson(path.join(tmpDir, 'settings.json'), existingSettings);
306
+ (0, init_project_1.mergeProjectSettingsJson)(tmpDir);
307
+ const result = readJson(path.join(tmpDir, 'settings.json'));
308
+ (0, vitest_1.expect)(result.hooks.StartSession).toHaveLength(2);
309
+ (0, vitest_1.expect)(result.hooks.StartSession[0].hooks[0].command).toBe('existing-session-hook.sh');
310
+ (0, vitest_1.expect)(result.hooks.StartSession[1].hooks[0].command).toBe('bash .claude/hooks/task-loader.sh');
311
+ });
312
+ (0, vitest_1.it)('should preserve other hook events', () => {
313
+ const existingSettings = {
314
+ hooks: {
315
+ UserPromptSubmit: [
316
+ { hooks: [{ type: 'command', command: 'prompt-hook.sh' }] },
317
+ ],
318
+ },
319
+ };
320
+ writeJson(path.join(tmpDir, 'settings.json'), existingSettings);
321
+ (0, init_project_1.mergeProjectSettingsJson)(tmpDir);
322
+ const result = readJson(path.join(tmpDir, 'settings.json'));
323
+ // Existing event preserved
324
+ (0, vitest_1.expect)(result.hooks.UserPromptSubmit).toHaveLength(1);
325
+ (0, vitest_1.expect)(result.hooks.UserPromptSubmit[0].hooks[0].command).toBe('prompt-hook.sh');
326
+ // New hook added
327
+ (0, vitest_1.expect)(result.hooks.StartSession).toHaveLength(1);
328
+ });
329
+ (0, vitest_1.it)('should preserve non-hook settings', () => {
330
+ const existingSettings = {
331
+ statusLine: { type: 'command', command: 'echo status' },
332
+ hooks: {},
333
+ };
334
+ writeJson(path.join(tmpDir, 'settings.json'), existingSettings);
335
+ (0, init_project_1.mergeProjectSettingsJson)(tmpDir);
336
+ const result = readJson(path.join(tmpDir, 'settings.json'));
337
+ (0, vitest_1.expect)(result.statusLine.command).toBe('echo status');
338
+ (0, vitest_1.expect)(result.hooks.StartSession).toHaveLength(1);
339
+ });
340
+ });
package/dist/cli.js CHANGED
@@ -45,15 +45,17 @@ const validate_1 = require("./validate");
45
45
  const program = new commander_1.Command();
46
46
  program
47
47
  .name('jun-claude-code')
48
- .description('Copy .claude configuration files to your home directory (~/.claude)')
48
+ .description('Copy .claude configuration files to ~/.claude (global) or .claude/ (project)')
49
49
  .version('1.0.0')
50
50
  .option('-d, --dry-run', 'Preview files to be copied without actually copying')
51
51
  .option('-f, --force', 'Overwrite existing files without confirmation')
52
+ .option('-p, --project', 'Install to project .claude/ instead of global ~/.claude/')
52
53
  .action(async (options) => {
53
54
  try {
54
55
  await (0, copy_1.copyClaudeFiles)({
55
56
  dryRun: options.dryRun,
56
57
  force: options.force,
58
+ project: options.project,
57
59
  });
58
60
  }
59
61
  catch (error) {
package/dist/copy.d.ts CHANGED
@@ -1,7 +1,14 @@
1
1
  export interface CopyOptions {
2
2
  dryRun?: boolean;
3
3
  force?: boolean;
4
+ project?: boolean;
4
5
  }
6
+ /**
7
+ * Merge settings.json from source into destination.
8
+ * Hooks are merged per event key; duplicate hook entries (by deep equality) are skipped.
9
+ * Non-hook keys are shallow-merged (source wins for new keys, dest preserved for existing).
10
+ */
11
+ export declare function mergeSettingsJson(sourceDir: string, destDir: string): void;
5
12
  /**
6
13
  * Copy .claude files to user's home directory
7
14
  */
package/dist/copy.js CHANGED
@@ -36,12 +36,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.mergeSettingsJson = mergeSettingsJson;
39
40
  exports.copyClaudeFiles = copyClaudeFiles;
40
41
  const fs = __importStar(require("fs"));
41
42
  const path = __importStar(require("path"));
42
43
  const readline = __importStar(require("readline"));
43
44
  const crypto = __importStar(require("crypto"));
44
45
  const chalk_1 = __importDefault(require("chalk"));
46
+ const utils_1 = require("./utils");
45
47
  /**
46
48
  * Prompt user for confirmation using readline
47
49
  */
@@ -168,22 +170,10 @@ function mergeSettingsJson(sourceDir, destDir) {
168
170
  destHooks[event] = [];
169
171
  }
170
172
  const destEntries = destHooks[event];
171
- // Extract a command-based key from a hook entry for duplicate detection.
172
- // Type 1: { type: "command", command: "..." } → returns "type:command"
173
- // Type 2: { hooks: [{ type: "command", command: "..." }, ...] } → returns sorted "type:command" joined
174
- const getHookKey = (entry) => {
175
- if (entry.hooks && Array.isArray(entry.hooks)) {
176
- return entry.hooks
177
- .map((h) => `${h.type || ''}:${h.command || ''}`)
178
- .sort()
179
- .join('\n');
180
- }
181
- return `${entry.type || ''}:${entry.command || ''}`;
182
- };
183
173
  // Build a Set of command keys from existing entries for fast duplicate detection
184
- const existingKeys = new Set(destEntries.map((entry) => getHookKey(entry)));
174
+ const existingKeys = new Set(destEntries.map((entry) => (0, utils_1.getHookKey)(entry)));
185
175
  for (const entry of sourceEntries) {
186
- const key = getHookKey(entry);
176
+ const key = (0, utils_1.getHookKey)(entry);
187
177
  if (!existingKeys.has(key)) {
188
178
  destEntries.push(entry);
189
179
  existingKeys.add(key);
@@ -198,11 +188,12 @@ function mergeSettingsJson(sourceDir, destDir) {
198
188
  * Copy .claude files to user's home directory
199
189
  */
200
190
  async function copyClaudeFiles(options = {}) {
201
- const { dryRun = false, force = false } = options;
191
+ const { dryRun = false, force = false, project = false } = options;
202
192
  const sourceDir = getSourceGlobalDir();
203
- const destDir = getDestClaudeDir();
193
+ const destDir = project ? path.join(process.cwd(), '.claude') : getDestClaudeDir();
194
+ const targetLabel = project ? 'project' : 'global';
204
195
  console.log(chalk_1.default.blue('Source:'), sourceDir);
205
- console.log(chalk_1.default.blue('Destination:'), destDir);
196
+ console.log(chalk_1.default.blue('Destination:'), `${destDir} ${chalk_1.default.gray(`(${targetLabel})`)}`);
206
197
  console.log();
207
198
  // Check if source exists
208
199
  if (!fs.existsSync(sourceDir)) {
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Merge StartSession hook into settings.json.
3
+ * Appends the task-loader hook if not already present (duplicate detection via getHookKey).
4
+ */
5
+ export declare function mergeProjectSettingsJson(destDir: string): void;
1
6
  /**
2
7
  * Initialize GitHub Project integration in current directory
3
8
  */
@@ -36,11 +36,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.mergeProjectSettingsJson = mergeProjectSettingsJson;
39
40
  exports.initProject = initProject;
40
41
  const fs = __importStar(require("fs"));
41
42
  const path = __importStar(require("path"));
42
43
  const readline = __importStar(require("readline"));
43
44
  const chalk_1 = __importDefault(require("chalk"));
45
+ const utils_1 = require("./utils");
44
46
  /**
45
47
  * Prompt user for input using readline
46
48
  */
@@ -112,9 +114,10 @@ function copyProjectFile(srcRelative, destDir) {
112
114
  console.log(chalk_1.default.green(` ✓ ${path.relative(process.cwd(), destPath)}`));
113
115
  }
114
116
  /**
115
- * Merge StartSession hook into settings.json
117
+ * Merge StartSession hook into settings.json.
118
+ * Appends the task-loader hook if not already present (duplicate detection via getHookKey).
116
119
  */
117
- function mergeSettingsJson(destDir) {
120
+ function mergeProjectSettingsJson(destDir) {
118
121
  const settingsPath = path.join(destDir, 'settings.json');
119
122
  let settings = {};
120
123
  if (fs.existsSync(settingsPath)) {
@@ -129,12 +132,21 @@ function mergeSettingsJson(destDir) {
129
132
  if (!settings.hooks) {
130
133
  settings.hooks = {};
131
134
  }
132
- settings.hooks.StartSession = [
133
- {
134
- type: 'command',
135
- command: 'bash .claude/hooks/task-loader.sh',
136
- },
137
- ];
135
+ if (!settings.hooks.StartSession) {
136
+ settings.hooks.StartSession = [];
137
+ }
138
+ const newEntry = {
139
+ hooks: [
140
+ {
141
+ type: 'command',
142
+ command: 'bash .claude/hooks/task-loader.sh',
143
+ },
144
+ ],
145
+ };
146
+ const existingKeys = new Set(settings.hooks.StartSession.map((e) => (0, utils_1.getHookKey)(e)));
147
+ if (!existingKeys.has((0, utils_1.getHookKey)(newEntry))) {
148
+ settings.hooks.StartSession.push(newEntry);
149
+ }
138
150
  fs.mkdirSync(destDir, { recursive: true });
139
151
  fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n', 'utf-8');
140
152
  console.log(chalk_1.default.green(` ✓ ${path.relative(process.cwd(), settingsPath)} (StartSession hook 추가)`));
@@ -152,7 +164,7 @@ async function initProject() {
152
164
  copyProjectFile('hooks/task-loader.sh', destDir);
153
165
  copyProjectFile('agents/project-task-manager.md', destDir);
154
166
  // 3. settings.json merge
155
- mergeSettingsJson(destDir);
167
+ mergeProjectSettingsJson(destDir);
156
168
  console.log(chalk_1.default.cyan('\n✅ GitHub Project 설정 완료!'));
157
169
  console.log(chalk_1.default.gray(` Owner: ${config.owner}`));
158
170
  console.log(chalk_1.default.gray(` Project: #${config.projectNumber}`));
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Extract a command-based key from a hook entry for duplicate detection.
3
+ * Includes the matcher field so that entries with the same command but different matchers
4
+ * are treated as distinct items.
5
+ *
6
+ * Type 1 (nested): { matcher?: "...", hooks: [{ type: "command", command: "..." }, ...] }
7
+ * -> returns "[matcher]type:command\ntype:command" (sorted) or "type:command\ntype:command" if no matcher
8
+ *
9
+ * Type 2 (flat): { type: "command", command: "..." }
10
+ * -> returns "type:command"
11
+ */
12
+ export declare const getHookKey: (entry: any) => string;
package/dist/utils.js ADDED
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getHookKey = void 0;
4
+ /**
5
+ * Extract a command-based key from a hook entry for duplicate detection.
6
+ * Includes the matcher field so that entries with the same command but different matchers
7
+ * are treated as distinct items.
8
+ *
9
+ * Type 1 (nested): { matcher?: "...", hooks: [{ type: "command", command: "..." }, ...] }
10
+ * -> returns "[matcher]type:command\ntype:command" (sorted) or "type:command\ntype:command" if no matcher
11
+ *
12
+ * Type 2 (flat): { type: "command", command: "..." }
13
+ * -> returns "type:command"
14
+ */
15
+ const getHookKey = (entry) => {
16
+ const matcher = entry.matcher || '';
17
+ if (entry.hooks && Array.isArray(entry.hooks)) {
18
+ const hooksKey = entry.hooks
19
+ .map((h) => `${h.type || ''}:${h.command || ''}`)
20
+ .sort()
21
+ .join('\n');
22
+ return matcher ? `[${matcher}]${hooksKey}` : hooksKey;
23
+ }
24
+ return `${entry.type || ''}:${entry.command || ''}`;
25
+ };
26
+ exports.getHookKey = getHookKey;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jun-claude-code",
3
- "version": "0.0.17",
3
+ "version": "0.1.0",
4
4
  "description": "Claude Code configuration template - copy .claude settings to your project",
5
5
  "main": "dist/index.js",
6
6
  "bin": "dist/cli.js",
@@ -10,6 +10,7 @@
10
10
  ],
11
11
  "scripts": {
12
12
  "build": "tsc",
13
+ "test": "vitest run",
13
14
  "prepublishOnly": "yarn build"
14
15
  },
15
16
  "packageManager": "yarn@3.8.7",
@@ -19,7 +20,8 @@
19
20
  },
20
21
  "devDependencies": {
21
22
  "@types/node": "^20.10.0",
22
- "typescript": "^5.5.3"
23
+ "typescript": "^5.5.3",
24
+ "vitest": "^4.0.18"
23
25
  },
24
26
  "keywords": [
25
27
  "claude",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "statusLine": {
3
- "format": "{{dir}} {{git}} | {{tokens}} | {{model}}",
4
- "updateInterval": 1000
3
+ "type": "command",
4
+ "command": "~/.claude/statusline-command.sh"
5
5
  },
6
6
  "hooks": {
7
7
  "UserPromptSubmit": [
@@ -0,0 +1,84 @@
1
+ #!/bin/bash
2
+
3
+ # Read JSON input from stdin
4
+ input=$(cat)
5
+
6
+ # Extract data from JSON
7
+ cwd=$(echo "$input" | jq -r '.workspace.current_dir')
8
+ model=$(echo "$input" | jq -r '.model.display_name')
9
+ session_name=$(echo "$input" | jq -r '.session_name // empty')
10
+ remaining=$(echo "$input" | jq -r '.context_window.remaining_percentage // empty')
11
+ used_tokens=$(echo "$input" | jq -r '.context_window.total_input_tokens // empty')
12
+ total_tokens=$(echo "$input" | jq -r '.context_window.context_window_size // empty')
13
+
14
+ # Get short directory name (basename)
15
+ dir_name=$(basename "$cwd")
16
+
17
+ # Git information
18
+ git_info=""
19
+ if git -C "$cwd" rev-parse --git-dir > /dev/null 2>&1; then
20
+ branch=$(git -C "$cwd" -c core.useBuiltinFSMonitor=false -c core.fsmonitor=false symbolic-ref --short HEAD 2>/dev/null || echo "detached")
21
+
22
+ # Check for uncommitted changes
23
+ if ! git -C "$cwd" -c core.useBuiltinFSMonitor=false -c core.fsmonitor=false diff --quiet 2>/dev/null || \
24
+ ! git -C "$cwd" -c core.useBuiltinFSMonitor=false -c core.fsmonitor=false diff --cached --quiet 2>/dev/null; then
25
+ status="✗"
26
+ else
27
+ status=""
28
+ fi
29
+
30
+ git_info=" git:($(printf '\033[31m')${branch}$(printf '\033[0m'))${status}"
31
+ fi
32
+
33
+ # Format token information
34
+ format_token_count() {
35
+ local value=$1
36
+ if (( value >= 1000 )); then
37
+ printf "%.1fk" "$(bc <<< "scale=1; $value / 1000")"
38
+ else
39
+ echo "$value"
40
+ fi
41
+ }
42
+
43
+ # Get color based on usage percentage
44
+ get_color_for_percentage() {
45
+ local percentage=$1
46
+ if (( percentage >= 90 )); then
47
+ printf '\033[31m' # red
48
+ elif (( percentage >= 70 )); then
49
+ printf '\033[33m' # yellow
50
+ else
51
+ printf '\033[0m' # reset (no color)
52
+ fi
53
+ }
54
+
55
+ # Build status line in robbyrussell style
56
+ status_line="$(printf '\033[36m')${dir_name}$(printf '\033[0m')${git_info}"
57
+
58
+ # Add context percentage if available
59
+ if [ -n "$remaining" ]; then
60
+ # Calculate usage percentage (100 - remaining)
61
+ usage=$((100 - remaining))
62
+ color=$(get_color_for_percentage "$usage")
63
+ status_line="${status_line} | ctx:${color}${usage}%$(printf '\033[0m')"
64
+ fi
65
+
66
+ # Add token information if available
67
+ if [ -n "$used_tokens" ] && [ -n "$total_tokens" ]; then
68
+ used_formatted=$(format_token_count "$used_tokens")
69
+ total_formatted=$(format_token_count "$total_tokens")
70
+ # Calculate token usage percentage
71
+ token_usage=$(echo "scale=0; $used_tokens * 100 / $total_tokens" | bc)
72
+ color=$(get_color_for_percentage "$token_usage")
73
+ status_line="${status_line} | token:${color}${used_formatted}/${total_formatted}$(printf '\033[0m')"
74
+ fi
75
+
76
+ # Add model info
77
+ status_line="${status_line} | ${model}"
78
+
79
+ # Add session name if set
80
+ if [ -n "$session_name" ]; then
81
+ status_line="${status_line} [${session_name}]"
82
+ fi
83
+
84
+ printf "%s" "$status_line"