@eliceio/cdk-cli 0.0.0-stage → 0.1.0-alpha.2
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 +526 -2
- package/es/bin/index.d.ts +2 -0
- package/es/bin/index.js +10 -0
- package/es/cli.d.ts +5 -0
- package/es/cli.js +209 -0
- package/es/commands/build/index.d.ts +30 -0
- package/es/commands/build/index.js +163 -0
- package/es/commands/check/index.d.ts +9 -0
- package/es/commands/check/index.js +31 -0
- package/es/commands/create/index.d.ts +8 -0
- package/es/commands/create/index.js +22 -0
- package/es/commands/create/scaffold.d.ts +24 -0
- package/es/commands/create/scaffold.js +82 -0
- package/es/commands/dev/index.d.ts +6 -0
- package/es/commands/dev/index.js +40 -0
- package/es/commands/doctor/index.d.ts +34 -0
- package/es/commands/doctor/index.js +311 -0
- package/es/commands/guide/index.d.ts +29 -0
- package/es/commands/guide/index.js +120 -0
- package/es/commands/skill/index.d.ts +48 -0
- package/es/commands/skill/index.js +173 -0
- package/es/core/collect.d.ts +21 -0
- package/es/core/collect.js +89 -0
- package/es/core/config.d.ts +55 -0
- package/es/core/config.js +109 -0
- package/es/core/manifest.d.ts +15 -0
- package/es/core/manifest.js +43 -0
- package/es/core/minify.d.ts +18 -0
- package/es/core/minify.js +93 -0
- package/es/core/prepare.d.ts +12 -0
- package/es/core/prepare.js +86 -0
- package/es/core/protocol.d.ts +2 -0
- package/es/core/protocol.js +4 -0
- package/es/core/sandbox.d.ts +17 -0
- package/es/core/sandbox.js +182 -0
- package/es/core/zip.d.ts +4 -0
- package/es/core/zip.js +17 -0
- package/es/dev/grading.d.ts +15 -0
- package/es/dev/grading.js +37 -0
- package/es/dev/host-page.d.ts +7 -0
- package/es/dev/host-page.js +240 -0
- package/es/dev/inject.d.ts +8 -0
- package/es/dev/inject.js +38 -0
- package/es/dev/mock-api.d.ts +65 -0
- package/es/dev/mock-api.js +269 -0
- package/es/dev/server.d.ts +25 -0
- package/es/dev/server.js +309 -0
- package/es/engines/static/index.d.ts +3 -0
- package/es/engines/static/index.js +11 -0
- package/es/engines/types.d.ts +12 -0
- package/es/engines/vite/index.d.ts +2 -0
- package/es/engines/vite/index.js +4 -0
- package/es/index.d.ts +2 -0
- package/es/index.js +2 -0
- package/es/rules/check.d.ts +2 -0
- package/es/rules/check.js +282 -0
- package/es/rules/index.d.ts +8 -0
- package/es/rules/index.js +7 -0
- package/es/rules/manifest.d.ts +39 -0
- package/es/rules/manifest.js +168 -0
- package/es/rules/node.d.ts +11 -0
- package/es/rules/node.js +87 -0
- package/es/rules/path.d.ts +7 -0
- package/es/rules/path.js +35 -0
- package/es/rules/refs.d.ts +19 -0
- package/es/rules/refs.js +111 -0
- package/es/rules/skip.d.ts +12 -0
- package/es/rules/skip.js +55 -0
- package/es/rules/spec.d.ts +3 -0
- package/es/rules/spec.js +6 -0
- package/es/rules/types.d.ts +140 -0
- package/es/rules/unused.d.ts +7 -0
- package/es/rules/unused.js +21 -0
- package/es/rules/zip.d.ts +13 -0
- package/es/rules/zip.js +45 -0
- package/es/rules.json.js +3 -0
- package/es/types.d.ts +4 -0
- package/es/version.d.ts +2 -0
- package/es/version.js +7 -0
- package/guides/content-development.md +207 -0
- package/package.json +50 -3
- package/rules.json +608 -0
- package/skills/_shared/always.md +7 -0
- package/skills/elice-content-check/SKILL.md +22 -0
- package/skills/elice-content-create/SKILL.md +21 -0
- package/skills/elice-content-migrate/SKILL.md +21 -0
- package/templates/_shared/lib/cdk-mock.d.ts +94 -0
- package/templates/_shared/lib/cdk-mock.js +429 -0
- package/templates/_shared/lib/cdk.js +3 -0
- package/templates/_shared/lib/elice-content.css +262 -0
- package/templates/_shared/lib/elice-content.d.ts +123 -0
- package/templates/_shared/lib/elice-content.js +534 -0
- package/templates/_shared/lib/elice-tokens.css +446 -0
- package/templates/blank/README.md +64 -0
- package/templates/blank/commentary.txt +2 -0
- package/templates/blank/content.json +4 -0
- package/templates/blank/edit.html +15 -0
- package/templates/blank/elice.config.json +12 -0
- package/templates/blank/gitignore +3 -0
- package/templates/blank/index.html +15 -0
- package/templates/blank/instructor.html +15 -0
- package/templates/blank/screens/edit.js +21 -0
- package/templates/blank/screens/instructor.js +9 -0
- package/templates/blank/screens/learn.js +19 -0
- package/templates/blank/styles.css +1 -0
- package/templates/quiz/README.md +108 -0
- package/templates/quiz/commentary.txt +2 -0
- package/templates/quiz/content.json +81 -0
- package/templates/quiz/core/behaviors.d.ts +59 -0
- package/templates/quiz/core/behaviors.js +310 -0
- package/templates/quiz/core/dom.d.ts +13 -0
- package/templates/quiz/core/dom.js +83 -0
- package/templates/quiz/core/editor.d.ts +48 -0
- package/templates/quiz/core/editor.js +206 -0
- package/templates/quiz/core/markdown.d.ts +2 -0
- package/templates/quiz/core/markdown.js +84 -0
- package/templates/quiz/core/model.d.ts +20 -0
- package/templates/quiz/core/model.js +203 -0
- package/templates/quiz/edit.html +17 -0
- package/templates/quiz/elice.config.json +14 -0
- package/templates/quiz/gitignore +3 -0
- package/templates/quiz/grading.json +13 -0
- package/templates/quiz/index.html +17 -0
- package/templates/quiz/instructor.html +17 -0
- package/templates/quiz/screens/edit.js +139 -0
- package/templates/quiz/screens/instructor.js +27 -0
- package/templates/quiz/screens/learn.js +55 -0
- package/templates/quiz/styles.css +570 -0
- package/templates/quiz/ui/templates/choice.js +22 -0
- package/templates/quiz/ui/templates/edit.d.ts +13 -0
- package/templates/quiz/ui/templates/edit.js +183 -0
- package/templates/quiz/ui/templates/group.js +68 -0
- package/templates/quiz/ui/templates/index.d.ts +5 -0
- package/templates/quiz/ui/templates/index.js +17 -0
- package/templates/quiz/ui/templates/order.js +35 -0
- package/templates/quiz/ui/templates/page.js +29 -0
- package/templates/quiz/ui/templates/question.js +28 -0
- package/templates/quiz/ui/templates/text.js +16 -0
- package/templates/quiz/ui/texts.d.ts +3 -0
- package/templates/quiz/ui/texts.js +127 -0
- package/templates/quiz/ui/theme.css +50 -0
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { access, readFile, appendFile } from 'node:fs/promises';
|
|
2
|
+
import { resolve, join } from 'node:path';
|
|
3
|
+
import { loadConfig, CONFIG_FILE, loadGrading, GRADING_DATA_FILE } from '../../core/config.js';
|
|
4
|
+
import { prepareContent } from '../../core/prepare.js';
|
|
5
|
+
import { checkFiles } from '../../rules/check.js';
|
|
6
|
+
import { lineSkipper } from '../../rules/skip.js';
|
|
7
|
+
import { RULES_VERSION } from '../../rules/spec.js';
|
|
8
|
+
import 'fflate';
|
|
9
|
+
import { VERSION } from '../../version.js';
|
|
10
|
+
import { skillsDir, skillNames, inspectSkill } from '../skill/index.js';
|
|
11
|
+
|
|
12
|
+
const usage = `사용법: ecdk doctor [프로젝트 폴더] [--fix] [--json]
|
|
13
|
+
|
|
14
|
+
환경(Node, 패키지 매니저)과 프로젝트(설정, 원본, 정답 유출, 검사)를 점검한다.
|
|
15
|
+
--fix 자동으로 고칠 수 있는 항목(auto)을 고친다
|
|
16
|
+
|
|
17
|
+
종료 코드: 0 실패 없음 · 1 실패 있음 · 2 잘못된 사용`;
|
|
18
|
+
const MIN_NODE = [20, 19];
|
|
19
|
+
const LOCKFILES = {
|
|
20
|
+
'package-lock.json': 'npm',
|
|
21
|
+
'pnpm-lock.yaml': 'pnpm',
|
|
22
|
+
'yarn.lock': 'yarn',
|
|
23
|
+
'bun.lockb': 'bun',
|
|
24
|
+
'bun.lock': 'bun'
|
|
25
|
+
};
|
|
26
|
+
const exists = p => access(p).then(() => true, () => false);
|
|
27
|
+
function checkNode(version) {
|
|
28
|
+
const [major = 0, minor = 0] = version.replace(/^v/, '').split('.').map(Number);
|
|
29
|
+
const ok = major > MIN_NODE[0] || major === MIN_NODE[0] && minor >= MIN_NODE[1];
|
|
30
|
+
return ok ? {
|
|
31
|
+
id: 'env.node',
|
|
32
|
+
level: 'ok',
|
|
33
|
+
message: `Node ${version}`
|
|
34
|
+
} : {
|
|
35
|
+
id: 'env.node',
|
|
36
|
+
level: 'fail',
|
|
37
|
+
message: `Node ${version}은 지원하지 않습니다 (${MIN_NODE.join('.')} 이상 필요).`,
|
|
38
|
+
fix: {
|
|
39
|
+
description: 'Node 22 LTS 이상 설치',
|
|
40
|
+
command: 'https://nodejs.org',
|
|
41
|
+
auto: false
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
async function checkPackageManager(dir) {
|
|
46
|
+
const found = [];
|
|
47
|
+
for (const [file, pm] of Object.entries(LOCKFILES)) if (await exists(join(dir, file))) found.push(`${pm}(${file})`);
|
|
48
|
+
if (found.length > 1) return {
|
|
49
|
+
id: 'env.package-manager',
|
|
50
|
+
level: 'warn',
|
|
51
|
+
message: `잠금 파일이 여러 개입니다: ${found.join(', ')}. 설치 결과가 사람마다 달라질 수 있습니다.`,
|
|
52
|
+
fix: {
|
|
53
|
+
description: '쓰는 패키지 매니저 하나의 잠금 파일만 남기기',
|
|
54
|
+
auto: false
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
id: 'env.package-manager',
|
|
59
|
+
level: 'ok',
|
|
60
|
+
message: found[0] ?? '잠금 파일 없음 (프로젝트 없이 단일 콘텐츠로 사용 중)'
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
async function checkGitignore(dir, config) {
|
|
64
|
+
const path = join(dir, '.gitignore');
|
|
65
|
+
const lines = (await readFile(path, 'utf8').catch(() => '')).split(/\r?\n/).map(l => l.trim());
|
|
66
|
+
const want = [`${config.outDir.replace(/^\.\//, '').replace(/\/$/, '')}/`, '.env'];
|
|
67
|
+
const missing = want.filter(w => !lines.includes(w) && !lines.includes(w.replace(/\/$/, '')) && !lines.includes(`/${w}`));
|
|
68
|
+
if (missing.length === 0) return {
|
|
69
|
+
id: 'project.gitignore',
|
|
70
|
+
level: 'ok',
|
|
71
|
+
message: '.gitignore에 산출물·.env 포함'
|
|
72
|
+
};
|
|
73
|
+
return {
|
|
74
|
+
id: 'project.gitignore',
|
|
75
|
+
level: 'warn',
|
|
76
|
+
message: `.gitignore에 ${missing.join(', ')}가 없습니다. 빌드 결과나 비밀 값이 저장소에 올라갈 수 있습니다.`,
|
|
77
|
+
fix: {
|
|
78
|
+
description: `.gitignore에 ${missing.join(', ')} 추가`,
|
|
79
|
+
auto: true
|
|
80
|
+
},
|
|
81
|
+
apply: async () => {
|
|
82
|
+
const current = await readFile(path, 'utf8').catch(() => '');
|
|
83
|
+
await appendFile(path, `${current && !current.endsWith('\n') ? '\n' : ''}${missing.join('\n')}\n`);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/** Claude Code 스킬: 프로젝트(.claude/skills) 또는 홈(~/.claude/skills)에 모두 있고 CLI와 같은 버전인지 */
|
|
88
|
+
function checkSkills(dir, home) {
|
|
89
|
+
const fix = {
|
|
90
|
+
description: '스킬 설치 · 갱신',
|
|
91
|
+
command: 'ecdk skill install',
|
|
92
|
+
auto: false
|
|
93
|
+
};
|
|
94
|
+
const project = skillsDir({
|
|
95
|
+
project: true,
|
|
96
|
+
cwd: dir
|
|
97
|
+
});
|
|
98
|
+
const user = skillsDir({
|
|
99
|
+
project: false,
|
|
100
|
+
home
|
|
101
|
+
});
|
|
102
|
+
const statuses = skillNames().map(name => {
|
|
103
|
+
const local = inspectSkill(project, name);
|
|
104
|
+
return local.state === 'missing' ? inspectSkill(user, name) : local;
|
|
105
|
+
});
|
|
106
|
+
const missing = statuses.filter(s => s.state === 'missing').map(s => s.name);
|
|
107
|
+
const outdated = statuses.filter(s => s.state === 'outdated').map(s => s.name);
|
|
108
|
+
if (missing.length > 0) return {
|
|
109
|
+
id: 'skill.installed',
|
|
110
|
+
level: 'warn',
|
|
111
|
+
message: `Claude Code 스킬 없음: ${missing.join(', ')}`,
|
|
112
|
+
fix
|
|
113
|
+
};
|
|
114
|
+
if (outdated.length > 0) return {
|
|
115
|
+
id: 'skill.installed',
|
|
116
|
+
level: 'warn',
|
|
117
|
+
message: `Claude Code 스킬이 CLI보다 오래됨: ${outdated.join(', ')}`,
|
|
118
|
+
fix
|
|
119
|
+
};
|
|
120
|
+
const newer = statuses.filter(s => s.state === 'newer').map(s => `${s.name}(${s.version})`);
|
|
121
|
+
return {
|
|
122
|
+
id: 'skill.installed',
|
|
123
|
+
level: 'ok',
|
|
124
|
+
message: newer.length > 0 ? `Claude Code 스킬 ${statuses.length}개 · CLI(${VERSION})보다 새 버전: ${newer.join(', ')}` : `Claude Code 스킬 ${statuses.length}개`
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/** grading.json: 형식 · 유형이 지원 유형 안인지. 정답 비교 유형을 지원하는데 파일이 없으면 로컬 채점을 흉내 낼 수 없다 */
|
|
128
|
+
async function checkGrading(dir, config) {
|
|
129
|
+
const id = 'project.grading';
|
|
130
|
+
if (!config.gradingTypes || config.gradingTypes.length === 0) return {
|
|
131
|
+
id,
|
|
132
|
+
level: 'skip',
|
|
133
|
+
message: '채점 유형 없음 (문제 설명)'
|
|
134
|
+
};
|
|
135
|
+
try {
|
|
136
|
+
const grading = await loadGrading(dir, config);
|
|
137
|
+
const needsAnswers = config.gradingTypes.some(t => t === 'pattern' || t === 'rubric');
|
|
138
|
+
if (needsAnswers && !(await exists(join(dir, GRADING_DATA_FILE)))) return {
|
|
139
|
+
id,
|
|
140
|
+
level: 'warn',
|
|
141
|
+
message: `${GRADING_DATA_FILE}이 없어 ecdk dev에서 pattern · rubric 채점을 흉내 낼 수 없습니다`,
|
|
142
|
+
fix: {
|
|
143
|
+
description: `정답을 ${GRADING_DATA_FILE}에 적기 (zip에는 들어가지 않음)`,
|
|
144
|
+
auto: false
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
return {
|
|
148
|
+
id,
|
|
149
|
+
level: 'ok',
|
|
150
|
+
message: `${GRADING_DATA_FILE}: 로컬 채점 유형 ${grading?.type ?? '-'}`
|
|
151
|
+
};
|
|
152
|
+
} catch (e) {
|
|
153
|
+
return {
|
|
154
|
+
id,
|
|
155
|
+
level: 'fail',
|
|
156
|
+
message: e.message,
|
|
157
|
+
fix: {
|
|
158
|
+
description: `${GRADING_DATA_FILE} 형식을 고치기 (ecdk guide 2)`,
|
|
159
|
+
auto: false
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
async function doctor(target, opts) {
|
|
165
|
+
const dir = resolve(target);
|
|
166
|
+
const checks = [checkNode(opts.nodeVersion ?? process.version), await checkPackageManager(dir)];
|
|
167
|
+
let config = null;
|
|
168
|
+
try {
|
|
169
|
+
config = await loadConfig(dir);
|
|
170
|
+
checks.push({
|
|
171
|
+
id: 'project.config',
|
|
172
|
+
level: 'ok',
|
|
173
|
+
message: (await exists(join(dir, CONFIG_FILE))) ? `${CONFIG_FILE} 읽음` : `${CONFIG_FILE} 없음 (기본값 사용)`
|
|
174
|
+
});
|
|
175
|
+
} catch (e) {
|
|
176
|
+
checks.push({
|
|
177
|
+
id: 'project.config',
|
|
178
|
+
level: 'fail',
|
|
179
|
+
message: `${CONFIG_FILE}을 읽을 수 없습니다: ${e.message}`
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
if (config) checks.push(await checkGrading(dir, config));
|
|
183
|
+
if (config) {
|
|
184
|
+
const srcDir = resolve(dir, config.root);
|
|
185
|
+
if (!(await exists(srcDir))) {
|
|
186
|
+
checks.push({
|
|
187
|
+
id: 'project.root',
|
|
188
|
+
level: 'fail',
|
|
189
|
+
message: `원본 폴더가 없습니다: ${config.root}`
|
|
190
|
+
});
|
|
191
|
+
} else {
|
|
192
|
+
let prepared = null;
|
|
193
|
+
try {
|
|
194
|
+
prepared = await prepareContent(dir, config);
|
|
195
|
+
} catch (e) {
|
|
196
|
+
checks.push({
|
|
197
|
+
id: 'project.root',
|
|
198
|
+
level: 'fail',
|
|
199
|
+
message: e.message
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
if (prepared) {
|
|
203
|
+
const {
|
|
204
|
+
files
|
|
205
|
+
} = prepared;
|
|
206
|
+
checks.push({
|
|
207
|
+
id: 'project.root',
|
|
208
|
+
level: 'ok',
|
|
209
|
+
message: `원본 ${config.root} · zip에 들어갈 파일 ${files.length}개`
|
|
210
|
+
});
|
|
211
|
+
// 빌드에서 빠지는 정답·설정 파일을 콘텐츠가 참조하면: 배포본에서 깨지고, 정답을 콘텐츠로 가져오려 한 신호.
|
|
212
|
+
// 주석 줄은 보지 않고, 일부러 참조하는 줄은 `ecdk-ignore project.answer-import`로 끈다
|
|
213
|
+
// (템플릿 mock SDK는 프로젝트 폴더에서 열 때 로컬 채점용으로 elice.config.json · grading.json을 읽는다)
|
|
214
|
+
const decoder = new TextDecoder();
|
|
215
|
+
const leaks = files.filter(f => /\.(html?|m?js|css)$/i.test(f.path)).filter(f => referencesAnswerFile(decoder.decode(f.data))).map(f => f.path);
|
|
216
|
+
checks.push(leaks.length > 0 ? {
|
|
217
|
+
id: 'project.answer-import',
|
|
218
|
+
level: 'fail',
|
|
219
|
+
message: `콘텐츠가 정답·설정 파일을 참조합니다: ${leaks.join(', ')}. 정답은 서버에서 채점하고 콘텐츠에는 넣지 않습니다.`,
|
|
220
|
+
fix: {
|
|
221
|
+
description: '정답은 편집 화면의 채점 설정으로 따로 올리고, 콘텐츠는 답만 제출',
|
|
222
|
+
auto: false
|
|
223
|
+
}
|
|
224
|
+
} : {
|
|
225
|
+
id: 'project.answer-import',
|
|
226
|
+
level: 'ok',
|
|
227
|
+
message: '콘텐츠가 정답·설정 파일을 참조하지 않음'
|
|
228
|
+
});
|
|
229
|
+
const result = checkFiles(files, {
|
|
230
|
+
input: 'zip',
|
|
231
|
+
bundlesModules: true
|
|
232
|
+
});
|
|
233
|
+
const errors = result.issues.filter(i => i.level === 'error');
|
|
234
|
+
const warns = result.issues.length - errors.length;
|
|
235
|
+
checks.push(errors.length > 0 ? {
|
|
236
|
+
id: 'project.check',
|
|
237
|
+
level: 'fail',
|
|
238
|
+
message: `검사 오류 ${errors.length}개 · 경고 ${warns}개 (${[...new Set(errors.map(i => i.id))].join(', ')})`,
|
|
239
|
+
fix: {
|
|
240
|
+
description: '자세한 위치 확인',
|
|
241
|
+
command: 'ecdk build',
|
|
242
|
+
auto: false
|
|
243
|
+
}
|
|
244
|
+
} : {
|
|
245
|
+
id: 'project.check',
|
|
246
|
+
level: warns > 0 ? 'warn' : 'ok',
|
|
247
|
+
message: `검사 오류 0개 · 경고 ${warns}개`
|
|
248
|
+
});
|
|
249
|
+
const near = result.issues.filter(i => i.id === 'limit.near');
|
|
250
|
+
if (near.length > 0) checks.push({
|
|
251
|
+
id: 'project.limits',
|
|
252
|
+
level: 'warn',
|
|
253
|
+
message: near.map(i => i.message).join(' ')
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
if (await exists(join(dir, 'package.json'))) checks.push(await checkGitignore(dir, config));
|
|
258
|
+
}
|
|
259
|
+
checks.push(checkSkills(dir, opts.home));
|
|
260
|
+
// 서버 API(D8)가 정해지면 규칙·프로토콜 버전을 서버와 비교
|
|
261
|
+
checks.push({
|
|
262
|
+
id: 'compat.server',
|
|
263
|
+
level: 'skip',
|
|
264
|
+
message: `서버 규칙 버전 비교는 아직 없음 (로컬 규칙 ${RULES_VERSION})`
|
|
265
|
+
});
|
|
266
|
+
if (opts.fix) {
|
|
267
|
+
for (const c of checks) {
|
|
268
|
+
if (c.apply && c.level !== 'ok') {
|
|
269
|
+
await c.apply();
|
|
270
|
+
c.fixed = true;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
const out = checks.map(({
|
|
275
|
+
apply,
|
|
276
|
+
...c
|
|
277
|
+
}) => c);
|
|
278
|
+
return {
|
|
279
|
+
ok: !out.some(c => c.level === 'fail'),
|
|
280
|
+
cli: VERSION,
|
|
281
|
+
rules: RULES_VERSION,
|
|
282
|
+
checks: out
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
function formatText(r) {
|
|
286
|
+
const lines = r.checks.map(c => {
|
|
287
|
+
const head = `[${c.fixed ? 'fixed' : c.level}] ${c.id.padEnd(22)} ${c.message}`;
|
|
288
|
+
if (!c.fix || c.fixed || c.level === 'ok') return head;
|
|
289
|
+
return `${head}\n${' '.repeat(8)}→ ${c.fix.description}${c.fix.command ? `: ${c.fix.command}` : ''}${c.fix.auto ? ' (--fix로 자동)' : ''}`;
|
|
290
|
+
});
|
|
291
|
+
const count = l => r.checks.filter(c => c.level === l && !c.fixed).length;
|
|
292
|
+
lines.push('', `결과: 실패 ${count('fail')} · 경고 ${count('warn')} (ecdk ${r.cli}, 규칙 ${r.rules}, 기계용: --json)`);
|
|
293
|
+
return lines.join('\n');
|
|
294
|
+
}
|
|
295
|
+
async function run(args) {
|
|
296
|
+
const result = await doctor(args.target, {
|
|
297
|
+
fix: args.fix
|
|
298
|
+
});
|
|
299
|
+
return {
|
|
300
|
+
exitCode: result.ok ? 0 : 1,
|
|
301
|
+
output: args.json ? JSON.stringify(result, null, 2) : formatText(result)
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
const ANSWER_FILE = /\b(?:answers\.[a-z]+|elice\.config\.[a-z]+|grading\.json)\b/i;
|
|
305
|
+
/** 주석뿐이 아닌 줄에서 정답·설정 파일 이름이 나오는지. 줄 건너뛰기는 금지 API 검사와 같은 규칙(content-rules lineSkipper) */
|
|
306
|
+
function referencesAnswerFile(text) {
|
|
307
|
+
const skip = lineSkipper(text);
|
|
308
|
+
return skip.lines.some((line, i) => ANSWER_FILE.test(line) && !skip.isSkipped(i + 1, 'project.answer-import'));
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export { checkNode, doctor, formatText, referencesAnswerFile, run, usage };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { CommandResult } from '../../types.js';
|
|
2
|
+
export declare const usage = "\uC0AC\uC6A9\uBC95: ecdk guide [\uC8FC\uC81C] [--json]\n\n \uC5D0\uC774\uC804\uD2B8(Claude \uB4F1)\uAC00 \uD559\uC2B5\uC790\uB8CC\uB97C \uB9CC\uB4E4 \uB54C \uC77D\uB294 \uAC1C\uBC1C \uAC00\uC774\uB4DC(\uC601\uC5B4)\uB97C \uCD9C\uB825\uD55C\uB2E4.\n \uC8FC\uC81C \uC5C6\uC774: \uC8FC\uC81C \uBAA9\uB85D \u00B7 \uC8FC\uC81C: \uADF8 \uC808\uB9CC (\uBC88\uD638\uB098 \uC55E\uBD80\uBD84\uB9CC \uC801\uC5B4\uB3C4 \uB428, \uC608: build \u00B7 10) \u00B7 all: \uC804\uCCB4\n\n\uC885\uB8CC \uCF54\uB4DC: 0 \uC131\uACF5 \u00B7 2 \uC5C6\uB294 \uC8FC\uC81C";
|
|
3
|
+
/** CLI 패키지에 들어 있는 가이드: CLI와 같은 버전이라 명령 · 규칙과 어긋나지 않는다 */
|
|
4
|
+
export declare const GUIDE_FILE: string;
|
|
5
|
+
export interface GuideTopic {
|
|
6
|
+
/** 제목을 소문자 · 하이픈으로 (예: "10. Build" → "10-build") */
|
|
7
|
+
id: string;
|
|
8
|
+
title: string;
|
|
9
|
+
/** 제목 줄을 포함한 절 본문 */
|
|
10
|
+
body: string;
|
|
11
|
+
}
|
|
12
|
+
export interface Guide {
|
|
13
|
+
title: string;
|
|
14
|
+
/** 첫 `##` 앞 (무엇을 만드는지 · 화면 표) */
|
|
15
|
+
intro: string;
|
|
16
|
+
topics: GuideTopic[];
|
|
17
|
+
}
|
|
18
|
+
/** 제목 → 주제 id: 소문자, 글자 · 숫자가 아닌 것이 이어지면 하이픈 하나 */
|
|
19
|
+
export declare function toTopicId(title: string): string;
|
|
20
|
+
/** `##` 절로 나눈다. 코드 블록 안의 `##`는 제목이 아니다 */
|
|
21
|
+
export declare function parseGuide(markdown: string): Guide;
|
|
22
|
+
export declare function loadGuide(file?: string): Guide;
|
|
23
|
+
/** 주제 찾기: id 그대로 → 번호(10) → id 안의 낱말(build) 순. 여럿이면 찾지 못한 것으로 */
|
|
24
|
+
export declare function findTopic(guide: Guide, query: string): GuideTopic | undefined;
|
|
25
|
+
export declare function run(args: {
|
|
26
|
+
topic?: string | undefined;
|
|
27
|
+
json: boolean;
|
|
28
|
+
file?: string;
|
|
29
|
+
}): CommandResult;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { VERSION } from '../../version.js';
|
|
4
|
+
|
|
5
|
+
const usage = `사용법: ecdk guide [주제] [--json]
|
|
6
|
+
|
|
7
|
+
에이전트(Claude 등)가 학습자료를 만들 때 읽는 개발 가이드(영어)를 출력한다.
|
|
8
|
+
주제 없이: 주제 목록 · 주제: 그 절만 (번호나 앞부분만 적어도 됨, 예: build · 10) · all: 전체
|
|
9
|
+
|
|
10
|
+
종료 코드: 0 성공 · 2 없는 주제`;
|
|
11
|
+
/** CLI 패키지에 들어 있는 가이드: CLI와 같은 버전이라 명령 · 규칙과 어긋나지 않는다 */
|
|
12
|
+
const GUIDE_FILE = fileURLToPath(new URL('../../../guides/content-development.md', import.meta.url));
|
|
13
|
+
/** 제목 → 주제 id: 소문자, 글자 · 숫자가 아닌 것이 이어지면 하이픈 하나 */
|
|
14
|
+
function toTopicId(title) {
|
|
15
|
+
return title.toLowerCase().replace(/[^\p{L}\p{N}]+/gu, '-').replace(/^-+|-+$/g, '');
|
|
16
|
+
}
|
|
17
|
+
/** `##` 절로 나눈다. 코드 블록 안의 `##`는 제목이 아니다 */
|
|
18
|
+
function parseGuide(markdown) {
|
|
19
|
+
const title = /^#\s+(.+?)\s*$/m.exec(markdown)?.[1] ?? '';
|
|
20
|
+
const intro = [];
|
|
21
|
+
const topics = [];
|
|
22
|
+
let current = null;
|
|
23
|
+
let fence = null;
|
|
24
|
+
const flush = () => {
|
|
25
|
+
if (current) topics.push({
|
|
26
|
+
id: toTopicId(current.title),
|
|
27
|
+
title: current.title,
|
|
28
|
+
body: current.lines.join('\n').trimEnd()
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
for (const line of markdown.split('\n')) {
|
|
32
|
+
const marker = /^\s*(`{3,}|~{3,})/.exec(line)?.[1];
|
|
33
|
+
if (marker) {
|
|
34
|
+
if (fence === null) fence = marker;else if (marker.startsWith(fence[0] ?? '') && marker.length >= fence.length) fence = null;
|
|
35
|
+
}
|
|
36
|
+
const heading = fence === null ? /^##\s+(.+?)\s*#*\s*$/.exec(line)?.[1] : undefined;
|
|
37
|
+
if (heading) {
|
|
38
|
+
flush();
|
|
39
|
+
current = {
|
|
40
|
+
title: heading,
|
|
41
|
+
lines: [line]
|
|
42
|
+
};
|
|
43
|
+
} else if (current) current.lines.push(line);else if (!/^#\s/.test(line)) intro.push(line);
|
|
44
|
+
}
|
|
45
|
+
flush();
|
|
46
|
+
return {
|
|
47
|
+
title,
|
|
48
|
+
intro: intro.join('\n').trim(),
|
|
49
|
+
topics
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function loadGuide(file = GUIDE_FILE) {
|
|
53
|
+
return parseGuide(readFileSync(file, 'utf8'));
|
|
54
|
+
}
|
|
55
|
+
/** 주제 찾기: id 그대로 → 번호(10) → id 안의 낱말(build) 순. 여럿이면 찾지 못한 것으로 */
|
|
56
|
+
function findTopic(guide, query) {
|
|
57
|
+
const q = toTopicId(query);
|
|
58
|
+
if (!q) return undefined;
|
|
59
|
+
const exact = guide.topics.find(t => t.id === q);
|
|
60
|
+
if (exact) return exact;
|
|
61
|
+
const byNumber = guide.topics.find(t => t.id.startsWith(`${q}-`) && /^\d+$/.test(q));
|
|
62
|
+
if (byNumber) return byNumber;
|
|
63
|
+
// 번호 없이 적은 id (예: what-the-person-decides → 0-what-the-person-decides)
|
|
64
|
+
const byName = guide.topics.find(t => t.id.replace(/^\d+-/, '') === q);
|
|
65
|
+
if (byName) return byName;
|
|
66
|
+
const partial = guide.topics.filter(t => t.id.split('-').some(word => word === q) || t.id.startsWith(q));
|
|
67
|
+
return partial.length === 1 ? partial[0] : undefined;
|
|
68
|
+
}
|
|
69
|
+
function list(guide) {
|
|
70
|
+
return [`# ${guide.title} (ecdk ${VERSION})`, '', guide.intro, '', 'Topics (read one with `ecdk guide <topic>`, everything with `ecdk guide all`):', ...guide.topics.map(t => `- ${t.id}: ${t.title}`)].join('\n');
|
|
71
|
+
}
|
|
72
|
+
function run(args) {
|
|
73
|
+
const guide = loadGuide(args.file);
|
|
74
|
+
const topics = guide.topics.map(({
|
|
75
|
+
id,
|
|
76
|
+
title
|
|
77
|
+
}) => ({
|
|
78
|
+
id,
|
|
79
|
+
title
|
|
80
|
+
}));
|
|
81
|
+
if (args.topic === undefined) {
|
|
82
|
+
return {
|
|
83
|
+
exitCode: 0,
|
|
84
|
+
output: args.json ? JSON.stringify({
|
|
85
|
+
title: guide.title,
|
|
86
|
+
version: VERSION,
|
|
87
|
+
intro: guide.intro,
|
|
88
|
+
topics
|
|
89
|
+
}, null, 2) : list(guide)
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
if (args.topic === 'all') {
|
|
93
|
+
const text = readFileSync(args.file ?? GUIDE_FILE, 'utf8');
|
|
94
|
+
return {
|
|
95
|
+
exitCode: 0,
|
|
96
|
+
output: args.json ? JSON.stringify({
|
|
97
|
+
title: guide.title,
|
|
98
|
+
version: VERSION,
|
|
99
|
+
markdown: text
|
|
100
|
+
}, null, 2) : text
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
const topic = findTopic(guide, args.topic);
|
|
104
|
+
if (!topic) {
|
|
105
|
+
const message = `없는 주제입니다: ${args.topic}`;
|
|
106
|
+
return {
|
|
107
|
+
exitCode: 2,
|
|
108
|
+
output: args.json ? JSON.stringify({
|
|
109
|
+
error: message,
|
|
110
|
+
topics
|
|
111
|
+
}, null, 2) : `${message}\n\n${topics.map(t => `- ${t.id}: ${t.title}`).join('\n')}`
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
exitCode: 0,
|
|
116
|
+
output: args.json ? JSON.stringify(topic, null, 2) : topic.body
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export { GUIDE_FILE, findTopic, loadGuide, parseGuide, run, toTopicId, usage };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { CommandResult } from '../../types.js';
|
|
2
|
+
export declare const usage = "\uC0AC\uC6A9\uBC95: ecdk skill install [--project] [--force] [--json]\n\n Claude Code\uAC00 Elice \uD559\uC2B5\uC790\uB8CC \uC694\uCCAD\uC744 \uC54C\uC544\uBCF4\uACE0 ecdk guide\uB97C \uC77D\uAC8C \uD558\uB294 \uC2A4\uD0AC(stub)\uC744 \uC124\uCE58\uD55C\uB2E4.\n \uAE30\uBCF8\uC740 ~/.claude/skills/ (\uBAA8\uB4E0 \uD504\uB85C\uC81D\uD2B8), --project\uBA74 \uD604\uC7AC \uD3F4\uB354\uC758 .claude/skills/.\n \uAC19\uC740 \uBC84\uC804\uC774\uBA74 \uAC74\uB108\uB6F0\uACE0, \uC61B \uBC84\uC804\uC774\uBA74 \uBC14\uAFBC\uB2E4. CLI\uBCF4\uB2E4 \uC0C8 \uBC84\uC804\uC774\uAC70\uB098 \uC190\uC73C\uB85C \uACE0\uCE5C \uC2A4\uD0AC\uC740 --force\uC77C \uB54C\uB9CC \uBC14\uAFBC\uB2E4.\n\n\uC885\uB8CC \uCF54\uB4DC: 0 \uC131\uACF5 \u00B7 1 \uC190\uC73C\uB85C \uACE0\uCE5C \uC2A4\uD0AC\uC774 \uC788\uC5B4 \uAC74\uB108\uB700 \u00B7 2 \uC798\uBABB\uB41C \uC0AC\uC6A9";
|
|
3
|
+
export type SkillState = 'missing' | 'current' | 'outdated' | 'newer' | 'modified';
|
|
4
|
+
export interface SkillStatus {
|
|
5
|
+
name: string;
|
|
6
|
+
path: string;
|
|
7
|
+
state: SkillState;
|
|
8
|
+
/** 설치된 스킬의 버전 (없으면 undefined) */
|
|
9
|
+
version?: string | undefined;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* semver 순서로 a가 b보다 앞이면 음수, 뒤면 양수, 같으면 0. 읽을 수 없는 버전은 undefined.
|
|
13
|
+
* 정식 버전은 같은 숫자의 pre-release보다 뒤 (1.0.0-alpha.1 < 1.0.0)
|
|
14
|
+
*/
|
|
15
|
+
export declare function compareVersions(a: string, b: string): number | undefined;
|
|
16
|
+
/** 패키지에 든 스킬 이름 (공통 폴더 제외) */
|
|
17
|
+
export declare function skillNames(root?: string): string[];
|
|
18
|
+
/** 원본에 공통 규칙과 버전 줄을 넣는다. 지문은 버전 줄을 뺀 본문으로 */
|
|
19
|
+
export declare function renderSkill(name: string, root?: string, version?: string): string;
|
|
20
|
+
/** 설치 위치: --project면 현재 폴더, 아니면 홈 */
|
|
21
|
+
export declare function skillsDir(opts: {
|
|
22
|
+
project: boolean;
|
|
23
|
+
cwd?: string | undefined;
|
|
24
|
+
home?: string | undefined;
|
|
25
|
+
}): string;
|
|
26
|
+
/** 설치된 스킬의 상태. 지문이 본문과 다르면 손으로 고친 것 */
|
|
27
|
+
export declare function inspectSkill(dir: string, name: string, version?: string): SkillStatus;
|
|
28
|
+
export interface InstallResult {
|
|
29
|
+
dir: string;
|
|
30
|
+
version: string;
|
|
31
|
+
skills: (SkillStatus & {
|
|
32
|
+
action: 'installed' | 'updated' | 'skipped' | 'kept' | 'newer';
|
|
33
|
+
})[];
|
|
34
|
+
}
|
|
35
|
+
export declare function install(opts: {
|
|
36
|
+
project: boolean;
|
|
37
|
+
force: boolean;
|
|
38
|
+
cwd?: string | undefined;
|
|
39
|
+
home?: string | undefined;
|
|
40
|
+
root?: string | undefined;
|
|
41
|
+
version?: string | undefined;
|
|
42
|
+
}): Promise<InstallResult>;
|
|
43
|
+
export declare function run(args: {
|
|
44
|
+
sub: string | undefined;
|
|
45
|
+
project: boolean;
|
|
46
|
+
force: boolean;
|
|
47
|
+
json: boolean;
|
|
48
|
+
}): Promise<CommandResult>;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { readFileSync, readdirSync, existsSync } from 'node:fs';
|
|
3
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { homedir } from 'node:os';
|
|
5
|
+
import { join, resolve } from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
|
|
8
|
+
const usage = `사용법: ecdk skill install [--project] [--force] [--json]
|
|
9
|
+
|
|
10
|
+
Claude Code가 Elice 학습자료 요청을 알아보고 ecdk guide를 읽게 하는 스킬(stub)을 설치한다.
|
|
11
|
+
기본은 ~/.claude/skills/ (모든 프로젝트), --project면 현재 폴더의 .claude/skills/.
|
|
12
|
+
같은 버전이면 건너뛰고, 옛 버전이면 바꾼다. CLI보다 새 버전이거나 손으로 고친 스킬은 --force일 때만 바꾼다.
|
|
13
|
+
|
|
14
|
+
종료 코드: 0 성공 · 1 손으로 고친 스킬이 있어 건너뜀 · 2 잘못된 사용`;
|
|
15
|
+
/** CLI 패키지의 skills/ (es/commands/skill/와 src/commands/skill/ 모두 세 단계 위) */
|
|
16
|
+
const SKILLS_ROOT = fileURLToPath(new URL('../../../skills', import.meta.url));
|
|
17
|
+
/** 모든 스킬에 끼워 넣는 공통 규칙 */
|
|
18
|
+
const SHARED_DIR = '_shared';
|
|
19
|
+
const PACKAGE_VERSION = JSON.parse(readFileSync(fileURLToPath(new URL('../../../package.json', import.meta.url)), 'utf8')).version;
|
|
20
|
+
/** 설치한 스킬 맨 끝 줄. 버전 · 내용 지문으로 오래됨 · 손으로 고침을 알아본다 */
|
|
21
|
+
const STAMP = /<!-- ecdk-skill: (\S+) (\S+) (sha256-[A-Za-z0-9+/=]+) -->\s*$/;
|
|
22
|
+
const sha = text => `sha256-${createHash('sha256').update(text).digest('base64')}`;
|
|
23
|
+
const SEMVER = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/;
|
|
24
|
+
/**
|
|
25
|
+
* semver 순서로 a가 b보다 앞이면 음수, 뒤면 양수, 같으면 0. 읽을 수 없는 버전은 undefined.
|
|
26
|
+
* 정식 버전은 같은 숫자의 pre-release보다 뒤 (1.0.0-alpha.1 < 1.0.0)
|
|
27
|
+
*/
|
|
28
|
+
function compareVersions(a, b) {
|
|
29
|
+
const pa = SEMVER.exec(a);
|
|
30
|
+
const pb = SEMVER.exec(b);
|
|
31
|
+
if (!pa || !pb) return undefined;
|
|
32
|
+
for (let i = 1; i <= 3; i++) {
|
|
33
|
+
const d = Number(pa[i]) - Number(pb[i]);
|
|
34
|
+
if (d !== 0) return d;
|
|
35
|
+
}
|
|
36
|
+
if (pa[4] === pb[4]) return 0;
|
|
37
|
+
if (pa[4] === undefined) return 1;
|
|
38
|
+
if (pb[4] === undefined) return -1;
|
|
39
|
+
const xa = pa[4].split('.');
|
|
40
|
+
const xb = pb[4].split('.');
|
|
41
|
+
for (let i = 0; i < Math.min(xa.length, xb.length); i++) {
|
|
42
|
+
const [x = '', y = ''] = [xa[i], xb[i]];
|
|
43
|
+
if (x === y) continue;
|
|
44
|
+
const nx = /^\d+$/.test(x);
|
|
45
|
+
const ny = /^\d+$/.test(y);
|
|
46
|
+
if (nx && ny) return Number(x) - Number(y);
|
|
47
|
+
if (nx !== ny) return nx ? -1 : 1;
|
|
48
|
+
return x < y ? -1 : 1;
|
|
49
|
+
}
|
|
50
|
+
return xa.length - xb.length;
|
|
51
|
+
}
|
|
52
|
+
/** 패키지에 든 스킬 이름 (공통 폴더 제외) */
|
|
53
|
+
function skillNames(root = SKILLS_ROOT) {
|
|
54
|
+
return readdirSync(root, {
|
|
55
|
+
withFileTypes: true
|
|
56
|
+
}).filter(d => d.isDirectory() && d.name !== SHARED_DIR).map(d => d.name).sort();
|
|
57
|
+
}
|
|
58
|
+
/** 원본에 공통 규칙과 버전 줄을 넣는다. 지문은 버전 줄을 뺀 본문으로 */
|
|
59
|
+
function renderSkill(name, root = SKILLS_ROOT, version = PACKAGE_VERSION) {
|
|
60
|
+
const always = readFileSync(join(root, SHARED_DIR, 'always.md'), 'utf8').trim();
|
|
61
|
+
const body = readFileSync(join(root, name, 'SKILL.md'), 'utf8').replace('{{always}}', always).replace(/\n*\{\{version\}\}\s*$/, '').trimEnd();
|
|
62
|
+
return `${body}\n\n<!-- ecdk-skill: ${name} ${version} ${sha(body)} -->\n`;
|
|
63
|
+
}
|
|
64
|
+
/** 설치 위치: --project면 현재 폴더, 아니면 홈 */
|
|
65
|
+
function skillsDir(opts) {
|
|
66
|
+
return opts.project ? join(resolve(opts.cwd ?? '.'), '.claude', 'skills') : join(opts.home ?? homedir(), '.claude', 'skills');
|
|
67
|
+
}
|
|
68
|
+
/** 설치된 스킬의 상태. 지문이 본문과 다르면 손으로 고친 것 */
|
|
69
|
+
function inspectSkill(dir, name, version = PACKAGE_VERSION) {
|
|
70
|
+
const path = join(dir, name, 'SKILL.md');
|
|
71
|
+
if (!existsSync(path)) return {
|
|
72
|
+
name,
|
|
73
|
+
path,
|
|
74
|
+
state: 'missing'
|
|
75
|
+
};
|
|
76
|
+
const text = readFileSync(path, 'utf8');
|
|
77
|
+
const stamp = STAMP.exec(text);
|
|
78
|
+
if (!stamp) return {
|
|
79
|
+
name,
|
|
80
|
+
path,
|
|
81
|
+
state: 'modified'
|
|
82
|
+
};
|
|
83
|
+
const body = text.slice(0, stamp.index).trimEnd();
|
|
84
|
+
if (sha(body) !== stamp[3]) return {
|
|
85
|
+
name,
|
|
86
|
+
path,
|
|
87
|
+
state: 'modified',
|
|
88
|
+
version: stamp[2]
|
|
89
|
+
};
|
|
90
|
+
const installed = stamp[2] ?? '';
|
|
91
|
+
// 홈 스킬은 모든 프로젝트가 같이 쓰므로, 더 새 CLI가 설치한 스킬을 옛 CLI가 내리지 않는다
|
|
92
|
+
const order = installed === version ? 0 : compareVersions(installed, version);
|
|
93
|
+
const state = order === 0 ? 'current' : order !== undefined && order > 0 ? 'newer' : 'outdated';
|
|
94
|
+
return {
|
|
95
|
+
name,
|
|
96
|
+
path,
|
|
97
|
+
state,
|
|
98
|
+
version: installed
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
async function install(opts) {
|
|
102
|
+
const root = opts.root ?? SKILLS_ROOT;
|
|
103
|
+
const version = opts.version ?? PACKAGE_VERSION;
|
|
104
|
+
const dir = skillsDir(opts);
|
|
105
|
+
const skills = [];
|
|
106
|
+
for (const name of skillNames(root)) {
|
|
107
|
+
const status = inspectSkill(dir, name, version);
|
|
108
|
+
const write = async () => {
|
|
109
|
+
await mkdir(join(dir, name), {
|
|
110
|
+
recursive: true
|
|
111
|
+
});
|
|
112
|
+
await writeFile(status.path, renderSkill(name, root, version));
|
|
113
|
+
};
|
|
114
|
+
if (status.state === 'missing') {
|
|
115
|
+
await write();
|
|
116
|
+
skills.push({
|
|
117
|
+
...status,
|
|
118
|
+
action: 'installed'
|
|
119
|
+
});
|
|
120
|
+
} else if (status.state === 'current') {
|
|
121
|
+
skills.push({
|
|
122
|
+
...status,
|
|
123
|
+
action: 'skipped'
|
|
124
|
+
});
|
|
125
|
+
} else if (status.state === 'outdated' || opts.force) {
|
|
126
|
+
await write();
|
|
127
|
+
skills.push({
|
|
128
|
+
...status,
|
|
129
|
+
action: 'updated'
|
|
130
|
+
});
|
|
131
|
+
} else if (status.state === 'newer') {
|
|
132
|
+
skills.push({
|
|
133
|
+
...status,
|
|
134
|
+
action: 'newer'
|
|
135
|
+
});
|
|
136
|
+
} else {
|
|
137
|
+
skills.push({
|
|
138
|
+
...status,
|
|
139
|
+
action: 'kept'
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
dir,
|
|
145
|
+
version,
|
|
146
|
+
skills
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
const ACTION = {
|
|
150
|
+
installed: '설치',
|
|
151
|
+
updated: '바꿈',
|
|
152
|
+
skipped: '최신이라 건너뜀',
|
|
153
|
+
kept: '손으로 고친 스킬이라 그대로 둠 (--force로 바꿈)',
|
|
154
|
+
newer: 'CLI보다 새 버전이라 그대로 둠 (--force로 바꿈)'
|
|
155
|
+
};
|
|
156
|
+
async function run(args) {
|
|
157
|
+
if (args.sub !== 'install') return {
|
|
158
|
+
exitCode: 2,
|
|
159
|
+
output: `알 수 없는 하위 명령: ${args.sub ?? '(없음)'}\n\n${usage}`
|
|
160
|
+
};
|
|
161
|
+
const result = await install({
|
|
162
|
+
project: args.project,
|
|
163
|
+
force: args.force
|
|
164
|
+
});
|
|
165
|
+
const kept = result.skills.some(s => s.action === 'kept');
|
|
166
|
+
const output = args.json ? JSON.stringify(result, null, 2) : [`스킬 위치: ${result.dir} (ecdk ${result.version})`, ...result.skills.map(s => ` ${s.name}: ${ACTION[s.action]}`), '', 'Claude Code를 새로 열면 적용됩니다.'].join('\n');
|
|
167
|
+
return {
|
|
168
|
+
exitCode: kept ? 1 : 0,
|
|
169
|
+
output
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export { compareVersions, inspectSkill, install, renderSkill, run, skillNames, skillsDir, usage };
|