@eliceio/cdk-cli 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/README.md +54 -27
  2. package/es/cli.js +35 -2
  3. package/es/commands/create/index.js +1 -1
  4. package/es/commands/dev/index.d.ts +8 -3
  5. package/es/commands/dev/index.js +72 -3
  6. package/es/commands/doctor/index.d.ts +1 -1
  7. package/es/commands/doctor/index.js +10 -13
  8. package/es/commands/setup/index.d.ts +1 -1
  9. package/es/commands/setup/index.js +4 -3
  10. package/es/commands/uninstall/index.d.ts +1 -1
  11. package/es/commands/uninstall/index.js +7 -30
  12. package/es/core/config.d.ts +2 -2
  13. package/es/core/config.js +2 -2
  14. package/es/core/skills.d.ts +22 -4
  15. package/es/core/skills.js +89 -17
  16. package/es/dev/browser.d.ts +22 -0
  17. package/es/dev/browser.js +105 -0
  18. package/es/dev/check.d.ts +84 -0
  19. package/es/dev/check.js +326 -0
  20. package/es/dev/host-page.js +10 -0
  21. package/es/dev/mock-api.js +1 -1
  22. package/es/dev/server.d.ts +2 -0
  23. package/es/dev/server.js +1 -0
  24. package/es/rules/check.js +1 -1
  25. package/es/rules/manifest.d.ts +1 -1
  26. package/es/rules/manifest.js +2 -2
  27. package/es/test-old-skill.d.ts +5 -0
  28. package/package.json +3 -2
  29. package/skills/_shared/always.md +13 -5
  30. package/skills/{elice-content-guide/topics → _shared/references}/00-what-the-person-decides.md +2 -2
  31. package/skills/{elice-content-guide/topics → _shared/references}/02-design-the-material.md +13 -4
  32. package/skills/{elice-content-guide/topics → _shared/references}/03-create-the-project.md +2 -2
  33. package/skills/_shared/references/05-screen-code.md +169 -0
  34. package/skills/{elice-content-guide/topics → _shared/references}/06-using-the-quiz-template.md +4 -3
  35. package/skills/{elice-content-guide/topics → _shared/references}/07-move-existing-html.md +1 -1
  36. package/skills/_shared/references/08-fix-check-errors.md +28 -0
  37. package/skills/_shared/references/09-check.md +29 -0
  38. package/skills/_shared/references/10-build.md +8 -0
  39. package/skills/_shared/references/12-upload-with-the-material-mcp.md +83 -0
  40. package/skills/elice-content-check/SKILL.md +7 -9
  41. package/skills/elice-content-create/SKILL.md +12 -10
  42. package/skills/elice-content-migrate/SKILL.md +10 -8
  43. package/skills/elice-content-publish/SKILL.md +10 -8
  44. package/templates/_shared/lib/cdk-mock.d.ts +1 -1
  45. package/templates/_shared/lib/cdk-mock.js +2 -2
  46. package/templates/_shared/lib/elice-content.css +1 -1
  47. package/templates/_shared/lib/elice-content.d.ts +1 -1
  48. package/templates/_shared/lib/elice-content.js +33 -16
  49. package/templates/blank/README.md +24 -21
  50. package/templates/blank/screens/edit.js +1 -1
  51. package/templates/blank/template.json +1 -1
  52. package/templates/quiz/README.md +6 -5
  53. package/templates/quiz/metadata.json +1 -1
  54. package/templates/quiz/screens/edit.js +1 -1
  55. package/templates/quiz/screens/learn.js +1 -1
  56. package/templates/quiz/styles.css +3 -33
  57. package/templates/quiz/template.json +2 -2
  58. package/templates/quiz/ui/templates/page.js +2 -17
  59. package/templates/quiz/ui/templates/question.js +1 -1
  60. package/templates/quiz/ui/texts.js +2 -11
  61. package/skills/elice-content-guide/SKILL.md +0 -42
  62. package/skills/elice-content-guide/topics/05-screen-code.md +0 -132
  63. package/skills/elice-content-guide/topics/08-fix-check-errors.md +0 -27
  64. package/skills/elice-content-guide/topics/09-check.md +0 -11
  65. package/skills/elice-content-guide/topics/10-build.md +0 -8
  66. package/skills/elice-content-guide/topics/12-upload-with-the-material-mcp.md +0 -41
  67. package/templates/quiz/instructor.html +0 -17
  68. package/templates/quiz/screens/instructor.js +0 -33
  69. /package/skills/{elice-content-guide/topics → _shared/references}/01-check-the-environment.md +0 -0
  70. /package/skills/{elice-content-guide/topics → _shared/references}/04-rules.md +0 -0
  71. /package/skills/{elice-content-guide/topics → _shared/references}/11-more.md +0 -0
