@eliceio/cdk-cli 0.1.0-alpha.1 → 0.1.0-alpha.3
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 +171 -136
- package/es/cli.js +119 -26
- package/es/commands/build/index.d.ts +4 -1
- package/es/commands/build/index.js +28 -9
- package/es/commands/check/index.d.ts +8 -2
- package/es/commands/check/index.js +45 -5
- package/es/commands/create/index.d.ts +2 -0
- package/es/commands/create/index.js +28 -3
- package/es/commands/create/scaffold.d.ts +2 -0
- package/es/commands/create/scaffold.js +10 -6
- package/es/commands/dev/index.d.ts +1 -1
- package/es/commands/dev/index.js +6 -2
- package/es/commands/doctor/index.d.ts +12 -0
- package/es/commands/doctor/index.js +217 -7
- package/es/commands/guide/index.d.ts +29 -0
- package/es/commands/guide/index.js +120 -0
- package/es/commands/mcp/index.d.ts +134 -0
- package/es/commands/mcp/index.js +399 -0
- package/es/commands/setup/index.d.ts +40 -0
- package/es/commands/setup/index.js +157 -0
- package/es/commands/skill/index.d.ts +45 -0
- package/es/commands/skill/index.js +145 -0
- package/es/core/config.d.ts +63 -19
- package/es/core/config.js +108 -32
- package/es/core/prepare.js +3 -5
- package/es/core/project-check.d.ts +15 -0
- package/es/core/project-check.js +26 -0
- package/es/core/sandbox.d.ts +17 -0
- package/es/core/sandbox.js +182 -0
- package/es/core/templates.d.ts +25 -0
- package/es/core/templates.js +41 -0
- package/es/dev/grading.d.ts +14 -7
- package/es/dev/grading.js +27 -13
- package/es/dev/host-page.d.ts +1 -1
- package/es/dev/host-page.js +33 -33
- package/es/dev/mock-api.d.ts +20 -4
- package/es/dev/mock-api.js +70 -9
- package/es/dev/server.d.ts +9 -1
- package/es/dev/server.js +101 -25
- package/es/rules/check.js +126 -4
- package/es/rules/index.d.ts +1 -1
- package/es/rules/index.js +1 -1
- package/es/rules/manifest.d.ts +23 -9
- package/es/rules/manifest.js +60 -35
- package/es/rules/node.js +3 -1
- package/es/rules/semver.d.ts +5 -0
- package/es/rules/semver.js +32 -0
- package/es/rules/types.d.ts +29 -6
- package/es/rules.json.js +1 -1
- package/es/version.d.ts +2 -1
- package/es/version.js +5 -1
- package/guides/content-development.md +294 -0
- package/package.json +4 -2
- package/rules.json +113 -5
- package/skills/_shared/always.md +9 -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/skills/elice-content-publish/SKILL.md +22 -0
- package/templates/_shared/lib/cdk-mock.d.ts +21 -3
- package/templates/_shared/lib/cdk-mock.js +239 -80
- package/templates/_shared/lib/cdk.js +2 -2
- package/templates/_shared/lib/elice-content.css +206 -0
- package/templates/_shared/lib/elice-content.d.ts +112 -5
- package/templates/_shared/lib/elice-content.js +660 -62
- package/templates/blank/README.md +14 -5
- package/templates/blank/commentary.txt +2 -0
- package/templates/blank/completion.html +15 -0
- package/templates/blank/elice.config.json +3 -5
- package/templates/blank/gitignore +1 -0
- package/templates/blank/screens/completion.js +7 -0
- package/templates/blank/screens/edit.js +3 -0
- package/templates/blank/template.json +6 -0
- package/templates/quiz/README.md +37 -30
- package/templates/quiz/commentary.txt +2 -0
- package/templates/quiz/content.json +17 -63
- package/templates/quiz/core/behaviors.d.ts +8 -3
- package/templates/quiz/core/behaviors.js +15 -2
- package/templates/quiz/core/model.d.ts +27 -1
- package/templates/quiz/core/model.js +199 -4
- package/templates/quiz/elice.config.json +1 -6
- package/templates/quiz/gitignore +1 -0
- package/templates/quiz/grading.json +1 -10
- package/templates/quiz/screens/edit.js +106 -32
- package/templates/quiz/screens/learn.js +13 -9
- package/templates/quiz/styles.css +84 -24
- package/templates/quiz/template.json +6 -0
- package/templates/quiz/ui/templates/edit.d.ts +2 -1
- package/templates/quiz/ui/templates/edit.js +16 -13
- package/templates/quiz/ui/templates/group.js +29 -8
- package/templates/quiz/ui/templates/question.js +3 -3
- package/templates/quiz/ui/texts.js +53 -29
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { access, readFile, appendFile } from 'node:fs/promises';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { resolve, join, dirname } from 'node:path';
|
|
4
|
+
import { loadConfig, CONFIG_FILE, loadGradingFile, legacyGradingTypesWarning, loadGrading, GRADING_DATA_FILE } from '../../core/config.js';
|
|
4
5
|
import { prepareContent } from '../../core/prepare.js';
|
|
6
|
+
import { projectCheckOptions } from '../../core/project-check.js';
|
|
7
|
+
import { parseTemplateRef, listTemplates } from '../../core/templates.js';
|
|
5
8
|
import { checkFiles } from '../../rules/check.js';
|
|
6
9
|
import { lineSkipper } from '../../rules/skip.js';
|
|
7
10
|
import { RULES_VERSION } from '../../rules/spec.js';
|
|
8
11
|
import 'fflate';
|
|
9
12
|
import { VERSION } from '../../version.js';
|
|
13
|
+
import { defaultMcpEnv, detectTargets, claudeRegistration, helpyRegisteredUrl, envOfUrl, MCP_NAME } from '../mcp/index.js';
|
|
14
|
+
import { skillsDir, skillNames, inspectSkill } from '../skill/index.js';
|
|
15
|
+
import { compareVersions } from '../../rules/semver.js';
|
|
10
16
|
|
|
11
17
|
const usage = `사용법: ecdk doctor [프로젝트 폴더] [--fix] [--json]
|
|
12
18
|
|
|
@@ -83,6 +89,203 @@ async function checkGitignore(dir, config) {
|
|
|
83
89
|
}
|
|
84
90
|
};
|
|
85
91
|
}
|
|
92
|
+
/** Claude Code 스킬: 프로젝트(.claude/skills) 또는 홈(~/.claude/skills)에 모두 있고 CLI와 같은 버전인지 */
|
|
93
|
+
function checkSkills(dir, home) {
|
|
94
|
+
const fix = {
|
|
95
|
+
description: '스킬 설치 · 갱신 (MCP 등록까지 한 번에)',
|
|
96
|
+
command: 'ecdk setup',
|
|
97
|
+
auto: false
|
|
98
|
+
};
|
|
99
|
+
// 프로젝트 폴더부터 위로(홈 · 루트까지) .claude/skills를 찾고, 없으면 홈(~/.claude/skills).
|
|
100
|
+
// Claude Code는 세션을 연 폴더의 .claude/skills를 읽으므로 ecdk create로 만든 하위 폴더에서도 상위 설치를 인정한다
|
|
101
|
+
const user = skillsDir({
|
|
102
|
+
project: false,
|
|
103
|
+
home
|
|
104
|
+
});
|
|
105
|
+
const dirs = [...projectSkillDirs(dir, home), user];
|
|
106
|
+
const where = new Set();
|
|
107
|
+
const statuses = skillNames().map(name => {
|
|
108
|
+
for (const d of dirs) {
|
|
109
|
+
const s = inspectSkill(d, name);
|
|
110
|
+
if (s.state !== 'missing') {
|
|
111
|
+
where.add(d);
|
|
112
|
+
return s;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return inspectSkill(user, name);
|
|
116
|
+
});
|
|
117
|
+
const missing = statuses.filter(s => s.state === 'missing').map(s => s.name);
|
|
118
|
+
const outdated = statuses.filter(s => s.state === 'outdated').map(s => s.name);
|
|
119
|
+
if (missing.length > 0) return {
|
|
120
|
+
id: 'skill.installed',
|
|
121
|
+
level: 'warn',
|
|
122
|
+
message: `Claude Code 스킬 없음: ${missing.join(', ')}`,
|
|
123
|
+
fix
|
|
124
|
+
};
|
|
125
|
+
if (outdated.length > 0) return {
|
|
126
|
+
id: 'skill.installed',
|
|
127
|
+
level: 'warn',
|
|
128
|
+
message: `Claude Code 스킬이 CLI보다 오래됨: ${outdated.join(', ')}`,
|
|
129
|
+
fix
|
|
130
|
+
};
|
|
131
|
+
const newer = statuses.filter(s => s.state === 'newer').map(s => `${s.name}(${s.version})`);
|
|
132
|
+
return {
|
|
133
|
+
id: 'skill.installed',
|
|
134
|
+
level: 'ok',
|
|
135
|
+
message: newer.length > 0 ? `Claude Code 스킬 ${statuses.length}개 (${[...where].join(', ')}) · CLI(${VERSION})보다 새 버전: ${newer.join(', ')}` : `Claude Code 스킬 ${statuses.length}개 (${[...where].join(', ')})`
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/** 프로젝트를 만든 템플릿 · 버전 (elice.config.json template). 이 CLI에 더 새 버전이 있으면 알리기만 한다 (자동 갱신 없음) */
|
|
139
|
+
function checkTemplate(config) {
|
|
140
|
+
const id = 'project.template';
|
|
141
|
+
if (!config.template) return {
|
|
142
|
+
id,
|
|
143
|
+
level: 'skip',
|
|
144
|
+
message: '템플릿 정보 없음 (ecdk create 없이 만들었거나 옛 프로젝트)'
|
|
145
|
+
};
|
|
146
|
+
const {
|
|
147
|
+
name,
|
|
148
|
+
version
|
|
149
|
+
} = parseTemplateRef(config.template);
|
|
150
|
+
const shipped = listTemplates().find(t => t.name === name);
|
|
151
|
+
if (!shipped) return {
|
|
152
|
+
id,
|
|
153
|
+
level: 'ok',
|
|
154
|
+
message: `${config.template} (이 ecdk에는 없는 템플릿)`
|
|
155
|
+
};
|
|
156
|
+
const newer = version !== undefined && (compareVersions(shipped.version, version) ?? 0) > 0;
|
|
157
|
+
return {
|
|
158
|
+
id,
|
|
159
|
+
level: 'ok',
|
|
160
|
+
message: newer ? `${config.template} · 이 ecdk에는 ${name}@${shipped.version}이 있습니다 (자동으로 바꾸지 않음. 바뀐 점은 ecdk create --list와 템플릿 README)` : config.template
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/** dir부터 위로 올라가며 <폴더>/.claude/skills 목록. 홈 폴더나 파일 시스템 루트에서 멈춘다 (홈은 사용자 위치라 따로) */
|
|
164
|
+
function projectSkillDirs(dir, home = homedir()) {
|
|
165
|
+
const out = [];
|
|
166
|
+
const stop = resolve(home);
|
|
167
|
+
let cur = resolve(dir);
|
|
168
|
+
for (;;) {
|
|
169
|
+
if (cur === stop) break;
|
|
170
|
+
out.push(skillsDir({
|
|
171
|
+
project: true,
|
|
172
|
+
cwd: cur
|
|
173
|
+
}));
|
|
174
|
+
const parent = dirname(cur);
|
|
175
|
+
if (parent === cur) break;
|
|
176
|
+
cur = parent;
|
|
177
|
+
}
|
|
178
|
+
return out;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* grading.json: 편집 화면이 만드는 settings.grading 모양({ type: pattern | rubric }, 2026-11-11)인지. 옛 elice.config.json
|
|
182
|
+
* gradingTypes는 경고. 로컬 완료 정책은 .ecdk/completion.json(ecdk dev 완료 정책 화면, completionPolicies 안일 때) · 첫 값.
|
|
183
|
+
* 채점해 완료(on_graded)인데 grading.json이 없으면 ecdk dev 학생 보기가 답을 비교할 수 없다 (내용 편집에서 답을 저장하면 생김)
|
|
184
|
+
*/
|
|
185
|
+
async function checkGrading(dir, config) {
|
|
186
|
+
const id = 'project.grading';
|
|
187
|
+
if (config.kind === 'description') return {
|
|
188
|
+
id,
|
|
189
|
+
level: 'skip',
|
|
190
|
+
message: '채점 없음 (문제 설명)'
|
|
191
|
+
};
|
|
192
|
+
const legacy = legacyGradingTypesWarning(config);
|
|
193
|
+
try {
|
|
194
|
+
const grading = await loadGrading(dir, config);
|
|
195
|
+
if (legacy) return {
|
|
196
|
+
id,
|
|
197
|
+
level: 'warn',
|
|
198
|
+
message: legacy,
|
|
199
|
+
fix: {
|
|
200
|
+
description: `${CONFIG_FILE}에서 gradingTypes 지우기`,
|
|
201
|
+
auto: false
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
const graded = grading?.completion_policy === 'on_graded';
|
|
205
|
+
if (graded && !grading?.grading) return {
|
|
206
|
+
id,
|
|
207
|
+
level: 'warn',
|
|
208
|
+
message: `채점해 완료(on_graded)하는데 ${GRADING_DATA_FILE}이 없어 ecdk dev 학생 보기가 채점할 수 없습니다 (답이 없음)`,
|
|
209
|
+
fix: {
|
|
210
|
+
description: `ecdk dev의 '내용 편집'에서 채점 방식 · 답을 저장 (${GRADING_DATA_FILE}에 씀, zip에는 들어가지 않음)`,
|
|
211
|
+
auto: false
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
const policy = grading?.completion_policy ?? '-';
|
|
215
|
+
return {
|
|
216
|
+
id,
|
|
217
|
+
level: 'ok',
|
|
218
|
+
message: `로컬 완료 정책 ${policy}${grading?.grading ? ` · ${GRADING_DATA_FILE} ${grading.grading.type}` : ''}`
|
|
219
|
+
};
|
|
220
|
+
} catch (e) {
|
|
221
|
+
return {
|
|
222
|
+
id,
|
|
223
|
+
level: 'fail',
|
|
224
|
+
message: e.message,
|
|
225
|
+
fix: {
|
|
226
|
+
description: `${GRADING_DATA_FILE} 형식을 고치기 (ecdk guide 2)`,
|
|
227
|
+
auto: false
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/** 학습자료 서버 MCP(elice-material)가 찾은 도구 중 하나에라도 등록돼 있는지 (읽기만) */
|
|
233
|
+
function checkMcp(env) {
|
|
234
|
+
const id = 'mcp.material';
|
|
235
|
+
const fix = {
|
|
236
|
+
description: 'MCP 등록 (자료를 LXP에 올릴 때 필요)',
|
|
237
|
+
command: 'ecdk setup',
|
|
238
|
+
auto: false
|
|
239
|
+
};
|
|
240
|
+
const targets = detectTargets(env);
|
|
241
|
+
if (targets.length === 0) return {
|
|
242
|
+
id,
|
|
243
|
+
level: 'skip',
|
|
244
|
+
message: 'Claude Code · Helpy Code를 찾지 못함'
|
|
245
|
+
};
|
|
246
|
+
const found = [];
|
|
247
|
+
const notes = [];
|
|
248
|
+
const envs = new Set();
|
|
249
|
+
for (const t of targets) {
|
|
250
|
+
let url;
|
|
251
|
+
if (t === 'claude') {
|
|
252
|
+
const reg = claudeRegistration(env);
|
|
253
|
+
if (reg.state === 'unknown') {
|
|
254
|
+
notes.push(`Claude Code 확인 못 함 (${reg.reason})`);
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
if (reg.state === 'other-scope') {
|
|
258
|
+
notes.push(`Claude Code는 ${reg.scope} 범위에만 있음 (이 폴더 전용, 다른 폴더에서는 없음)`);
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
url = reg.state === 'user' ? reg.url : null;
|
|
262
|
+
} else url = helpyRegisteredUrl(env);
|
|
263
|
+
if (!url) continue;
|
|
264
|
+
const name = envOfUrl(url);
|
|
265
|
+
envs.add(name);
|
|
266
|
+
found.push(`${t === 'claude' ? 'Claude Code' : 'Helpy Code'}(${name})`);
|
|
267
|
+
}
|
|
268
|
+
const extra = notes.length > 0 ? ` · ${notes.join(' · ')}` : '';
|
|
269
|
+
const notProd = [...envs].filter(e => e !== 'prod');
|
|
270
|
+
const note = notProd.length > 0 ? ` — ${notProd.map(e => e === 'custom' ? '직접 지정한 서버' : `QA 환경(${e})`).join(' · ')}에 연결됨, 운영 자료를 올리지 마세요` : '';
|
|
271
|
+
if (found.length > 0) return {
|
|
272
|
+
id,
|
|
273
|
+
level: 'ok',
|
|
274
|
+
message: `${MCP_NAME} 등록: ${found.join(', ')}${note}${extra}`
|
|
275
|
+
};
|
|
276
|
+
// 확인만 못 한 경우는 경고하지 않는다 (등록돼 있는데 느린 것일 수 있음)
|
|
277
|
+
if (notes.length > 0 && notes.every(n => n.includes('확인 못 함'))) return {
|
|
278
|
+
id,
|
|
279
|
+
level: 'skip',
|
|
280
|
+
message: `${MCP_NAME} 등록 ${notes.join(' · ')}`
|
|
281
|
+
};
|
|
282
|
+
return {
|
|
283
|
+
id,
|
|
284
|
+
level: 'warn',
|
|
285
|
+
message: `${MCP_NAME} MCP가 사용자 범위에 등록돼 있지 않습니다${extra}`,
|
|
286
|
+
fix
|
|
287
|
+
};
|
|
288
|
+
}
|
|
86
289
|
async function doctor(target, opts) {
|
|
87
290
|
const dir = resolve(target);
|
|
88
291
|
const checks = [checkNode(opts.nodeVersion ?? process.version), await checkPackageManager(dir)];
|
|
@@ -101,6 +304,7 @@ async function doctor(target, opts) {
|
|
|
101
304
|
message: `${CONFIG_FILE}을 읽을 수 없습니다: ${e.message}`
|
|
102
305
|
});
|
|
103
306
|
}
|
|
307
|
+
if (config) checks.push(checkTemplate(config), await checkGrading(dir, config));
|
|
104
308
|
if (config) {
|
|
105
309
|
const srcDir = resolve(dir, config.root);
|
|
106
310
|
if (!(await exists(srcDir))) {
|
|
@@ -147,9 +351,11 @@ async function doctor(target, opts) {
|
|
|
147
351
|
level: 'ok',
|
|
148
352
|
message: '콘텐츠가 정답·설정 파일을 참조하지 않음'
|
|
149
353
|
});
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
354
|
+
// grading.json 형식 오류는 project.grading이 알리므로 여기서는 없는 것으로 본다
|
|
355
|
+
const grading = config.kind === 'description' ? undefined : await loadGradingFile(dir).catch(() => undefined);
|
|
356
|
+
const result = checkFiles(files, projectCheckOptions(config, {
|
|
357
|
+
grading
|
|
358
|
+
}));
|
|
153
359
|
const errors = result.issues.filter(i => i.level === 'error');
|
|
154
360
|
const warns = result.issues.length - errors.length;
|
|
155
361
|
checks.push(errors.length > 0 ? {
|
|
@@ -176,6 +382,9 @@ async function doctor(target, opts) {
|
|
|
176
382
|
}
|
|
177
383
|
if (await exists(join(dir, 'package.json'))) checks.push(await checkGitignore(dir, config));
|
|
178
384
|
}
|
|
385
|
+
checks.push(checkSkills(dir, opts.home));
|
|
386
|
+
// MCP는 도구 설정을 읽으므로 실행 환경을 받았을 때만 (run은 실제 환경, 테스트는 가짜 환경)
|
|
387
|
+
if (opts.mcp) checks.push(checkMcp(opts.mcp));
|
|
179
388
|
// 서버 API(D8)가 정해지면 규칙·프로토콜 버전을 서버와 비교
|
|
180
389
|
checks.push({
|
|
181
390
|
id: 'compat.server',
|
|
@@ -213,7 +422,8 @@ function formatText(r) {
|
|
|
213
422
|
}
|
|
214
423
|
async function run(args) {
|
|
215
424
|
const result = await doctor(args.target, {
|
|
216
|
-
fix: args.fix
|
|
425
|
+
fix: args.fix,
|
|
426
|
+
mcp: defaultMcpEnv()
|
|
217
427
|
});
|
|
218
428
|
return {
|
|
219
429
|
exitCode: result.ok ? 0 : 1,
|
|
@@ -227,4 +437,4 @@ function referencesAnswerFile(text) {
|
|
|
227
437
|
return skip.lines.some((line, i) => ANSWER_FILE.test(line) && !skip.isSkipped(i + 1, 'project.answer-import'));
|
|
228
438
|
}
|
|
229
439
|
|
|
230
|
-
export { checkNode, doctor, formatText, referencesAnswerFile, run, usage };
|
|
440
|
+
export { checkMcp, checkNode, checkSkills, checkTemplate, doctor, formatText, projectSkillDirs, 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,134 @@
|
|
|
1
|
+
import type { CommandResult } from '../../types.js';
|
|
2
|
+
export declare const usage = "\uC0AC\uC6A9\uBC95: ecdk mcp setup [--target claude|helpycode|all] [--env prod|qa5] [--url <\uC8FC\uC18C>] [--dry-run] [--force] [--json]\n\n Elice \uD559\uC2B5\uC790\uB8CC \uC11C\uBC84 MCP(elice-material)\uB97C AI \uB3C4\uAD6C\uC5D0 \uB4F1\uB85D\uD55C\uB2E4. \uB098\uC911\uC5D0 \uC790\uB8CC\uB97C LXP\uC5D0 \uC62C\uB9AC\uB294 \uC2A4\uD0AC\uC774 \uC4F4\uB2E4.\n --target claude(Claude Code) \u00B7 helpycode(Helpy Code \uB370\uC2A4\uD06C\uD1B1 \u00B7 CLI) \u00B7 all(\uCC3E\uC740 \uB3C4\uAD6C \uBAA8\uB450, \uAE30\uBCF8)\n --env \uC11C\uBC84 \uD658\uACBD prod(\uC6B4\uC601, \uAE30\uBCF8) \u00B7 qa5. \uD658\uACBD \uBCC0\uC218 ECDK_ENV\uB85C\uB3C4 \uC815\uD560 \uC218 \uC788\uB2E4 (\uC635\uC158\uC774 \uBA3C\uC800)\n --url \uADF8 \uBC16\uC758 \uC11C\uBC84 MCP \uC8FC\uC18C (https, --env\uBCF4\uB2E4 \uBA3C\uC800)\n --dry-run \uBB34\uC5C7\uC744 \uBC14\uAFC0\uC9C0 \uBCF4\uC5EC \uC8FC\uAE30\uB9CC \uD55C\uB2E4 (\uC11C\uBC84 \uD655\uC778\uB3C4 \uD558\uC9C0 \uC54A\uC74C)\n --force \uC774\uBBF8 \uB2E4\uB978 \uC8FC\uC18C\uB85C \uB4F1\uB85D\uB3FC \uC788\uAC70\uB098 \uC11C\uBC84\uC5D0 MCP\uAC00 \uC5C6\uC5B4 \uBCF4\uC5EC\uB3C4 \uB4F1\uB85D\uD55C\uB2E4\n \uB4F1\uB85D \uC804\uC5D0 \uC11C\uBC84\uC5D0 MCP\uAC00 \uC788\uB294\uC9C0 \uD655\uC778\uD558\uACE0, \uB85C\uADF8\uC778\uC740 \uB4F1\uB85D \uB4A4 \uAC01 \uB3C4\uAD6C\uC5D0\uC11C \uD55C\uB2E4 (\uC548\uB0B4\uB97C \uCD9C\uB825\uD568).\n\n\uC885\uB8CC \uCF54\uB4DC: 0 \uC131\uACF5 \u00B7 1 \uC9C1\uC811 \uD560 \uC77C\uC774 \uC788\uC74C(\uC11C\uBC84\uC5D0 MCP \uC5C6\uC74C, \uC8FC\uC11D\uC774 \uC788\uB294 \uC124\uC815 \uD30C\uC77C, \uB2E4\uB978 \uC8FC\uC18C\uB85C \uB4F1\uB85D\uB428) \u00B7 2 \uC798\uBABB\uB41C \uC0AC\uC6A9";
|
|
3
|
+
export declare const MCP_NAME = "elice-material";
|
|
4
|
+
/**
|
|
5
|
+
* 서버 환경 → MCP 주소. 표는 여기 하나만 둔다.
|
|
6
|
+
* prod는 material API 주소(api-material.elice.io)에 /mcp를 붙인 **가정**이다: 2026-11-10 운영에는 아직 MCP가 없고
|
|
7
|
+
* (GET 405), 백엔드가 주소를 확정해 주기로 함 (백엔드 요청 B1). 그래서 등록 전에 probe로 확인한다.
|
|
8
|
+
*/
|
|
9
|
+
export declare const MCP_ENVS: Record<string, string>;
|
|
10
|
+
export declare const DEFAULT_ENV = "prod";
|
|
11
|
+
export type McpTarget = 'claude' | 'helpycode';
|
|
12
|
+
/** 바깥 세계(HOME · PATH · 명령 실행)를 바꿔 끼울 수 있게 (테스트는 실제 설정을 건드리지 않음) */
|
|
13
|
+
export interface McpEnv {
|
|
14
|
+
home: string;
|
|
15
|
+
platform: NodeJS.Platform;
|
|
16
|
+
/** PATH에서 명령을 찾는다 (없으면 null) */
|
|
17
|
+
which(command: string): string | null;
|
|
18
|
+
/** 명령 실행 (시간 제한 ms) */
|
|
19
|
+
/** timedOut: 시간 초과 · 실행 실패 (결과를 알 수 없음) */
|
|
20
|
+
exec(command: string, args: string[], timeoutMs: number): {
|
|
21
|
+
code: number;
|
|
22
|
+
stdout: string;
|
|
23
|
+
timedOut?: boolean;
|
|
24
|
+
};
|
|
25
|
+
exists(path: string): boolean;
|
|
26
|
+
/** 이 주소에 MCP 서버가 있는지 (로그인을 요구하는 401 + OAuth 안내면 ok) */
|
|
27
|
+
probe(url: string): Promise<{
|
|
28
|
+
ok: boolean;
|
|
29
|
+
detail: string;
|
|
30
|
+
}>;
|
|
31
|
+
/** 환경 변수 ECDK_ENV */
|
|
32
|
+
envVar?: string | undefined;
|
|
33
|
+
}
|
|
34
|
+
/** MCP initialize를 POST해 본다. 로그인 전이면 401과 www-authenticate(resource_metadata)가 와야 한다 */
|
|
35
|
+
export declare function probeMcp(url: string): Promise<{
|
|
36
|
+
ok: boolean;
|
|
37
|
+
detail: string;
|
|
38
|
+
}>;
|
|
39
|
+
export declare function defaultMcpEnv(): McpEnv;
|
|
40
|
+
export declare const helpyConfigPath: (env: McpEnv) => string;
|
|
41
|
+
export declare function detectTargets(env: McpEnv): McpTarget[];
|
|
42
|
+
/** 주소로 환경 이름 (표에 없으면 custom) */
|
|
43
|
+
export declare const envOfUrl: (url: string) => string;
|
|
44
|
+
export type ClaudeRegistration = {
|
|
45
|
+
state: 'user';
|
|
46
|
+
url: string;
|
|
47
|
+
} | {
|
|
48
|
+
state: 'other-scope';
|
|
49
|
+
url: string;
|
|
50
|
+
scope: string;
|
|
51
|
+
} | {
|
|
52
|
+
state: 'none';
|
|
53
|
+
} | {
|
|
54
|
+
state: 'unknown';
|
|
55
|
+
reason: string;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Claude Code 등록 상태. `claude mcp get`은 서버 연결 상태까지 확인해 느릴 수 있으므로
|
|
59
|
+
* 시간 초과 · 실행 실패는 "없음"이 아니라 "확인 못 함"으로 본다.
|
|
60
|
+
* 범위(Scope) 줄이 User가 아니면 이 폴더 전용(local · project) 등록이라 다른 폴더에서는 없다.
|
|
61
|
+
* Scope 줄이 없으면(옛 Claude CLI) 사용자 범위로 본다.
|
|
62
|
+
*/
|
|
63
|
+
export declare function claudeRegistration(env: McpEnv): ClaudeRegistration;
|
|
64
|
+
/** Claude Code 사용자 범위에 등록된 주소 (없거나 확인 못 하면 null) */
|
|
65
|
+
export declare function claudeRegisteredUrl(env: McpEnv): string | null;
|
|
66
|
+
type HelpyConfig = {
|
|
67
|
+
kind: 'missing';
|
|
68
|
+
} | {
|
|
69
|
+
kind: 'json';
|
|
70
|
+
data: Record<string, unknown>;
|
|
71
|
+
text: string;
|
|
72
|
+
} | {
|
|
73
|
+
kind: 'jsonc';
|
|
74
|
+
text: string;
|
|
75
|
+
};
|
|
76
|
+
/** 주석 · 끝 쉼표가 있으면 다시 쓰지 않는다 (지우면 사람이 적은 설명이 사라짐) */
|
|
77
|
+
export declare function readHelpyConfig(path: string): HelpyConfig;
|
|
78
|
+
/** Helpy Code 설정에 등록된 주소 (없으면 null, 읽을 수 없으면 undefined) */
|
|
79
|
+
export declare function helpyRegisteredUrl(env: McpEnv): string | null | undefined;
|
|
80
|
+
export type SetupAction = 'added' | 'replaced' | 'skipped' | 'would-add' | 'would-replace' | 'conflict' | 'manual' | 'unreachable' | 'failed';
|
|
81
|
+
export interface SetupStep {
|
|
82
|
+
target: McpTarget;
|
|
83
|
+
action: SetupAction;
|
|
84
|
+
message: string;
|
|
85
|
+
/** 사람이 붙여 넣을 내용 (주석이 있는 설정 파일일 때) */
|
|
86
|
+
paste?: string | undefined;
|
|
87
|
+
}
|
|
88
|
+
export interface SetupResult {
|
|
89
|
+
env: string;
|
|
90
|
+
probe: {
|
|
91
|
+
ok: boolean;
|
|
92
|
+
detail: string;
|
|
93
|
+
} | 'skipped';
|
|
94
|
+
url: string;
|
|
95
|
+
targets: McpTarget[];
|
|
96
|
+
steps: SetupStep[];
|
|
97
|
+
login: string[];
|
|
98
|
+
}
|
|
99
|
+
export declare function setup(opts: {
|
|
100
|
+
env: McpEnv;
|
|
101
|
+
envName: string;
|
|
102
|
+
url: string;
|
|
103
|
+
target: 'claude' | 'helpycode' | 'all';
|
|
104
|
+
dryRun: boolean;
|
|
105
|
+
force: boolean;
|
|
106
|
+
}): Promise<SetupResult>;
|
|
107
|
+
export declare const NEEDS_PERSON: SetupAction[];
|
|
108
|
+
export type ResolvedUrl = {
|
|
109
|
+
ok: true;
|
|
110
|
+
envName: string;
|
|
111
|
+
source: string;
|
|
112
|
+
url: string;
|
|
113
|
+
} | {
|
|
114
|
+
ok: false;
|
|
115
|
+
error: string;
|
|
116
|
+
};
|
|
117
|
+
/** 주소: --url > --env > ECDK_ENV > prod */
|
|
118
|
+
export declare function resolveUrl(args: {
|
|
119
|
+
envName: string | undefined;
|
|
120
|
+
url: string | undefined;
|
|
121
|
+
}, env: McpEnv): ResolvedUrl;
|
|
122
|
+
/** 사람용 출력의 MCP 부분 (환경 · 서버 확인 · 도구별 결과) */
|
|
123
|
+
export declare function formatSetupLines(result: SetupResult, source: string, dryRun: boolean): string[];
|
|
124
|
+
export declare function run(args: {
|
|
125
|
+
sub: string | undefined;
|
|
126
|
+
target: string | undefined;
|
|
127
|
+
envName: string | undefined;
|
|
128
|
+
url: string | undefined;
|
|
129
|
+
dryRun: boolean;
|
|
130
|
+
force: boolean;
|
|
131
|
+
json: boolean;
|
|
132
|
+
env?: McpEnv | undefined;
|
|
133
|
+
}): Promise<CommandResult>;
|
|
134
|
+
export {};
|