@kood/claude-code 0.1.9 → 0.1.11
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/dist/index.js +54 -35
- package/package.json +1 -1
- package/templates/hono/docs/commands/docs-creator.md +239 -0
- package/templates/hono/docs/commands/docs-refactor.md +168 -0
- package/templates/hono/docs/commands/git-all.md +83 -0
- package/templates/hono/docs/commands/git-session.md +91 -0
- package/templates/hono/docs/commands/git.md +86 -0
- package/templates/hono/docs/commands/lint-fix.md +170 -0
- package/templates/hono/docs/commands/lint-init.md +300 -0
- package/templates/hono/docs/commands/ts-fix.md +176 -0
- package/templates/hono/docs/skills/command-creator/LICENSE.txt +202 -0
- package/templates/hono/docs/skills/command-creator/SKILL.md +245 -0
- package/templates/hono/docs/skills/command-creator/scripts/init_command.py +244 -0
- package/templates/hono/docs/skills/command-creator/scripts/package_command.py +125 -0
- package/templates/hono/docs/skills/command-creator/scripts/quick_validate.py +143 -0
- package/templates/hono/docs/skills/skill-creator/LICENSE.txt +202 -0
- package/templates/hono/docs/skills/skill-creator/SKILL.md +184 -0
- package/templates/hono/docs/skills/skill-creator/scripts/init_skill.py +303 -0
- package/templates/hono/docs/skills/skill-creator/scripts/package_skill.py +110 -0
- package/templates/hono/docs/skills/skill-creator/scripts/quick_validate.py +65 -0
- package/templates/npx/docs/commands/docs-creator.md +239 -0
- package/templates/npx/docs/commands/docs-refactor.md +168 -0
- package/templates/npx/docs/commands/git-all.md +83 -0
- package/templates/npx/docs/commands/git-session.md +91 -0
- package/templates/npx/docs/commands/git.md +86 -0
- package/templates/npx/docs/commands/lint-fix.md +170 -0
- package/templates/npx/docs/commands/lint-init.md +300 -0
- package/templates/npx/docs/commands/ts-fix.md +176 -0
- package/templates/npx/docs/skills/command-creator/LICENSE.txt +202 -0
- package/templates/npx/docs/skills/command-creator/SKILL.md +245 -0
- package/templates/npx/docs/skills/command-creator/scripts/init_command.py +244 -0
- package/templates/npx/docs/skills/command-creator/scripts/package_command.py +125 -0
- package/templates/npx/docs/skills/command-creator/scripts/quick_validate.py +143 -0
- package/templates/npx/docs/skills/skill-creator/LICENSE.txt +202 -0
- package/templates/npx/docs/skills/skill-creator/SKILL.md +184 -0
- package/templates/npx/docs/skills/skill-creator/scripts/init_skill.py +303 -0
- package/templates/npx/docs/skills/skill-creator/scripts/package_skill.py +110 -0
- package/templates/npx/docs/skills/skill-creator/scripts/quick_validate.py +65 -0
- package/templates/tanstack-start/docs/commands/docs-creator.md +239 -0
- package/templates/tanstack-start/docs/commands/docs-refactor.md +168 -0
- package/templates/tanstack-start/docs/commands/git-all.md +83 -0
- package/templates/tanstack-start/docs/commands/git-session.md +91 -0
- package/templates/tanstack-start/docs/commands/git.md +86 -0
- package/templates/tanstack-start/docs/commands/lint-fix.md +170 -0
- package/templates/tanstack-start/docs/commands/lint-init.md +300 -0
- package/templates/tanstack-start/docs/commands/ts-fix.md +176 -0
- package/templates/tanstack-start/docs/skills/command-creator/LICENSE.txt +202 -0
- package/templates/tanstack-start/docs/skills/command-creator/SKILL.md +245 -0
- package/templates/tanstack-start/docs/skills/command-creator/scripts/init_command.py +244 -0
- package/templates/tanstack-start/docs/skills/command-creator/scripts/package_command.py +125 -0
- package/templates/tanstack-start/docs/skills/command-creator/scripts/quick_validate.py +143 -0
- package/templates/tanstack-start/docs/skills/skill-creator/LICENSE.txt +202 -0
- package/templates/tanstack-start/docs/skills/skill-creator/SKILL.md +184 -0
- package/templates/tanstack-start/docs/skills/skill-creator/scripts/init_skill.py +303 -0
- package/templates/tanstack-start/docs/skills/skill-creator/scripts/package_skill.py +110 -0
- package/templates/tanstack-start/docs/skills/skill-creator/scripts/quick_validate.py +65 -0
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
커맨드 초기화 스크립트 - 템플릿에서 새 슬래시 커맨드 생성
|
|
4
|
+
|
|
5
|
+
사용법:
|
|
6
|
+
init_command.py <커맨드명> --path <경로>
|
|
7
|
+
init_command.py <커맨드명> --project
|
|
8
|
+
init_command.py <커맨드명> --personal
|
|
9
|
+
|
|
10
|
+
예시:
|
|
11
|
+
init_command.py review-security --path .claude/commands
|
|
12
|
+
init_command.py commit-fix --project
|
|
13
|
+
init_command.py my-helper --personal
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
import sys
|
|
17
|
+
import os
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
COMMAND_TEMPLATE = """---
|
|
22
|
+
description: [TODO: 커맨드가 하는 일에 대한 간단한 설명]
|
|
23
|
+
allowed-tools: [TODO: 필요한 도구 목록, 예: Bash(git:*), Read, Write]
|
|
24
|
+
argument-hint: [TODO: 예상 인자, 예: <file> <type>]
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
# {command_title}
|
|
28
|
+
|
|
29
|
+
[TODO: 여기에 커맨드 지시사항 작성]
|
|
30
|
+
|
|
31
|
+
## 예시 패턴
|
|
32
|
+
|
|
33
|
+
### 인자 사용하기
|
|
34
|
+
|
|
35
|
+
모든 인자를 단일 문자열로:
|
|
36
|
+
```
|
|
37
|
+
다음을 처리하세요: $ARGUMENTS
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
위치 인자:
|
|
41
|
+
```
|
|
42
|
+
$1 파일을 $2 우선순위로 검토하세요
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 컨텍스트 포함하기
|
|
46
|
+
|
|
47
|
+
파일 내용:
|
|
48
|
+
```
|
|
49
|
+
@$1 의 코드를 검토하세요
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
셸 출력:
|
|
53
|
+
```
|
|
54
|
+
현재 상태: !`git status`
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### 일반적인 지시사항
|
|
58
|
+
|
|
59
|
+
[TODO: 실제 커맨드 지시사항으로 대체. 예시:]
|
|
60
|
+
|
|
61
|
+
**코드 리뷰용:**
|
|
62
|
+
```
|
|
63
|
+
다음 코드를 검토하세요:
|
|
64
|
+
- 보안 취약점
|
|
65
|
+
- 성능 이슈
|
|
66
|
+
- 코드 스타일 위반
|
|
67
|
+
|
|
68
|
+
@$ARGUMENTS
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**커밋 생성용:**
|
|
72
|
+
```
|
|
73
|
+
다음 형식으로 git 커밋 생성:
|
|
74
|
+
- 타입: $1
|
|
75
|
+
- 메시지: $2
|
|
76
|
+
|
|
77
|
+
컨벤셔널 커밋 형식을 따르세요.
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**테스트 생성용:**
|
|
81
|
+
```
|
|
82
|
+
@$1 의 코드에 대한 유닛 테스트 생성
|
|
83
|
+
|
|
84
|
+
포함할 것:
|
|
85
|
+
- 엣지 케이스
|
|
86
|
+
- 에러 처리
|
|
87
|
+
- 해피 패스 시나리오
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
이 템플릿 내용을 삭제하고 위에 실제 커맨드 지시사항을 작성하세요.
|
|
93
|
+
"""
|
|
94
|
+
|
|
95
|
+
SIMPLE_TEMPLATE = """---
|
|
96
|
+
description: {description}
|
|
97
|
+
allowed-tools: {tools}
|
|
98
|
+
argument-hint: {hint}
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
{instructions}
|
|
102
|
+
"""
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def title_case_command_name(command_name):
|
|
106
|
+
"""하이픈으로 구분된 커맨드명을 Title Case로 변환."""
|
|
107
|
+
return ' '.join(word.capitalize() for word in command_name.split('-'))
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def get_project_commands_path():
|
|
111
|
+
"""프로젝트 커맨드 디렉토리 경로 반환."""
|
|
112
|
+
return Path.cwd() / '.claude' / 'commands'
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def get_personal_commands_path():
|
|
116
|
+
"""개인 커맨드 디렉토리 경로 반환."""
|
|
117
|
+
return Path.home() / '.claude' / 'commands'
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def init_command(command_name, path):
|
|
121
|
+
"""
|
|
122
|
+
템플릿으로 새 커맨드 파일 초기화.
|
|
123
|
+
|
|
124
|
+
Args:
|
|
125
|
+
command_name: 커맨드 이름 (.md 확장자 제외)
|
|
126
|
+
path: 커맨드 파일이 생성될 경로
|
|
127
|
+
|
|
128
|
+
Returns:
|
|
129
|
+
생성된 커맨드 파일 경로, 오류 시 None
|
|
130
|
+
"""
|
|
131
|
+
# 커맨드명 검증
|
|
132
|
+
if not command_name:
|
|
133
|
+
print("❌ 오류: 커맨드 이름이 필요합니다")
|
|
134
|
+
return None
|
|
135
|
+
|
|
136
|
+
# .md 확장자 제거
|
|
137
|
+
if command_name.endswith('.md'):
|
|
138
|
+
command_name = command_name[:-3]
|
|
139
|
+
|
|
140
|
+
# 이름 규칙 검증
|
|
141
|
+
import re
|
|
142
|
+
if not re.match(r'^[a-z0-9-]+$', command_name):
|
|
143
|
+
print(f"❌ 오류: 커맨드 이름 '{command_name}'은 하이픈-케이스여야 합니다")
|
|
144
|
+
print(" (소문자, 숫자, 하이픈만 허용)")
|
|
145
|
+
return None
|
|
146
|
+
|
|
147
|
+
if command_name.startswith('-') or command_name.endswith('-') or '--' in command_name:
|
|
148
|
+
print(f"❌ 오류: 커맨드 이름 '{command_name}'은 하이픈으로 시작/끝나거나")
|
|
149
|
+
print(" 연속된 하이픈을 포함할 수 없습니다")
|
|
150
|
+
return None
|
|
151
|
+
|
|
152
|
+
if len(command_name) > 40:
|
|
153
|
+
print(f"❌ 오류: 커맨드 이름 '{command_name}'이 40자를 초과합니다")
|
|
154
|
+
return None
|
|
155
|
+
|
|
156
|
+
# 커맨드 파일 경로 결정
|
|
157
|
+
command_dir = Path(path).resolve()
|
|
158
|
+
command_file = command_dir / f'{command_name}.md'
|
|
159
|
+
|
|
160
|
+
# 파일 존재 여부 확인
|
|
161
|
+
if command_file.exists():
|
|
162
|
+
print(f"❌ 오류: 커맨드 파일이 이미 존재합니다: {command_file}")
|
|
163
|
+
return None
|
|
164
|
+
|
|
165
|
+
# 필요시 디렉토리 생성
|
|
166
|
+
try:
|
|
167
|
+
command_dir.mkdir(parents=True, exist_ok=True)
|
|
168
|
+
except Exception as e:
|
|
169
|
+
print(f"❌ 오류: 디렉토리 생성 실패: {e}")
|
|
170
|
+
return None
|
|
171
|
+
|
|
172
|
+
# 템플릿에서 커맨드 파일 생성
|
|
173
|
+
command_title = title_case_command_name(command_name)
|
|
174
|
+
command_content = COMMAND_TEMPLATE.format(
|
|
175
|
+
command_name=command_name,
|
|
176
|
+
command_title=command_title
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
try:
|
|
180
|
+
command_file.write_text(command_content)
|
|
181
|
+
print(f"✅ 커맨드 파일 생성: {command_file}")
|
|
182
|
+
except Exception as e:
|
|
183
|
+
print(f"❌ 오류: 커맨드 파일 생성 실패: {e}")
|
|
184
|
+
return None
|
|
185
|
+
|
|
186
|
+
# 다음 단계 안내
|
|
187
|
+
print(f"\n✅ 커맨드 '{command_name}' 초기화 완료!")
|
|
188
|
+
print(f"\n사용법: /{command_name}")
|
|
189
|
+
print("\n다음 단계:")
|
|
190
|
+
print("1. 커맨드 파일을 편집하여 TODO 항목 완성")
|
|
191
|
+
print("2. frontmatter의 description 업데이트")
|
|
192
|
+
print("3. 템플릿 내용을 실제 지시사항으로 교체")
|
|
193
|
+
print(f"4. 커맨드 테스트: /{command_name}")
|
|
194
|
+
|
|
195
|
+
return command_file
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
def main():
|
|
199
|
+
if len(sys.argv) < 3:
|
|
200
|
+
print("사용법: init_command.py <커맨드명> --path <경로>")
|
|
201
|
+
print(" init_command.py <커맨드명> --project")
|
|
202
|
+
print(" init_command.py <커맨드명> --personal")
|
|
203
|
+
print("\n커맨드명 요구사항:")
|
|
204
|
+
print(" - 하이픈-케이스 식별자 (예: 'review-security')")
|
|
205
|
+
print(" - 소문자, 숫자, 하이픈만 허용")
|
|
206
|
+
print(" - 최대 40자")
|
|
207
|
+
print("\n예시:")
|
|
208
|
+
print(" init_command.py review-security --path .claude/commands")
|
|
209
|
+
print(" init_command.py commit-fix --project")
|
|
210
|
+
print(" init_command.py my-helper --personal")
|
|
211
|
+
sys.exit(1)
|
|
212
|
+
|
|
213
|
+
command_name = sys.argv[1]
|
|
214
|
+
option = sys.argv[2]
|
|
215
|
+
|
|
216
|
+
# 옵션에 따라 경로 결정
|
|
217
|
+
if option == '--project':
|
|
218
|
+
path = get_project_commands_path()
|
|
219
|
+
elif option == '--personal':
|
|
220
|
+
path = get_personal_commands_path()
|
|
221
|
+
elif option == '--path':
|
|
222
|
+
if len(sys.argv) < 4:
|
|
223
|
+
print("❌ 오류: --path는 디렉토리 인자가 필요합니다")
|
|
224
|
+
sys.exit(1)
|
|
225
|
+
path = sys.argv[3]
|
|
226
|
+
else:
|
|
227
|
+
print(f"❌ 오류: 알 수 없는 옵션 '{option}'")
|
|
228
|
+
print("--path <경로>, --project, --personal 중 하나를 사용하세요")
|
|
229
|
+
sys.exit(1)
|
|
230
|
+
|
|
231
|
+
print(f"🚀 커맨드 초기화: {command_name}")
|
|
232
|
+
print(f" 위치: {path}")
|
|
233
|
+
print()
|
|
234
|
+
|
|
235
|
+
result = init_command(command_name, path)
|
|
236
|
+
|
|
237
|
+
if result:
|
|
238
|
+
sys.exit(0)
|
|
239
|
+
else:
|
|
240
|
+
sys.exit(1)
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
if __name__ == "__main__":
|
|
244
|
+
main()
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
커맨드 패키저 - 커맨드 파일을 배포용 zip 파일로 생성
|
|
4
|
+
|
|
5
|
+
사용법:
|
|
6
|
+
python package_command.py <commands-폴더-경로> [출력-디렉토리]
|
|
7
|
+
python package_command.py <command.md-경로> [출력-디렉토리]
|
|
8
|
+
|
|
9
|
+
예시:
|
|
10
|
+
python package_command.py .claude/commands
|
|
11
|
+
python package_command.py .claude/commands ./dist
|
|
12
|
+
python package_command.py .claude/commands/review-security.md
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import sys
|
|
16
|
+
import zipfile
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
from quick_validate import validate_command, validate_commands_folder
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def package_commands(source_path, output_dir=None):
|
|
22
|
+
"""
|
|
23
|
+
커맨드 파일(들)을 zip 파일로 패키징.
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
source_path: 커맨드 파일 또는 커맨드 폴더 경로
|
|
27
|
+
output_dir: zip 파일 출력 디렉토리 (선택)
|
|
28
|
+
|
|
29
|
+
Returns:
|
|
30
|
+
생성된 zip 파일 경로, 오류 시 None
|
|
31
|
+
"""
|
|
32
|
+
source_path = Path(source_path).resolve()
|
|
33
|
+
|
|
34
|
+
# 소스 존재 확인
|
|
35
|
+
if not source_path.exists():
|
|
36
|
+
print(f"❌ 오류: 경로를 찾을 수 없음: {source_path}")
|
|
37
|
+
return None
|
|
38
|
+
|
|
39
|
+
# 단일 파일인지 폴더인지 확인
|
|
40
|
+
is_folder = source_path.is_dir()
|
|
41
|
+
|
|
42
|
+
# 패키징 전 검증
|
|
43
|
+
print("🔍 커맨드 검증 중...")
|
|
44
|
+
|
|
45
|
+
if is_folder:
|
|
46
|
+
valid, results = validate_commands_folder(source_path)
|
|
47
|
+
for name, v, message in results:
|
|
48
|
+
status = "✅" if v else "❌"
|
|
49
|
+
print(f" [{status}] {name}: {message}")
|
|
50
|
+
if not valid:
|
|
51
|
+
print("\n❌ 검증 실패. 패키징 전에 오류를 수정해주세요.")
|
|
52
|
+
return None
|
|
53
|
+
print(f"\n✅ 모든 {len(results)}개 커맨드 검증 완료.\n")
|
|
54
|
+
else:
|
|
55
|
+
valid, message = validate_command(source_path)
|
|
56
|
+
if not valid:
|
|
57
|
+
print(f" ❌ 검증 실패: {message}")
|
|
58
|
+
print("\n패키징 전에 검증 오류를 수정해주세요.")
|
|
59
|
+
return None
|
|
60
|
+
print(f" ✅ {message}\n")
|
|
61
|
+
|
|
62
|
+
# 출력 위치 결정
|
|
63
|
+
if is_folder:
|
|
64
|
+
zip_name = source_path.name
|
|
65
|
+
else:
|
|
66
|
+
zip_name = source_path.stem
|
|
67
|
+
|
|
68
|
+
if output_dir:
|
|
69
|
+
output_path = Path(output_dir).resolve()
|
|
70
|
+
output_path.mkdir(parents=True, exist_ok=True)
|
|
71
|
+
else:
|
|
72
|
+
output_path = Path.cwd()
|
|
73
|
+
|
|
74
|
+
zip_filename = output_path / f"{zip_name}-commands.zip"
|
|
75
|
+
|
|
76
|
+
# zip 파일 생성
|
|
77
|
+
try:
|
|
78
|
+
with zipfile.ZipFile(zip_filename, 'w', zipfile.ZIP_DEFLATED) as zipf:
|
|
79
|
+
if is_folder:
|
|
80
|
+
# 폴더의 모든 .md 파일 추가
|
|
81
|
+
for md_file in source_path.glob('**/*.md'):
|
|
82
|
+
arcname = md_file.relative_to(source_path.parent)
|
|
83
|
+
zipf.write(md_file, arcname)
|
|
84
|
+
print(f" 📦 추가: {arcname}")
|
|
85
|
+
else:
|
|
86
|
+
# 단일 파일 추가
|
|
87
|
+
arcname = source_path.name
|
|
88
|
+
zipf.write(source_path, arcname)
|
|
89
|
+
print(f" 📦 추가: {arcname}")
|
|
90
|
+
|
|
91
|
+
print(f"\n✅ 패키징 완료: {zip_filename}")
|
|
92
|
+
return zip_filename
|
|
93
|
+
|
|
94
|
+
except Exception as e:
|
|
95
|
+
print(f"❌ zip 파일 생성 오류: {e}")
|
|
96
|
+
return None
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def main():
|
|
100
|
+
if len(sys.argv) < 2:
|
|
101
|
+
print("사용법: python package_command.py <commands-경로> [출력-디렉토리]")
|
|
102
|
+
print("\n예시:")
|
|
103
|
+
print(" python package_command.py .claude/commands")
|
|
104
|
+
print(" python package_command.py .claude/commands ./dist")
|
|
105
|
+
print(" python package_command.py .claude/commands/review-security.md")
|
|
106
|
+
sys.exit(1)
|
|
107
|
+
|
|
108
|
+
source_path = sys.argv[1]
|
|
109
|
+
output_dir = sys.argv[2] if len(sys.argv) > 2 else None
|
|
110
|
+
|
|
111
|
+
print(f"📦 커맨드 패키징: {source_path}")
|
|
112
|
+
if output_dir:
|
|
113
|
+
print(f" 출력 디렉토리: {output_dir}")
|
|
114
|
+
print()
|
|
115
|
+
|
|
116
|
+
result = package_commands(source_path, output_dir)
|
|
117
|
+
|
|
118
|
+
if result:
|
|
119
|
+
sys.exit(0)
|
|
120
|
+
else:
|
|
121
|
+
sys.exit(1)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
if __name__ == "__main__":
|
|
125
|
+
main()
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
커맨드 검증 스크립트 - 최소 버전
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import sys
|
|
7
|
+
import re
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def validate_command(command_path):
|
|
12
|
+
"""
|
|
13
|
+
커맨드 파일 기본 검증.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
command_path: .md 커맨드 파일 경로
|
|
17
|
+
|
|
18
|
+
Returns:
|
|
19
|
+
(유효 여부, 메시지) 튜플
|
|
20
|
+
"""
|
|
21
|
+
command_path = Path(command_path)
|
|
22
|
+
|
|
23
|
+
# 파일 존재 확인
|
|
24
|
+
if not command_path.exists():
|
|
25
|
+
return False, f"커맨드 파일을 찾을 수 없음: {command_path}"
|
|
26
|
+
|
|
27
|
+
# 파일 확장자 확인
|
|
28
|
+
if command_path.suffix != '.md':
|
|
29
|
+
return False, "커맨드 파일은 .md 확장자여야 합니다"
|
|
30
|
+
|
|
31
|
+
# 파일명 규칙 확인
|
|
32
|
+
name = command_path.stem
|
|
33
|
+
if not re.match(r'^[a-z0-9-]+$', name):
|
|
34
|
+
return False, f"커맨드 이름 '{name}'은 하이픈-케이스여야 합니다 (소문자, 숫자, 하이픈만 허용)"
|
|
35
|
+
|
|
36
|
+
if name.startswith('-') or name.endswith('-') or '--' in name:
|
|
37
|
+
return False, f"커맨드 이름 '{name}'은 하이픈으로 시작/끝나거나 연속된 하이픈을 포함할 수 없습니다"
|
|
38
|
+
|
|
39
|
+
if len(name) > 40:
|
|
40
|
+
return False, f"커맨드 이름 '{name}'이 40자를 초과합니다"
|
|
41
|
+
|
|
42
|
+
# 내용 읽기
|
|
43
|
+
try:
|
|
44
|
+
content = command_path.read_text()
|
|
45
|
+
except Exception as e:
|
|
46
|
+
return False, f"파일 읽기 오류: {e}"
|
|
47
|
+
|
|
48
|
+
# 빈 파일 확인
|
|
49
|
+
if not content.strip():
|
|
50
|
+
return False, "커맨드 파일이 비어있습니다"
|
|
51
|
+
|
|
52
|
+
# frontmatter가 있으면 검증
|
|
53
|
+
if content.startswith('---'):
|
|
54
|
+
match = re.match(r'^---\n(.*?)\n---', content, re.DOTALL)
|
|
55
|
+
if not match:
|
|
56
|
+
return False, "잘못된 frontmatter 형식 (닫는 --- 누락)"
|
|
57
|
+
|
|
58
|
+
frontmatter = match.group(1)
|
|
59
|
+
|
|
60
|
+
# 허용된 frontmatter 필드 검증
|
|
61
|
+
valid_fields = {'description', 'allowed-tools', 'argument-hint', 'model', 'disable-model-invocation'}
|
|
62
|
+
for line in frontmatter.split('\n'):
|
|
63
|
+
line = line.strip()
|
|
64
|
+
if not line or line.startswith('#'):
|
|
65
|
+
continue
|
|
66
|
+
if ':' in line:
|
|
67
|
+
field = line.split(':')[0].strip()
|
|
68
|
+
if field and field not in valid_fields:
|
|
69
|
+
return False, f"알 수 없는 frontmatter 필드: '{field}'"
|
|
70
|
+
|
|
71
|
+
# description 확인
|
|
72
|
+
desc_match = re.search(r'description:\s*(.+)', frontmatter)
|
|
73
|
+
if desc_match:
|
|
74
|
+
description = desc_match.group(1).strip()
|
|
75
|
+
if '<' in description or '>' in description:
|
|
76
|
+
return False, "description에 꺾쇠괄호(< 또는 >)를 포함할 수 없습니다"
|
|
77
|
+
if '[TODO' in description:
|
|
78
|
+
return False, "description에 TODO 플레이스홀더가 있습니다 - 완성해주세요"
|
|
79
|
+
|
|
80
|
+
# frontmatter 이후 내용 확인
|
|
81
|
+
body = content[match.end():].strip()
|
|
82
|
+
if not body:
|
|
83
|
+
return False, "커맨드에 frontmatter만 있고 지시사항이 없습니다"
|
|
84
|
+
|
|
85
|
+
return True, "커맨드가 유효합니다!"
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def validate_commands_folder(folder_path):
|
|
89
|
+
"""
|
|
90
|
+
폴더 내 모든 커맨드 파일 검증.
|
|
91
|
+
|
|
92
|
+
Args:
|
|
93
|
+
folder_path: .md 파일이 포함된 폴더 경로
|
|
94
|
+
|
|
95
|
+
Returns:
|
|
96
|
+
(전체 유효 여부, 결과 리스트) 튜플
|
|
97
|
+
"""
|
|
98
|
+
folder_path = Path(folder_path)
|
|
99
|
+
|
|
100
|
+
if not folder_path.exists():
|
|
101
|
+
return False, [("folder", False, f"폴더를 찾을 수 없음: {folder_path}")]
|
|
102
|
+
|
|
103
|
+
if not folder_path.is_dir():
|
|
104
|
+
return False, [("path", False, f"경로가 디렉토리가 아님: {folder_path}")]
|
|
105
|
+
|
|
106
|
+
# 모든 .md 파일 찾기
|
|
107
|
+
md_files = list(folder_path.glob('**/*.md'))
|
|
108
|
+
|
|
109
|
+
if not md_files:
|
|
110
|
+
return False, [("folder", False, "폴더에 .md 파일이 없습니다")]
|
|
111
|
+
|
|
112
|
+
results = []
|
|
113
|
+
all_valid = True
|
|
114
|
+
|
|
115
|
+
for md_file in md_files:
|
|
116
|
+
valid, message = validate_command(md_file)
|
|
117
|
+
results.append((md_file.name, valid, message))
|
|
118
|
+
if not valid:
|
|
119
|
+
all_valid = False
|
|
120
|
+
|
|
121
|
+
return all_valid, results
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
if __name__ == "__main__":
|
|
125
|
+
if len(sys.argv) != 2:
|
|
126
|
+
print("사용법: python quick_validate.py <command.md 또는 commands-폴더>")
|
|
127
|
+
sys.exit(1)
|
|
128
|
+
|
|
129
|
+
path = Path(sys.argv[1])
|
|
130
|
+
|
|
131
|
+
if path.is_file():
|
|
132
|
+
valid, message = validate_command(path)
|
|
133
|
+
print(message)
|
|
134
|
+
sys.exit(0 if valid else 1)
|
|
135
|
+
elif path.is_dir():
|
|
136
|
+
all_valid, results = validate_commands_folder(path)
|
|
137
|
+
for name, valid, message in results:
|
|
138
|
+
status = "✅" if valid else "❌"
|
|
139
|
+
print(f"[{status}] {name}: {message}")
|
|
140
|
+
sys.exit(0 if all_valid else 1)
|
|
141
|
+
else:
|
|
142
|
+
print(f"경로를 찾을 수 없음: {path}")
|
|
143
|
+
sys.exit(1)
|