@@ -0,0 +1,326 @@
1
+ import { mkdir } from 'node:fs/promises';
2
+ import { join, relative, sep } from 'node:path';
3
+ import { launchBrowser } from './browser.js';
4
+ import { startDevServer } from './server.js';
5
+
6
+ /** ecdk dev --check가 여는 화면. tutoring은 학생 화면(learn)을 튜터링 보기로 연 것 */
7
+ const CHECK_SCREENS = ['learn', 'tutoring', 'instructor', 'edit'];
8
+ /** 화면 → dev 화면의 보기 (host-page.ts SCENARIOS) */
9
+ const VIEW = {
10
+ learn: 'student',
11
+ tutoring: 'tutor',
12
+ instructor: 'instructor',
13
+ edit: 'edit'
14
+ };
15
+ /** 폭 → dev 화면의 폭 버튼 값 (host-page.ts data-w). 브라우저 창은 늘 1280×860 */
16
+ const CHECK_VIEWPORTS = {
17
+ desktop: '100%',
18
+ mobile: '360px'
19
+ };
20
+ const WINDOW = {
21
+ width: 1280,
22
+ height: 860
23
+ };
24
+ /** 화면 하나를 기다리는 최대 시간. 넘으면 그때 모습으로 기록한다 */
25
+ const SCREEN_WAIT_MS = 8000;
26
+ /** 다 그려진 뒤 늦게 나는 오류 · 글꼴을 조금 더 기다린다 */
27
+ const SETTLE_MS = 400;
28
+ /** 동시에 여는 화면 수 */
29
+ const PARALLEL = 4;
30
+ /** Chrome이 콘텐츠 CSP의 webrtc 지시어를 모른다고 내는 안내 (콘텐츠 문제 아님) */
31
+ const IGNORED_CONSOLE = [/Unrecognized Content-Security-Policy directive 'webrtc'/];
32
+ /** 다른 칸(blocked · failedRequests)에 이미 적는 브라우저 기본 메시지 */
33
+ const DUPLICATE_CONSOLE = [/^Refused to /, /violates the (following|document's) Content Security Policy/, /^Failed to load resource: /];
34
+ /** 기본 화면: metadata.json에서 켠 화면 + 학생 화면이 있으면 튜터링. 문제 설명은 학생 화면만 (dev 화면과 같음) */
35
+ function defaultScreens(entries, kind) {
36
+ if (kind === 'description') return entries.learn ? ['learn'] : [];
37
+ return CHECK_SCREENS.filter(s => s === 'tutoring' ? entries.learn : entries[s]);
38
+ }
39
+ /** "a,b" → 목록. 모르는 값이 있으면 오류 문구 */
40
+ function parseList(value, allowed, label) {
41
+ const values = [...new Set(value.split(',').map(v => v.trim()))].filter(Boolean);
42
+ const unknown = values.filter(v => !allowed.includes(v));
43
+ if (unknown.length || values.length === 0) return {
44
+ error: `${label} 값이 올바르지 않습니다: ${unknown.join(', ') || '(비어 있음)'} (가능: ${allowed.join(', ')})`
45
+ };
46
+ return {
47
+ values: values
48
+ };
49
+ }
50
+ /** 화면 하나의 문제. fail: 오류 · 막힘 · 빈 화면, warn: 불러오는 중이 남음 · 가로 넘침 */
51
+ function findingsOf(r) {
52
+ const out = [];
53
+ if (r.loading) out.push({
54
+ level: 'warn',
55
+ message: `"${r.loading}"이 남아 있음`
56
+ });else if (!r.rendered) out.push({
57
+ level: 'fail',
58
+ message: '화면이 비어 있음 (글 · canvas 없음)'
59
+ });
60
+ if (r.pageErrors.length) out.push({
61
+ level: 'fail',
62
+ message: `예외 ${r.pageErrors.length}개`
63
+ });
64
+ if (r.consoleErrors.length) out.push({
65
+ level: 'fail',
66
+ message: `콘솔 오류 ${r.consoleErrors.length}개`
67
+ });
68
+ if (r.blocked.length) out.push({
69
+ level: 'fail',
70
+ message: `막힌 외부 요청 ${r.blocked.length}개`
71
+ });
72
+ if (r.failedRequests.length) out.push({
73
+ level: 'fail',
74
+ message: `실패한 요청 ${r.failedRequests.length}개`
75
+ });
76
+ if (r.overflowX) out.push({
77
+ level: 'warn',
78
+ message: '가로로 넘침 (가로 스크롤 생김)'
79
+ });
80
+ return out;
81
+ }
82
+ function statusOf(r) {
83
+ const f = findingsOf(r);
84
+ return f.some(x => x.level === 'fail') ? 'fail' : f.length ? 'warn' : 'ok';
85
+ }
86
+ /** 0: 모든 화면 문제 없음 · 검사 오류 없음, 1: 문제 있음 (경고 포함). 브라우저 없음(3) · 사용법(2)은 명령에서 */
87
+ function exitCodeOf(report) {
88
+ return report.validate.errors === 0 && report.screens.every(r => statusOf(r) === 'ok') ? 0 : 1;
89
+ }
90
+ const DETAIL_LIMIT = 3;
91
+ function formatText(report) {
92
+ const lines = [`ecdk dev --check ${report.project} (브라우저: ${report.browser})`];
93
+ const v = report.validate;
94
+ lines.push(`${v.errors ? '[fail]' : '[ok]'} 검사 오류 ${v.errors} · 경고 ${v.warnings}`);
95
+ for (const i of v.issues.filter(x => x.level === 'error').slice(0, DETAIL_LIMIT)) lines.push(` ${i.id}${i.path ? ` ${i.path}` : ''} ${i.message}`);
96
+ for (const n of report.notes) lines.push(` ${n}`);
97
+ for (const r of report.screens) {
98
+ const findings = findingsOf(r).map(f => f.message);
99
+ const shot = r.screenshot ? `화면 그림 ${r.screenshot}` : '화면 그림 없음';
100
+ lines.push(`[${statusOf(r)}] ${r.screen} · ${r.viewport} ${r.width}px ${[...findings, shot].join(' · ')}`);
101
+ const detail = (label, items) => {
102
+ for (const item of items.slice(0, DETAIL_LIMIT)) lines.push(` ${label}: ${item.split('\n')[0]}`);
103
+ if (items.length > DETAIL_LIMIT) lines.push(` … ${label} 외 ${items.length - DETAIL_LIMIT}개`);
104
+ };
105
+ detail('예외', r.pageErrors);
106
+ detail('콘솔 오류', r.consoleErrors);
107
+ detail('막힌 외부 요청', r.blocked);
108
+ detail('실패한 요청', r.failedRequests);
109
+ }
110
+ const bad = report.screens.filter(r => statusOf(r) !== 'ok').length;
111
+ lines.push('', `${report.ok ? '[ok]' : '[fail]'} 화면 ${report.screens.length}개 중 문제 ${bad}개${v.errors ? ` · 검사 오류 ${v.errors}` : ''} (${(report.durationMs / 1000).toFixed(1)}초)`, `화면 그림: ${report.screenshotsDir}`);
112
+ return lines.join('\n');
113
+ }
114
+ /** 콘텐츠 문서 상태 (브라우저 안에서 돈다) */
115
+ function probe() {
116
+ const LOADING = /^(불러오는 중|로딩 중|loading)\s*(…|\.\.\.)?$/i;
117
+ const body = document.body;
118
+ const de = document.documentElement;
119
+ if (!body) return {
120
+ ready: false,
121
+ text: 0,
122
+ media: false,
123
+ loading: null,
124
+ overflowX: false,
125
+ width: 0
126
+ };
127
+ const visible = el => el.getClientRects().length > 0;
128
+ const loadingEl = [...body.querySelectorAll('*')].find(el => el.children.length === 0 && LOADING.test((el.textContent ?? '').trim()) && visible(el));
129
+ const media = [...body.querySelectorAll('canvas, svg, img, video')].some(el => {
130
+ const r = el.getBoundingClientRect();
131
+ return r.width > 0 && r.height > 0;
132
+ });
133
+ return {
134
+ ready: document.readyState === 'complete',
135
+ text: body.innerText.trim().length,
136
+ media,
137
+ loading: loadingEl ? (loadingEl.textContent ?? '').trim() : null,
138
+ overflowX: de.scrollWidth > de.clientWidth,
139
+ width: window.innerWidth
140
+ };
141
+ }
142
+ const wait = ms => new Promise(r => setTimeout(r, ms));
143
+ async function checkScreen(page, o) {
144
+ const started = Date.now();
145
+ const hostOrigin = new URL(o.hostUrl).origin;
146
+ const consoleErrors = [];
147
+ const pageErrors = [];
148
+ const failedRequests = [];
149
+ page.on('console', m => {
150
+ if (m.type() !== 'error') return;
151
+ const text = m.text();
152
+ if ([...IGNORED_CONSOLE, ...DUPLICATE_CONSOLE].some(re => re.test(text))) return;
153
+ consoleErrors.push(text);
154
+ });
155
+ page.on('pageerror', e => pageErrors.push(e.stack ?? e.message));
156
+ page.on('response', r => {
157
+ const url = r.url();
158
+ if (r.status() < 400) return;
159
+ if (url.startsWith(o.contentOrigin) || url.startsWith(`${hostOrigin}/api/`)) failedRequests.push(`${r.status()} ${new URL(url).pathname}`);
160
+ });
161
+ const url = `${o.hostUrl}?view=${VIEW[o.screen]}&width=${encodeURIComponent(CHECK_VIEWPORTS[o.viewport])}`;
162
+ const deadline = started + SCREEN_WAIT_MS;
163
+ let state = null;
164
+ try {
165
+ await page.goto(url, {
166
+ waitUntil: 'domcontentloaded',
167
+ timeout: SCREEN_WAIT_MS
168
+ });
169
+ } catch {
170
+ // 시간 안에 못 열면 아래에서 그때 모습으로 기록
171
+ }
172
+ const contentFrame = () => page.frames().find(f => f.url().startsWith(o.contentOrigin));
173
+ const read = async () => {
174
+ const frame = contentFrame();
175
+ if (!frame) return null;
176
+ try {
177
+ return await frame.evaluate(probe);
178
+ } catch {
179
+ return null; // 다시 띄우는 중
180
+ }
181
+ };
182
+ while (Date.now() < deadline) {
183
+ state = await read();
184
+ if (state && state.ready && (state.text > 0 || state.media) && !state.loading) break;
185
+ await wait(150);
186
+ }
187
+ await wait(SETTLE_MS);
188
+ state = (await read()) ?? state;
189
+ let screenshot = null;
190
+ const file = join(o.shotDir, `${o.screen}-${o.viewport}.png`);
191
+ try {
192
+ await page.locator('#content').screenshot({
193
+ path: file,
194
+ timeout: 5000
195
+ });
196
+ screenshot = relative(o.dir, file).split(sep).join('/');
197
+ } catch {
198
+ // 그림 없이 결과만
199
+ }
200
+ let blocked = [];
201
+ try {
202
+ blocked = await page.evaluate(() => (window.__ECDK_HOST__?.blocked ?? []).map(b => `${b.blockedURI} (${b.violatedDirective})`));
203
+ } catch {
204
+ // 화면이 닫혔으면 빈 목록
205
+ }
206
+ return {
207
+ screen: o.screen,
208
+ viewport: o.viewport,
209
+ width: state?.width ?? 0,
210
+ rendered: !!state && (state.text > 0 || state.media) && !state.loading,
211
+ loading: state?.loading ?? null,
212
+ consoleErrors: [...new Set(consoleErrors)],
213
+ pageErrors: [...new Set(pageErrors)],
214
+ blocked,
215
+ failedRequests: [...new Set(failedRequests)],
216
+ overflowX: state?.overflowX ?? false,
217
+ screenshot,
218
+ ms: Date.now() - started
219
+ };
220
+ }
221
+ /** 프로젝트에 없는 화면을 고른 경우 (사용법 오류) */
222
+ class ScreenNotFoundError extends Error {}
223
+ /**
224
+ * ecdk dev와 같은 서버를 띄우고 화면 × 폭마다 헤드리스 브라우저로 열어 확인한 뒤 서버를 닫는다.
225
+ * 그림은 <프로젝트>/.ecdk/screens/<화면>-<폭>.png (매번 덮어씀, .ecdk는 zip에서 빠짐)
226
+ */
227
+ async function runCheck(opts) {
228
+ const started = Date.now();
229
+ const notes = [];
230
+ const server = await startDevServer({
231
+ dir: opts.dir,
232
+ port: opts.port ?? 0,
233
+ log: line => {
234
+ if (line.startsWith('[dev]')) notes.push(line);
235
+ }
236
+ });
237
+ let browser = null;
238
+ const stop = async () => {
239
+ await browser?.close().catch(() => {});
240
+ await server.close();
241
+ };
242
+ // Ctrl+C · 종료 신호에도 브라우저와 서버를 닫는다
243
+ const onSignal = () => void stop().finally(() => process.exit(130));
244
+ process.once('SIGINT', onSignal);
245
+ process.once('SIGTERM', onSignal);
246
+ try {
247
+ const check = server.check;
248
+ const entries = check.manifest?.entries ?? {
249
+ learn: 'index.html'
250
+ };
251
+ const kind = check.manifest?.kind ?? 'material';
252
+ const available = defaultScreens(entries, kind);
253
+ const screens = opts.screens ?? available;
254
+ const missing = screens.filter(s => !available.includes(s));
255
+ if (missing.length) throw new ScreenNotFoundError(`이 프로젝트에 없는 화면: ${missing.join(', ')} (있는 화면: ${available.join(', ') || '없음'}, metadata.json screens.*.enabled)`);
256
+ const viewports = opts.viewports ?? ['desktop', 'mobile'];
257
+ const launched = await launchBrowser();
258
+ browser = launched.browser;
259
+ const context = await browser.newContext({
260
+ viewport: WINDOW
261
+ });
262
+ const dir = server.projectDir;
263
+ const shotDir = join(dir, '.ecdk', 'screens');
264
+ await mkdir(shotDir, {
265
+ recursive: true
266
+ });
267
+ const contentOrigin = new URL(server.contentUrl).origin;
268
+ const jobs = screens.flatMap(screen => viewports.map(viewport => ({
269
+ screen,
270
+ viewport
271
+ })));
272
+ const results = new Array(jobs.length);
273
+ let next = 0;
274
+ await Promise.all(Array.from({
275
+ length: Math.min(PARALLEL, jobs.length)
276
+ }, async () => {
277
+ while (next < jobs.length) {
278
+ const i = next++;
279
+ const page = await context.newPage();
280
+ try {
281
+ results[i] = await checkScreen(page, {
282
+ hostUrl: server.hostUrl,
283
+ contentOrigin,
284
+ ...jobs[i],
285
+ dir,
286
+ shotDir
287
+ });
288
+ } finally {
289
+ await page.close().catch(() => {});
290
+ }
291
+ }
292
+ }));
293
+ const issues = check.issues.map(i => ({
294
+ level: i.level,
295
+ id: i.id,
296
+ ...(i.path ? {
297
+ path: i.path
298
+ } : {}),
299
+ message: i.message
300
+ }));
301
+ const validate = {
302
+ errors: issues.filter(i => i.level === 'error').length,
303
+ warnings: issues.filter(i => i.level !== 'error').length,
304
+ issues
305
+ };
306
+ const report = {
307
+ ok: false,
308
+ project: dir,
309
+ browser: launched.name,
310
+ durationMs: 0,
311
+ screenshotsDir: shotDir,
312
+ screens: results,
313
+ validate,
314
+ notes
315
+ };
316
+ report.ok = exitCodeOf(report) === 0;
317
+ report.durationMs = Date.now() - started;
318
+ return report;
319
+ } finally {
320
+ process.off('SIGINT', onSignal);
321
+ process.off('SIGTERM', onSignal);
322
+ await stop();
323
+ }
324
+ }
325
+
326
+ export { CHECK_SCREENS, CHECK_VIEWPORTS, SCREEN_WAIT_MS, ScreenNotFoundError, defaultScreens, exitCodeOf, findingsOf, formatText, parseList, runCheck, statusOf };
@@ -108,6 +108,11 @@ function hostPage(opts) {
108
108
  // 저장소가 막힌 브라우저에서도 화면이 떠야 하므로 sessionStorage는 모두 try로 감싼다
109
109
  let current = 'student';
110
110
  try { current = sessionStorage.getItem('ecdk-scenario') || 'student'; } catch {}
111
+ // 주소로 보기 · 폭을 고른다 (?view=edit&width=360px). ecdk dev --check가 쓰고, 사람이 북마크로 써도 된다
112
+ const query = new URLSearchParams(location.search);
113
+ if (query.get('view')) current = query.get('view');
114
+ // ecdk dev --check가 읽는 기록: 이번에 연 콘텐츠의 막힌 외부 요청
115
+ window.__ECDK_HOST__ = { blocked: [] };
111
116
 
112
117
  function note(line) {
113
118
  const lines = (messagesEl.textContent ? messagesEl.textContent.split('\\n') : []).slice(-4);
@@ -123,6 +128,7 @@ function hostPage(opts) {
123
128
  async function open(scenario) {
124
129
  current = scenario;
125
130
  blocked = new Set();
131
+ window.__ECDK_HOST__.blocked = [];
126
132
  try { sessionStorage.setItem('ecdk-scenario', scenario); } catch {}
127
133
  for (const b of scenariosEl.children) b.setAttribute('aria-pressed', String(b.dataset.scenario === scenario));
128
134
  previewEl.setAttribute('aria-pressed', String(scenario === PREVIEW[0]));
@@ -172,6 +178,7 @@ function hostPage(opts) {
172
178
  const key = p.blockedURI + ' ' + p.violatedDirective;
173
179
  if (!blocked.has(key)) {
174
180
  blocked.add(key);
181
+ window.__ECDK_HOST__.blocked.push({ blockedURI: String(p.blockedURI), violatedDirective: String(p.violatedDirective) });
175
182
  note('막힌 외부 요청: ' + p.blockedURI + ' (' + p.violatedDirective + ') — LXP 콘텐츠 CSP도 막습니다. zip 안에 넣어 주세요');
176
183
  }
177
184
  return;
@@ -225,6 +232,9 @@ function hostPage(opts) {
225
232
  for (const x of document.querySelectorAll('[data-w]')) x.setAttribute('aria-pressed', String(x === b));
226
233
  frame.style.setProperty('--w', b.dataset.w);
227
234
  };
235
+ // ?width=360px: 그 폭 버튼을 누른 것과 같다
236
+ const widthButton = [...document.querySelectorAll('[data-w]')].find((b) => b.dataset.w === query.get('width'));
237
+ if (widthButton) widthButton.click();
228
238
  // SDK 기능 펼침 상태는 이 탭에서만 기억한다
229
239
  const toolsEl = document.getElementById('sdk-tools');
230
240
  try { toolsEl.open = sessionStorage.getItem('ecdk-sdk-tools') === '1'; } catch {}
@@ -222,7 +222,7 @@ async function handleMockApi(req, res, path, opts) {
222
222
  };
223
223
  state.settings = next;
224
224
  await opts.saveSettings?.(next);
225
- log(`내용을 .ecdk/settings.json에 저장했습니다${next.grading ? ` (채점 설정 ${next.grading.type})` : ''}`);
225
+ log(`내용을 .ecdk/settings.json에 저장했습니다${next.grading ? ` (채점 설정 ${next.grading.type})` : ''}. 로컬에만 있고, publish 스킬이 동의를 받아 업로드와 함께 보낼 수 있습니다`);
226
226
  const {
227
227
  metadata
228
228
  } = material(state.settings).current_version;
@@ -8,6 +8,8 @@ export interface DevServerOptions {
8
8
  log?: (line: string) => void;
9
9
  }
10
10
  export interface DevServer {
11
+ /** 프로젝트 폴더 (절대 경로) */
12
+ projectDir: string;
11
13
  hostUrl: string;
12
14
  contentUrl: string;
13
15
  /** 지금 보고 있는 콘텐츠 기준 검사 결과 */
package/es/dev/server.js CHANGED
@@ -326,6 +326,7 @@ async function startDevServer(opts) {
326
326
  });
327
327
  log(summarize(check));
328
328
  return {
329
+ projectDir: dir,
329
330
  hostUrl: `${hostOrigin}/`,
330
331
  contentUrl: contentOrigin + CONTENT_PREFIX,
331
332
  get check() {
package/es/rules/check.js CHANGED
@@ -94,7 +94,7 @@ function checkTemplate(manifest, opts, add) {
94
94
  const LEGACY_FILE_MESSAGES = {
95
95
  'elice.config.json': 'elice.config.json은 더 쓰지 않습니다 (ADR 0011). 화면 · 학습 참고 내용(kind · screens · commentary)은 원본의 metadata.json에, 빌드 옵션 · template은 package.json "ecdk"에 둡니다. ecdk doctor --fix가 옮기고 elice.config.json을 지웁니다 (옮기기 전까지는 지금처럼 빌드됨).',
96
96
  'content.json': 'content.json은 더 쓰지 않습니다 (기본 내용 파일 없음, ADR 0011). 화면은 편집 화면이 저장한 내용만 읽고, 저장하기 전에는 "아직 내용이 없습니다" 안내를 보입니다. 그 내용은 LXP에 올린 뒤 편집 화면에서 다시 넣고 파일을 지워 주세요. 화면 코드가 직접 fetch하는 데이터 파일이면 다른 이름(예: data.json)으로 바꿔 주세요.',
97
- 'grading.json': "grading.json은 더 쓰지 않습니다 (ADR 0011). 채점 방식 · 답은 LXP에 올린 뒤 편집 화면에서 정합니다 (ecdk dev의 '내용 편집'에 넣은 답은 로컬 견본, .ecdk/settings.json). 파일은 지워 주세요 (zip에는 들어가지 않음)."
97
+ 'grading.json': "grading.json은 더 쓰지 않습니다 (ADR 0011). 채점 방식 · 답은 LXP에 올린 뒤 편집 화면에서 정합니다 (ecdk dev의 '내용 편집'에 넣은 답은 .ecdk/settings.json, publish 스킬이 동의를 받아 업로드와 함께 보낼 수 있음). 파일은 지워 주세요 (zip에는 들어가지 않음)."
98
98
  };
99
99
  function checkLegacyFiles(opts, add) {
100
100
  for (const path of opts.legacyFiles ?? []) {
@@ -19,7 +19,7 @@ export type ParsedManifest = {
19
19
  */
20
20
  export declare const LEGACY_COMPLETION_SCREENS: readonly ["completionPolicy", "completion", "grading"];
21
21
  /** 완료 정책은 LXP 설정 (ADR 0012): metadata.json에 남은 완료 정책 필드 · 화면 안내 */
22
- export declare const COMPLETION_POLICIES_IGNORED = "\uC644\uB8CC \uC815\uCC45\uC740 LXP\uC5D0 \uC62C\uB9B0 \uB4A4 \uC124\uC815 \uD0ED\uC5D0\uC11C \uAD50\uC721\uC790\uAC00 \uACE0\uB985\uB2C8\uB2E4 (2026-11-12, ADR 0012). metadata.json\uC5D0\uC11C \uC9C0\uC6CC \uC8FC\uC138\uC694 (ecdk build\uB294 zip\uC5D0\uC11C \uBE8D\uB2C8\uB2E4)";
22
+ export declare const COMPLETION_POLICIES_IGNORED = "\uC644\uB8CC \uC815\uCC45\uC740 LXP\uC5D0 \uC62C\uB9B0 \uB4A4 \uC790\uB8CC \uD3B8\uC9D1 \uD654\uBA74\uC758 '\uC124\uC815'\uC5D0\uC11C \uAD50\uC721\uC790\uAC00 \uACE0\uB985\uB2C8\uB2E4 (2026-11-12, ADR 0012). metadata.json\uC5D0\uC11C \uC9C0\uC6CC \uC8FC\uC138\uC694 (ecdk build\uB294 zip\uC5D0\uC11C \uBE8D\uB2C8\uB2E4)";
23
23
  /**
24
24
  * metadata.json에 적는 파일 이름(진입 파일 · 학습 참고 내용): zip 최상위, 영문 · 숫자 · `.` · `_` · `-`만.
25
25
  * LXP가 배포 주소 뒤에 그대로 붙여 열므로 공백 · 한글 · `?` · `#` · `%`처럼 URL 인코딩이 필요한 글자는 받지 않는다.
@@ -4,7 +4,7 @@
4
4
  */
5
5
  const LEGACY_COMPLETION_SCREENS = ['completionPolicy', 'completion', 'grading'];
6
6
  /** 완료 정책은 LXP 설정 (ADR 0012): metadata.json에 남은 완료 정책 필드 · 화면 안내 */
7
- const COMPLETION_POLICIES_IGNORED = '완료 정책은 LXP에 올린 뒤 설정 탭에서 교육자가 고릅니다 (2026-11-12, ADR 0012). metadata.json에서 지워 주세요 (ecdk build는 zip에서 뺍니다)';
7
+ const COMPLETION_POLICIES_IGNORED = "완료 정책은 LXP에 올린 뒤 자료 편집 화면의 '설정'에서 교육자가 고릅니다 (2026-11-12, ADR 0012). metadata.json에서 지워 주세요 (ecdk build는 zip에서 뺍니다)";
8
8
  const isRecord = v => typeof v === 'object' && v !== null && !Array.isArray(v);
9
9
  /**
10
10
  * metadata.json에 적는 파일 이름(진입 파일 · 학습 참고 내용): zip 최상위, 영문 · 숫자 · `.` · `_` · `-`만.
@@ -124,7 +124,7 @@ function parseManifest(text, spec) {
124
124
  });
125
125
  if (json.gradingTypes !== undefined) warnings.push({
126
126
  id: 'manifest.grading-types',
127
- message: '"gradingTypes"는 더 쓰지 않습니다 (2026-11-10). 채점 방식 · 답은 편집 화면이 정하고 (ADR 0009), 완료 정책은 LXP 설정 탭에서 교육자가 고릅니다 (ADR 0012). ecdk build로 다시 만들면 빠집니다.'
127
+ message: `"gradingTypes"는 더 쓰지 않습니다 (2026-11-10). 채점 방식 · 답은 편집 화면이 정하고 (ADR 0009), 완료 정책은 LXP 자료 편집 화면의 '설정'에서 교육자가 고릅니다 (ADR 0012). ecdk build로 다시 만들면 빠집니다.`
128
128
  });
129
129
  const commentary = json.commentary;
130
130
  if (commentary !== undefined) {
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 테스트용: 옛 CLI(1.0.0-alpha.6 이하)가 설치한 공유 가이드 스킬 elice-content-guide를 그때 모양 그대로 만든다
3
+ * (SKILL.md + topics/NN-….md, 본문 안 ecdk-skill-files 줄, 맨 끝 ecdk-skill 설치 표시)
4
+ */
5
+ export declare function writeOldGuideSkill(skillsDir: string, version?: string): Promise<string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eliceio/cdk-cli",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "교육자용 Custom HTML 콘텐츠 CLI",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -35,6 +35,7 @@
35
35
  "dependencies": {
36
36
  "esbuild": "~0.28.2",
37
37
  "fflate": "^0.8.3",
38
+ "playwright-core": "~1.64.1",
38
39
  "vite": "^8.3.6"
39
40
  },
40
41
  "devDependencies": {
@@ -45,7 +46,7 @@
45
46
  "rollup": "^4.0.0",
46
47
  "tslib": "^2.6.1",
47
48
  "typescript": "~5.9.3",
48
- "@eliceio/cdk": "^1.1.0"
49
+ "@eliceio/cdk": "^1.2.0"
49
50
  },
50
51
  "scripts": {
51
52
  "prebuild": "del-cli \"buildcache/*\" \"es/*\"",
@@ -1,10 +1,18 @@
1
1
  ## Always
2
2
 
3
- - Never put correct answers in the content zip. The edit screen saves them to `settings.grading` (locally `.ecdk/settings.json` from `ecdk dev`).
3
+ - Answer the person in their language. The reference files are in English: `references/` next to this SKILL.md, read only the ones you need with the Read tool: 00 what the person decides · 01 environment · 02 design · 03 create the project · 04 sandbox rules · 05 screen code and kit API · 06 quiz template · 07 move existing HTML · 08 error ids · 09 check · 10 build and report · 11 more · 12 upload.
4
+ - Never put correct answers in the content zip. The edit screen saves them to `settings.grading` (locally `.ecdk/settings.json` from `ecdk dev`, which stays local unless the person agrees to send it with the upload, `references/12-upload-with-the-material-mcp.md`).
5
+ - The completion policy is not in the project or the zip: it is a setting of the LXP page. Say which one fits (`references/02-design-the-material.md` ②); the elice-content-publish skill sets it with the upload after the person agrees (`on_graded` only with grading saved), otherwise the instructor picks it in the '설정' panel at the top of the LXP edit page. Only `on_graded` grades: `on_submit` completes on any submission without grading (`is_correct: null`, the kit shows "제출했어요."), `on_access` completes on open.
4
6
  - The content runs in a sandboxed iframe on its own origin: use the SDK (`app.useSubmit`, `app.useSave`) for anything that must be kept (storage and cookies stay only in that browser), and in-page UI instead of `alert`/`confirm`, new windows, the parent window or external requests.
5
7
  - The content CSP blocks external images, fonts, video, CSS, `<iframe>` and external APIs: put everything in the zip (fonts as files or data URIs). If a library calls outside hosts while running, that is blocked too → check the `ecdk dev` log for "막힌 외부 요청".
6
- - If `ecdk`, `node` or `npm` is "command not found", the app started without the person's shell PATH (macOS desktop apps such as Helpy Code Desktop). Run each command through their login shell instead: `"$SHELL" -ilc 'ecdk build --json'` (use `zsh -ilc` when `$SHELL` is empty). With `--json`, read only the last JSON block of the output (a login shell may print other text first). If that also fails, ask the person how Node was installed.
7
8
  - Fix every `ecdk validate` / `ecdk build` error before you report. Do not edit `lib/` (the screen kit). The SDK comes from npm through `package.json` (`npm update @eliceio/cdk`); the kit imports it and `ecdk build` (Vite) bundles it into the screens. Never copy SDK code into the project.
8
- - Ask the person before you settle correct answers, install anything globally, or upload or save to LXP (a saved version is visible to learners at once). Before uploading, confirm the exact target page (기관 · 과목 · 수업 · 페이지) with the person.
9
- - LXP draws its own 이전 · 다음 bar under the material to move between lecture pages. For steps inside a material use the kit's `app.usePaging` (side chevrons, `n / N`; on the first and last step they become "이전 자료" · "다음 자료" to the previous / next lecture page, `../elice-content-guide/topics/02-design-the-material.md`), never a look-alike bottom 이전 · 다음 bar.
10
- - Answer the person in their language. The guide is in English.
9
+ - Ask the person before you settle correct answers (they confirm them before answers go with an upload), install anything globally, or upload or save to LXP (a saved version is visible to learners at once). Before uploading, confirm the exact target page (기관 · 과목 · 수업 · 페이지) with the person.
10
+ - LXP draws its own 이전 · 다음 bar under the material to move between lecture pages. For steps inside a material use the kit's `app.usePaging` (side chevrons, `n / N`; `references/02-design-the-material.md`), never a look-alike bottom 이전 · 다음 bar.
11
+
12
+ ## Progress and live preview
13
+
14
+ - At the start, show a short numbered plan (for example `1 설계 → 2 프로젝트 → 3 학생 화면 → 4 편집 화면 → 5 확인 → 6 zip`). Before and after each step write one line: `[3/6] 학생 화면 만드는 중: …` and `[3/6] 끝: … · 다음: …`.
15
+ - Right after `ecdk create` (or when you start on an existing project), start `ecdk dev <folder>` in the background and give the person the URL it prints (`http://localhost:4170` unless that port is taken), so they watch the screens change while you write code. Claude Code: run it as a background command. Helpy Code: the tool's background option, or `zsh -ilc 'ecdk dev <folder> > /tmp/ecdk-dev.log 2>&1 &'` and read the URL from that log. Do not wait for the person.
16
+ - Check screens only with `ecdk dev [folder] --check [--screens learn,tutoring,instructor,edit] [--viewport desktop,mobile] [--json]`. Never write your own browser-automation script (Playwright, Puppeteer, …). After each screen, run it (`--screens <that screen>`), tell the person the result lines, the screenshots `.ecdk/screens/<screen>-<viewport>.png` (Claude Code: Read the PNG to see it; otherwise give the path) and what to try in the browser (it checks only the first state, no clicks or submits). First make sure `ecdk dev --help` lists `--check` (an older ecdk does not have it). To see the student screen with content, write sample content to `.ecdk/settings.json` first (`references/09-check.md`). Exit 1: fix and run again (at most twice). Exit 3 (no browser), an unknown option (an older ecdk) or a problem you cannot fix: stop checking and ask the person to look at the dev URL (`references/09-check.md`).
17
+ - While `ecdk dev` runs, do not run `ecdk validate` again and again: dev checks again on every change and `--check` prints the validation summary. Run `ecdk validate` once before building (or let `ecdk build` check).
18
+ - If `ecdk`, `node` or `npm` is "command not found", the app started without the person's shell PATH (macOS desktop apps such as Helpy Code Desktop). Find the paths once with `"$SHELL" -ilc 'command -v ecdk node npm'` (`zsh -ilc` when `$SHELL` is empty), then run commands with absolute paths and node's folder first on PATH: `PATH="/opt/homebrew/bin:$PATH" /opt/homebrew/bin/ecdk build --json`. If that fails, run the command through the login shell (`"$SHELL" -ilc 'ecdk build --json'`; with `--json` read only the last JSON block). If that also fails, ask the person how Node was installed.
@@ -3,8 +3,8 @@
3
3
  The person (the instructor or author) is responsible for the content and its answers. Do not settle the following on your own; ask, or get a confirmation.
4
4
 
5
5
  1. **The learning goal, when it is unclear.** Decide the rest of the design to fit the goal and tell the person briefly what you decided.
6
- 2. **Correct answers.** You may draft answers and rubrics, but the person confirms that they are right.
7
- 3. **How it is graded**: whether the student submits, and the grader (`pattern` or `rubric`) set on the edit screen. Propose what fits the material and get a confirmation. The completion policy is not decided here: the instructor picks it in the LXP settings tab after the upload (완료 정책은 LXP에 올린 뒤 설정 탭에서 교육자가 고른다). Tell the person which policy fits (see the table in 2 ②).
6
+ 2. **Correct answers.** You may draft answers and rubrics, but the person confirms that they are right, before they go with an upload.
7
+ 3. **How it is graded**: whether the student submits, and the grader (`pattern` or `rubric`) set on the edit screen. Propose what fits the material and get a confirmation. **The completion policy**: propose the one that fits (the table in 2 ②) and get a yes before the upload sets it (2026-11-12: the publish skill can set it with the save; otherwise the instructor picks it in the '설정' panel at the top of the LXP edit page). Only `on_graded` grades: `on_submit` completes on any submission without grading (`is_correct: null`, the kit shows "제출했어요."), `on_access` completes on open.
8
8
  4. **What the learning notes say** (`commentary.txt`). A material needs them (LXP rejects the upload without them); once they are filled in, AI Helpy answers only questions about this material, so let the person check the wording.
9
9
  5. **Checking the screens.** The person looks at the student, tutoring, instructor, edit and mobile views in the preview. When they cannot, tell them what to check and in which order.
10
10
  6. **Uploading to LXP.** A saved version is **visible to learners at once** (when the page is open). Before uploading, show what changes and get approval. The same goes for changing a material that is already open, changing answers, and restoring an older version.
@@ -1,21 +1,30 @@
1
1
  # 2. Design the material
2
2
 
3
+ A Custom HTML learning material is **a small web app in one zip**: an explanation, an interactive simulation or visualization, a guided exercise, a game-like activity, flashcards, a self-check or survey, a quiz, or the description of a practice problem. Elice opens it in a **sandboxed (`allow-scripts allow-same-origin`) iframe on its own origin**; there is no server, only submission, saving and grading go to the Elice server. One zip has up to three screens:
4
+
5
+ | Screen | Files | What it does |
6
+ | ----------------------- | ------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
7
+ | Student (required) | `index.html` + `screens/learn.js` | The learning activity (read, interact, solve, make). Submits a result when needed |
8
+ | Instructor (optional) | `instructor.html` + `screens/instructor.js` | What only instructors see: activity summary, explanations, teaching tips |
9
+ | Content edit (optional) | `edit.html` + `screens/edit.js` | Instructors edit text and data without code and save it → `app.content` of the other screens. Also sets the grader and the answers or rubric, saved to `settings.grading` (never sent to students) |
10
+
3
11
  Decide the following before writing code. Decide what the request leaves out to fit the material's purpose, and tell the user briefly what you decided. Ask only when the learning goal is unclear.
4
12
 
5
13
  **① What the student does**
6
14
  Read or watch / change values and observe (simulation, visualization) / follow steps / solve problems / make something. Tie the activity directly to the learning goal.
7
15
 
8
- **② Submission and grading** (2026-11-12: the completion policy is an LXP setting the instructor picks in the settings tab after the upload, ADR 0012; the package does not list it. The grading settings `settings.grading` hold the grader `type` and its answers)
16
+ **② Submission and grading** (the completion policy is a setting of the LXP page, not in the package, ADR 0012; since 2026-11-12 the publish skill sets it with the upload after the person agrees, otherwise the instructor picks it in the '설정' panel at the top of the LXP edit page. The grading settings `settings.grading` hold the grader `type` and its answers)
9
17
 
10
- | Material | Policy to suggest (LXP setting) | Grading (`type`) | Student screen |
18
+ | Material | Policy to propose (LXP setting) | Grading (`type`) | Student screen |
11
19
  | ----------------------------------------------------------- | --------------------------------- | ----------------------- | ----------------------------------------- |
12
20
  | Something to read or watch, such as a simulation | `on_access` (done on open) | - | No submission |
13
- | Done when the activity ends (results, self-check, survey) | `on_submit` (100 on submit) | - | Submit the result with `useSubmit` |
21
+ | Done when the activity ends (results, self-check, survey) | `on_submit` (done on submit) | - | Submit the result with `useSubmit` |
14
22
  | One correct answer or one set of answers | `on_graded` (done when it passes) | `pattern` (one regex) | `useSubmit` |
15
23
  | Writing or assignments graded against a rubric (AI grading) | `on_graded` | `rubric` (the criteria) | `useSubmit`, the score comes back at once |
16
24
 
17
25
  - **The grader and the answers are set on the edit screen** and saved to `settings.grading` with the edit token (`useSave` with `getGrading`): `{ "type": "pattern", "answer_key": "^…$" }` or `{ "type": "rubric", "rubric": "…" }`. The kit's default block `app.useGradingBlock()` uses LXP's wording (기준 답안 (정규표현식), 작성 예시 보기, 평가 기준). When the answers depend on the content's structure (questions, choices, steps), set them where the content is edited, for example in each question card. The answer to `pattern` is **one regular expression** that must match the whole submitted answer string (trimmed), so submit one string and build the regex from the instructor's choices.
18
- - **The completion policy is picked in LXP**, not in the project: after the upload the instructor chooses `on_access`, `on_submit` or `on_graded` in the settings tab (ADR 0012). Do not write it in `metadata.json` (the old `completionPolicies` and `screens.completionPolicy` are ignored with the warning `manifest.completion-policies-ignored`, and `ecdk build` leaves them out of the zip). The content can read the current policy (SDK `material.completionPolicy`) but never sets it. Build what the suggested policy needs: a submission (`useSubmit`) for `on_submit` · `on_graded`, and the grading saved on the edit screen for `on_graded`. The server rejects `on_graded` without `settings.grading` (`MATERIAL_GRADING_REQUIRED`). The edit screen never sends a policy.
26
+ - **The completion policy is picked in LXP**, not in the project: the publish skill proposes it from this table and sets it with the upload after the person agrees (graded: the quiz template or settings with `grading` → `on_graded`; submits without grading → `on_submit`; no submission → `on_access`), or the instructor chooses it in the '설정' panel at the top of the LXP edit page, which applies at once (ADR 0012). `on_graded` needs `settings.grading` saved first, so it goes in the same save as settings with `grading`, or later. Do not write it in `metadata.json` (the old `completionPolicies` and `screens.completionPolicy` are ignored with the warning `manifest.completion-policies-ignored`, and `ecdk build` leaves them out of the zip). The content can read the current policy (SDK `material.completionPolicy`) but never sets it. Build what the suggested policy needs: a submission (`useSubmit`) for `on_submit` · `on_graded`, and the grading saved on the edit screen for `on_graded`. The server rejects `on_graded` without `settings.grading` (`MATERIAL_GRADING_REQUIRED`). The edit screen never sends a policy.
27
+ - **Only `on_graded` grades.** `on_submit` completes on any submission and does not grade, even with saved answers: the submission comes back `is_correct: null`, `score: 100`, and the kit shows "제출했어요.". `on_access` completes on open. A quiz with `on_submit` shows no score; that is the policy, not broken grading.
19
28
  - Custom HTML does not use manual grading (`manual`) or no grading (`none`). There is no per-question grading: every question must be right for 100. Changing the answers does not regrade past submissions.
20
29
  - Answers never go in the zip (`metadata.json` · data JSON · code), and there is no answer file in the project: answers exist only in `settings.grading`, saved on the edit screen. The old `gradingTypes` field is gone (2026-11-10): `ecdk build` warns when it is still in `metadata.json` or an old `elice.config.json`. A grading with the 11-10 policy and grader fields is rejected with how to rewrite it.
21
30
 
@@ -1,6 +1,6 @@
1
1
  # 3. Create the project
2
2
 
3
- Run `ecdk create --list` first: it prints each template with its own version (`quiz@1.3.1`), what it is for and its screens. Pick the template from that list. `ecdk create` records the template and version in `package.json` `"ecdk"` (`template`), `ecdk build` copies it to `metadata.json` `build.template`, and `ecdk doctor` says when the installed ecdk ships a newer version of that template (nothing changes on its own).
3
+ Run `ecdk create --list` first: it prints each template with its own version (`quiz@1.3.2`), what it is for and its screens. Pick the template from that list. `ecdk create` records the template and version in `package.json` `"ecdk"` (`template`), `ecdk build` copies it to `metadata.json` `build.template`, and `ecdk doctor` says when the installed ecdk ships a newer version of that template (nothing changes on its own).
4
4
 
5
5
  | Case | Start with |
6
6
  | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -17,6 +17,6 @@ The project files: screens, `lib/` (the screen kit, copied as is), `metadata.jso
17
17
  Then:
18
18
 
19
19
  1. Set `screens` in `metadata.json` to the design (`{ "enabled": true, "entry": "edit.html" }` for a screen you keep, `{ "enabled": false }` for one you drop). In `ecdk dev`, saving in the content edit view writes the whole settings (content and answers) to `.ecdk/settings.json`; it stays out of the zip and out of `ecdk build` · `check`.
20
- 2. Make the edit screen save the data in ④. **Local work builds only the template (screens and code)**; the real content and answers are entered in the LXP edit screen after upload (2026-11-11). In `ecdk dev`, try the edit and learn screens with a little sample input; it is saved only in `.ecdk/settings.json` and never uploaded, so do not author the full content locally. When the person describes the content, give it as draft text for them to enter in LXP.
20
+ 2. Make the edit screen save the data in ④. There is no default content file: the content and answers are what the edit screen saves. In `ecdk dev` the edit view writes `.ecdk/settings.json`, local by default; the upload can carry it after the person agrees ([12](12-upload-with-the-material-mcp.md) "Content and answers (settings)"), otherwise the person enters the content in the LXP edit screen after upload. When the person describes the content, fill it in through the edit view (or write the file in the shape [9](09-check.md) describes and have the edit view save it), with answers the person confirmed.
21
21
  3. Write the screen code ([5](05-screen-code.md)). Delete the HTML and JS of screens you do not use.
22
22
  4. Check ([9](09-check.md)) → build ([10](10-build.md)).