@eliceio/cdk-cli 0.1.0-alpha.6 → 0.1.0-alpha.7
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 +70 -71
- package/es/cli.js +7 -22
- package/es/commands/build/index.d.ts +5 -3
- package/es/commands/build/index.js +16 -7
- package/es/commands/create/scaffold.d.ts +2 -0
- package/es/commands/create/scaffold.js +15 -1
- package/es/commands/doctor/index.d.ts +1 -1
- package/es/commands/doctor/index.js +4 -5
- package/es/commands/setup/index.d.ts +4 -7
- package/es/commands/setup/index.js +41 -70
- package/es/commands/uninstall/index.d.ts +9 -8
- package/es/commands/uninstall/index.js +41 -47
- package/es/commands/update/index.d.ts +4 -2
- package/es/commands/update/index.js +27 -18
- package/es/core/config.d.ts +1 -1
- package/es/core/config.js +2 -2
- package/es/{commands/mcp/index.d.ts → core/mcp.d.ts} +11 -18
- package/es/{commands/mcp/index.js → core/mcp.js} +29 -51
- package/es/core/minify.js +31 -2
- package/es/core/sandbox.d.ts +25 -0
- package/es/core/sandbox.js +104 -5
- package/es/{commands/skill/index.d.ts → core/skills.d.ts} +1 -17
- package/es/{commands/skill/index.js → core/skills.js} +6 -22
- package/es/dev/grading.d.ts +1 -1
- package/es/dev/grading.js +1 -1
- package/es/dev/host-page.js +2 -2
- package/es/rules/check.js +3 -3
- package/es/rules/csp.d.ts +1 -1
- package/es/rules/csp.js +1 -1
- package/es/rules/index.d.ts +1 -1
- package/es/rules/index.js +1 -1
- package/es/rules/unused.d.ts +2 -0
- package/es/rules/unused.js +4 -3
- package/package.json +2 -2
- package/skills/elice-content-create/SKILL.md +2 -1
- package/skills/elice-content-guide/topics/01-check-the-environment.md +2 -2
- package/skills/elice-content-guide/topics/02-design-the-material.md +2 -0
- package/skills/elice-content-guide/topics/03-create-the-project.md +2 -2
- package/skills/elice-content-guide/topics/05-screen-code.md +44 -13
- package/skills/elice-content-guide/topics/10-build.md +1 -1
- package/skills/elice-content-guide/topics/12-upload-with-the-material-mcp.md +2 -2
- package/skills/elice-content-publish/SKILL.md +1 -1
- package/templates/_shared/lib/cdk-mock.js +2 -2
- package/templates/_shared/lib/elice-content-editor.d.ts +80 -0
- package/templates/_shared/lib/elice-content-editor.js +1062 -0
- package/templates/_shared/lib/elice-content.css +332 -0
- package/templates/_shared/lib/elice-content.js +10 -3
- package/templates/blank/README.md +27 -2
- package/templates/blank/commentary.txt +5 -0
- package/templates/blank/screens/edit.js +38 -17
- package/templates/blank/screens/instructor.js +20 -8
- package/templates/blank/screens/learn.js +151 -13
- package/templates/blank/styles.css +171 -0
- package/templates/blank/template.json +2 -2
- package/templates/quiz/core/model.js +1 -1
- package/templates/quiz/screens/edit.js +14 -2
- package/templates/quiz/styles.css +11 -0
- package/templates/quiz/template.json +1 -1
- package/templates/quiz/ui/texts.js +1 -1
package/es/core/sandbox.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { build } from 'esbuild';
|
|
1
|
+
import { build, transform } from 'esbuild';
|
|
2
2
|
import 'fflate';
|
|
3
3
|
import { rules } from '../rules/spec.js';
|
|
4
4
|
import { resolveRef } from '../rules/path.js';
|
|
5
5
|
import { classifyRef } from '../rules/refs.js';
|
|
6
|
+
import { TEXT_FILE } from '../rules/unused.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* LXP는 자료를 콘텐츠마다 다른 출처의 sandbox iframe(`allow-scripts allow-same-origin`)에서 연다.
|
|
@@ -17,7 +18,7 @@ import { classifyRef } from '../rules/refs.js';
|
|
|
17
18
|
* - `<script type="module" src="상대경로">`를 esbuild로 하나로 묶어 `<script type="module">` 본문으로 넣는다
|
|
18
19
|
* (zip 안 파일만 묶음. `import.meta.url`은 원래 파일 주소로 바꿔 상대경로 계산이 그대로 맞게).
|
|
19
20
|
* - zip 안 JSON(metadata.json 제외, 작성자가 넣은 데이터 파일)을 페이지에 넣고 `fetch`가 그 주소를 받으면 넣어 둔 내용을 돌려준다.
|
|
20
|
-
* 원본 JS
|
|
21
|
+
* build는 묶어 넣은 원본 JS 중 다른 데서 쓰지 않는 파일을 zip에서 뺀다 (`dropBundledSources`). JSON은 그대로 둔다.
|
|
21
22
|
*/
|
|
22
23
|
const encoder = new TextEncoder();
|
|
23
24
|
const decoder = new TextDecoder();
|
|
@@ -100,6 +101,10 @@ async function bundle(entry, page, byPath, opts) {
|
|
|
100
101
|
} : {}),
|
|
101
102
|
// minify를 켜면 실제로 실행되는 묶음 코드를 줄인다 (원본 JS는 이제 실행되지 않음)
|
|
102
103
|
minify: opts.minify === true,
|
|
104
|
+
// 라이선스 주석(/*! · @license · @preserve)은 줄여도 묶음 끝에 모아 남긴다 (넣은 라이브러리의 고지 의무)
|
|
105
|
+
legalComments: 'eof',
|
|
106
|
+
// 어느 파일을 묶었는지 (dropBundledSources)
|
|
107
|
+
metafile: true,
|
|
103
108
|
bundle: true,
|
|
104
109
|
format: 'esm',
|
|
105
110
|
target: 'es2022',
|
|
@@ -109,7 +114,40 @@ async function bundle(entry, page, byPath, opts) {
|
|
|
109
114
|
}).catch(e => {
|
|
110
115
|
throw new Error(`${entry}를 묶지 못했습니다: ${e.errors?.[0]?.text ?? e.message ?? 'esbuild 오류'}. LXP에서는 모듈 스크립트를 따로 받을 수 없어 build가 HTML 안에 묶어 넣습니다.`);
|
|
111
116
|
});
|
|
112
|
-
return
|
|
117
|
+
return {
|
|
118
|
+
code: r.outputFiles[0]?.text ?? '',
|
|
119
|
+
inputs: Object.keys(r.metafile.inputs).map(k => k.replace(/^zip:/, ''))
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* 묶음 코드에서 다른 파일 이름을 찾을 글. 그 파일을 받는 코드가 아닌 것은 뺀다: 주석(줄이지 않을 때 esbuild가 다는
|
|
124
|
+
* `// zip:파일` 포함), 줄이지 않을 때 esbuild가 모듈을 감싸며 쓰는 이름(`"zip:파일"()`), import.meta.url 대신 넣은 원래 파일 주소
|
|
125
|
+
*/
|
|
126
|
+
async function scanText(code, inputs) {
|
|
127
|
+
const bare = await withoutComments('x.js', code);
|
|
128
|
+
const own = new Set(inputs);
|
|
129
|
+
return bare.replace(/"zip:([^"]+)"/g, (m, p) => own.has(p) ? '""' : m).replace(/new URL\("(?:\.\.\/)*([^"]+)",\s*location\.href\)\.href/g, (m, p) => own.has(p) ? '""' : m);
|
|
130
|
+
}
|
|
131
|
+
/** 주석을 뺀 글 (주석 속 파일 이름은 받는 것이 아니다). JS는 esbuild로, 문법이 틀리면 그대로 */
|
|
132
|
+
async function withoutComments(path, text) {
|
|
133
|
+
if (/\.html?$/i.test(path)) return text.replace(/<!--[\s\S]*?-->/g, '');
|
|
134
|
+
if (/\.css$/i.test(path)) return text.replace(/\/\*[\s\S]*?\*\//g, '');
|
|
135
|
+
if (!/\.m?js$/i.test(path)) return text;
|
|
136
|
+
try {
|
|
137
|
+
return (await transform(text, {
|
|
138
|
+
loader: 'js',
|
|
139
|
+
minifyWhitespace: true,
|
|
140
|
+
legalComments: 'none'
|
|
141
|
+
})).code;
|
|
142
|
+
} catch {
|
|
143
|
+
return text;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/** 경로나 파일 이름이 나오는지. 앞에 이름 글자가 붙어 있으면 다른 파일이다 (editor.js ≠ elice-content-editor.js) */
|
|
147
|
+
function mentions(path, text) {
|
|
148
|
+
const name = path.split('/').pop() ?? path;
|
|
149
|
+
const escape = x => x.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
150
|
+
return new RegExp(`(?<![\\w.-])(?:${escape(path)}|${escape(name)})`).test(text);
|
|
113
151
|
}
|
|
114
152
|
/** zip 안 JSON을 넣어 두고, 그 주소를 fetch하면 넣어 둔 내용을 돌려준다 */
|
|
115
153
|
function jsonPrelude(files, page) {
|
|
@@ -135,6 +173,8 @@ opts = {}) {
|
|
|
135
173
|
const byPath = new Map(files.map(f => [f.path, f]));
|
|
136
174
|
const pages = [];
|
|
137
175
|
const out = [];
|
|
176
|
+
const inputs = new Set();
|
|
177
|
+
const pageTexts = new Map();
|
|
138
178
|
for (const f of files) {
|
|
139
179
|
if (!/\.html?$/i.test(f.path)) {
|
|
140
180
|
out.push(f);
|
|
@@ -156,11 +196,17 @@ opts = {}) {
|
|
|
156
196
|
}
|
|
157
197
|
let next = '';
|
|
158
198
|
let last = 0;
|
|
199
|
+
let scan = '';
|
|
159
200
|
for (const [i, m] of scripts.entries()) {
|
|
160
201
|
const src = attr(m[1] ?? '', 'src') ?? '';
|
|
161
202
|
const entry = resolveRef(f.path, src.replace(/[?#].*$/, ''));
|
|
162
203
|
if (entry === null || !byPath.has(entry)) throw new Error(`${f.path}의 모듈 스크립트 파일이 없습니다: ${src}`);
|
|
163
|
-
const
|
|
204
|
+
const {
|
|
205
|
+
code,
|
|
206
|
+
inputs: used
|
|
207
|
+
} = await bundle(entry, f.path, byPath, opts);
|
|
208
|
+
for (const p of used) inputs.add(p);
|
|
209
|
+
scan += `${await withoutComments(f.path, html.slice(last, m.index))}\n${await scanText(code, used)}\n`;
|
|
164
210
|
next += html.slice(last, m.index);
|
|
165
211
|
if (i === 0) next += jsonPrelude(files, f.path);
|
|
166
212
|
// data-ecdk-bundle: 원본(ecdk-ignore 주석 포함)을 이미 검사했으니 zip 검사에서 이 본문은 다시 보지 않는다
|
|
@@ -168,7 +214,9 @@ opts = {}) {
|
|
|
168
214
|
last = (m.index ?? 0) + m[0].length;
|
|
169
215
|
}
|
|
170
216
|
next += html.slice(last);
|
|
217
|
+
scan += await withoutComments(f.path, html.slice(last));
|
|
171
218
|
pages.push(f.path);
|
|
219
|
+
pageTexts.set(f.path, scan);
|
|
172
220
|
out.push({
|
|
173
221
|
...f,
|
|
174
222
|
data: encoder.encode(next)
|
|
@@ -178,8 +226,59 @@ opts = {}) {
|
|
|
178
226
|
files: out,
|
|
179
227
|
report: {
|
|
180
228
|
pages
|
|
229
|
+
},
|
|
230
|
+
bundled: {
|
|
231
|
+
inputs,
|
|
232
|
+
pageTexts
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
/** 묶음에 남은 import(): 묶을 때 풀지 못한 것(변수 · 조합 주소)이라 어느 파일을 받는지 모른다 */
|
|
237
|
+
const DYNAMIC_IMPORT = /\bimport\s*\(/;
|
|
238
|
+
/**
|
|
239
|
+
* 묶어 넣은 원본 JS 중 다른 데서 이름이 나오지 않는 파일을 뺀다 (zip 크기 · 같은 코드 두 벌).
|
|
240
|
+
* 묶은 파일(.js · .mjs)마다, 남는 텍스트 파일(묶은 페이지는 BundledSources.pageTexts)에 경로나 파일 이름이 나오면 둔다:
|
|
241
|
+
* 일반 <script src> · new Worker('…') · fetch · HTML · CSS · 문자열로 조합한 주소. 둔 파일은 따로 받히므로 그 안의
|
|
242
|
+
* import도 찾아 계속 둔다. 묶음에 import()가 남았으면(변수 주소) 무엇을 받는지 몰라 하나도 빼지 않는다.
|
|
243
|
+
* metadata.json · 화면 진입 파일(HTML) · JSON · CSS는 JS가 아니라 대상이 아니다.
|
|
244
|
+
*/
|
|
245
|
+
async function dropBundledSources(files, bundled) {
|
|
246
|
+
const byPath = new Map(files.map(f => [f.path, f]));
|
|
247
|
+
const candidates = [...bundled.inputs].filter(p => /\.m?js$/i.test(p) && byPath.has(p));
|
|
248
|
+
if (candidates.length === 0) return {
|
|
249
|
+
files,
|
|
250
|
+
report: {
|
|
251
|
+
dropped: []
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
if ([...bundled.pageTexts.values()].some(t => DYNAMIC_IMPORT.test(t))) return {
|
|
255
|
+
files,
|
|
256
|
+
report: {
|
|
257
|
+
dropped: [],
|
|
258
|
+
keptAll: '묶은 코드에 주소를 조합하는 import()가 있어 어느 파일을 받는지 몰라 원본 JS를 모두 둡니다'
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
const isCandidate = new Set(candidates);
|
|
262
|
+
const texts = await Promise.all(files.filter(f => !isCandidate.has(f.path) && TEXT_FILE.test(f.path)).map(async f => bundled.pageTexts.get(f.path) ?? withoutComments(f.path, decoder.decode(f.data))));
|
|
263
|
+
const kept = new Set();
|
|
264
|
+
// 둔 파일의 글에서 다시 찾는다 (둔 파일은 따로 받히므로 그 안의 import도 받힌다)
|
|
265
|
+
for (let grew = true; grew;) {
|
|
266
|
+
grew = false;
|
|
267
|
+
for (const p of candidates) {
|
|
268
|
+
if (kept.has(p) || !texts.some(t => mentions(p, t))) continue;
|
|
269
|
+
kept.add(p);
|
|
270
|
+
texts.push(await withoutComments(p, decoder.decode(byPath.get(p)?.data)));
|
|
271
|
+
grew = true;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
const dropped = candidates.filter(p => !kept.has(p)).sort();
|
|
275
|
+
const gone = new Set(dropped);
|
|
276
|
+
return {
|
|
277
|
+
files: files.filter(f => !gone.has(f.path)),
|
|
278
|
+
report: {
|
|
279
|
+
dropped
|
|
181
280
|
}
|
|
182
281
|
};
|
|
183
282
|
}
|
|
184
283
|
|
|
185
|
-
export { BUNDLE_ATTR, inlineModuleScripts };
|
|
284
|
+
export { BUNDLE_ATTR, dropBundledSources, inlineModuleScripts };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { compareVersions } from '
|
|
1
|
+
import { compareVersions } from '../rules/semver.js';
|
|
2
2
|
export { compareVersions };
|
|
3
3
|
/** 다른 스킬이 ../elice-content-guide/topics/로 읽는 공유 개발 가이드 스킬 */
|
|
4
4
|
export declare const GUIDE_SKILL = "elice-content-guide";
|
|
@@ -65,19 +65,3 @@ export declare function install(opts: {
|
|
|
65
65
|
* Helpy Code 데스크톱은 바로 다시 읽는지 확인하지 못해 다시 시작하라고 한다
|
|
66
66
|
*/
|
|
67
67
|
export declare function reloadNotes(skillsDirCreated: boolean): string[];
|
|
68
|
-
export type PlannedAction = InstallResult['skills'][number]['action'] | 'would-install' | 'would-update';
|
|
69
|
-
/** --dry-run: 스킬 폴더를 쓰지 않고 install이 무엇을 할지만 */
|
|
70
|
-
export declare function planInstall(opts: {
|
|
71
|
-
project: boolean;
|
|
72
|
-
force: boolean;
|
|
73
|
-
cwd?: string | undefined;
|
|
74
|
-
home?: string | undefined;
|
|
75
|
-
root?: string | undefined;
|
|
76
|
-
version?: string | undefined;
|
|
77
|
-
}): {
|
|
78
|
-
dir: string;
|
|
79
|
-
skills: {
|
|
80
|
-
name: string;
|
|
81
|
-
action: PlannedAction;
|
|
82
|
-
}[];
|
|
83
|
-
};
|
|
@@ -4,17 +4,17 @@ import { mkdir, copyFile, writeFile } from 'node:fs/promises';
|
|
|
4
4
|
import { homedir } from 'node:os';
|
|
5
5
|
import { join, resolve, dirname, relative, sep } from 'node:path';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
|
-
import { compareVersions } from '
|
|
7
|
+
import { compareVersions } from '../rules/semver.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* 스킬 설치 · 상태 검사 (
|
|
10
|
+
* 스킬 설치 · 상태 검사 (ecdk setup · update · uninstall · doctor가 쓴다).
|
|
11
11
|
* 설치 위치는 ~/.claude/skills/ (모든 프로젝트) 또는 --project면 현재 폴더의 .claude/skills/.
|
|
12
12
|
*/
|
|
13
|
-
/** CLI 패키지의 skills/ (es/
|
|
14
|
-
const SKILLS_ROOT = fileURLToPath(new URL('
|
|
13
|
+
/** CLI 패키지의 skills/ (es/core/와 src/core/ 모두 두 단계 위) */
|
|
14
|
+
const SKILLS_ROOT = fileURLToPath(new URL('../../skills', import.meta.url));
|
|
15
15
|
/** 모든 스킬에 끼워 넣는 공통 규칙 */
|
|
16
16
|
const SHARED_DIR = '_shared';
|
|
17
|
-
const PACKAGE_VERSION = JSON.parse(readFileSync(fileURLToPath(new URL('
|
|
17
|
+
const PACKAGE_VERSION = JSON.parse(readFileSync(fileURLToPath(new URL('../../package.json', import.meta.url)), 'utf8')).version;
|
|
18
18
|
/** 설치한 스킬 맨 끝 줄. 버전 · 내용 지문으로 오래됨 · 손으로 고침을 알아본다 */
|
|
19
19
|
const STAMP = /<!-- ecdk-skill: (\S+) (\S+) (sha256-[A-Za-z0-9+/=]+) -->\s*$/;
|
|
20
20
|
/**
|
|
@@ -241,21 +241,5 @@ async function install(opts) {
|
|
|
241
241
|
function reloadNotes(skillsDirCreated) {
|
|
242
242
|
return [skillsDirCreated ? 'Claude Code: 이미 열려 있던 Claude Code 세션에서는 /reload-skills를 한 번 입력하세요 (새로 여는 세션은 필요 없음).' : 'Claude Code: 열려 있는 세션에도 바뀐 스킬이 자동으로 적용됩니다.', 'Helpy Code 데스크톱은 다시 시작하세요.'];
|
|
243
243
|
}
|
|
244
|
-
/** --dry-run: 스킬 폴더를 쓰지 않고 install이 무엇을 할지만 */
|
|
245
|
-
function planInstall(opts) {
|
|
246
|
-
const dir = skillsDir(opts);
|
|
247
|
-
const skills = skillNames(opts.root).map(name => {
|
|
248
|
-
const state = inspectSkill(dir, name, opts.version).state;
|
|
249
|
-
const action = state === 'missing' ? 'would-install' : state === 'current' ? 'skipped' : state === 'outdated' || opts.force ? 'would-update' : state === 'newer' ? 'newer' : 'kept';
|
|
250
|
-
return {
|
|
251
|
-
name,
|
|
252
|
-
action
|
|
253
|
-
};
|
|
254
|
-
});
|
|
255
|
-
return {
|
|
256
|
-
dir,
|
|
257
|
-
skills
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
244
|
|
|
261
|
-
export { GUIDE_SKILL, compareVersions, inspectSkill, install, isDotPath, markedSkillNames,
|
|
245
|
+
export { GUIDE_SKILL, compareVersions, inspectSkill, install, isDotPath, markedSkillNames, reloadNotes, removeSkillFiles, renderSkill, skillFiles, skillNames, skillsDir };
|
package/es/dev/grading.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare function matchesPattern(answerKey: unknown, answer: unknown): boo
|
|
|
15
15
|
* 템플릿 mock(`lib/cdk-mock.js`의 gradeLocally)과 같은 판정이다. 완료 정책은 LXP 설정이라 보지 않는다 (ADR 0012):
|
|
16
16
|
* 채점 설정이 있으면 채점하고, 없으면 제출만 받는다.
|
|
17
17
|
* - pattern: 답 문자열 전체를 정규식 하나로 비교 0 / 100
|
|
18
|
-
* - rubric: 흉내 점수 RUBRIC_DEV_SCORE, 통과로 본다 (통과 기준 pass_threshold는 정해지지
|
|
18
|
+
* - rubric: 흉내 점수 RUBRIC_DEV_SCORE, 통과로 본다 (통과 기준 pass_threshold는 정해지지 않음)
|
|
19
19
|
* - 채점 설정(편집 화면이 저장하는 settings.grading)이 없으면 제출만 받고 `{ null, null }`
|
|
20
20
|
*/
|
|
21
21
|
export declare function grade(local: LocalGrading | undefined, answer: unknown): GradeResult;
|
package/es/dev/grading.js
CHANGED
|
@@ -16,7 +16,7 @@ function matchesPattern(answerKey, answer) {
|
|
|
16
16
|
* 템플릿 mock(`lib/cdk-mock.js`의 gradeLocally)과 같은 판정이다. 완료 정책은 LXP 설정이라 보지 않는다 (ADR 0012):
|
|
17
17
|
* 채점 설정이 있으면 채점하고, 없으면 제출만 받는다.
|
|
18
18
|
* - pattern: 답 문자열 전체를 정규식 하나로 비교 0 / 100
|
|
19
|
-
* - rubric: 흉내 점수 RUBRIC_DEV_SCORE, 통과로 본다 (통과 기준 pass_threshold는 정해지지
|
|
19
|
+
* - rubric: 흉내 점수 RUBRIC_DEV_SCORE, 통과로 본다 (통과 기준 pass_threshold는 정해지지 않음)
|
|
20
20
|
* - 채점 설정(편집 화면이 저장하는 settings.grading)이 없으면 제출만 받고 `{ null, null }`
|
|
21
21
|
*/
|
|
22
22
|
function grade(local, answer) {
|
package/es/dev/host-page.js
CHANGED
|
@@ -142,7 +142,7 @@ function hostPage(opts) {
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
// 화면(learn · instructor · edit)은 검사기가 kindModes로 이미 걸러 state.entries에 켠 것만 온다.
|
|
145
|
-
// 문제 설명에는 학생 보기만 둔다: 다른 보기가 있는지는 서버 · LXP와 아직 정하지 않았다
|
|
145
|
+
// 문제 설명에는 학생 보기만 둔다: 다른 보기가 있는지는 서버 · LXP와 아직 정하지 않았다
|
|
146
146
|
const available = (s) => entryOf(s[2]) && (state.kind !== 'description' || s[0] === 'student');
|
|
147
147
|
function renderScenarios() {
|
|
148
148
|
scenariosEl.replaceChildren(...SCENARIOS.filter(available).map(([scenario, label]) => {
|
|
@@ -185,7 +185,7 @@ function hostPage(opts) {
|
|
|
185
185
|
? 'settings-saved: 저장했습니다. 다른 보기에서 material.settings로 받습니다 (내용 · 채점 방식 · 답은 .ecdk/settings.json)'
|
|
186
186
|
: 'settings-saved: 저장 실패 (' + payload.code + ')');
|
|
187
187
|
return;
|
|
188
|
-
// init의 불러오기
|
|
188
|
+
// init의 불러오기 상태. loading · ready는 매번 오므로 적지 않고, 실패만 적는다
|
|
189
189
|
// (LXP는 failed를 받으면 자기 실패 화면을 띄움: reason network · auth · config)
|
|
190
190
|
case 'status':
|
|
191
191
|
if (payload.state === 'failed')
|
package/es/rules/check.js
CHANGED
|
@@ -106,7 +106,7 @@ function checkLegacyFiles(opts, add) {
|
|
|
106
106
|
const SDK_UPDATE_COMMAND = 'npm update @eliceio/cdk';
|
|
107
107
|
/**
|
|
108
108
|
* SDK 버전 (ADR 0010). metadata.json build.sdk가 rules.json minVersions.sdk보다 낮으면 오류:
|
|
109
|
-
* LXP 프로토콜과 맞지 않아 저장 · 제출이 안 될 수 있다 (
|
|
109
|
+
* LXP 프로토콜과 맞지 않아 저장 · 제출이 안 될 수 있다 (alpha.3 이하는 LXP 편집 화면 초안 저장이 422). 옛 lib/cdk.js 복사본 프로젝트는 sdk.lib-copy 경고로 알린다
|
|
110
110
|
*/
|
|
111
111
|
function checkSdk(manifest, spec, opts, add) {
|
|
112
112
|
// 옛 머리말은 "1.0.0 (브랜치@커밋)"일 수 있어 첫 낱말만 비교한다
|
|
@@ -127,7 +127,7 @@ function blankBundles(html) {
|
|
|
127
127
|
return html.replace(/(<script\b[^>]*\sdata-ecdk-bundle\b[^>]*>)([\s\S]*?)(<\/script\s*>)/gi, (_, open, body, close) => open + body.replace(/[^\n]/g, '') + close);
|
|
128
128
|
}
|
|
129
129
|
/** ecdk가 넣는 lib/ 파일 (SDK · 키트). 작성자가 넣은 라이브러리가 아니라 ref.vendor-external-url에서 뺀다 */
|
|
130
|
-
const ECDK_LIB_FILES = new Set(['lib/cdk.js', 'lib/elice-content.js', 'lib/cdk-mock.js']);
|
|
130
|
+
const ECDK_LIB_FILES = new Set(['lib/cdk.js', 'lib/elice-content.js', 'lib/elice-content-editor.js', 'lib/cdk-mock.js']);
|
|
131
131
|
/** 작성자가 내려받아 넣은 라이브러리로 보는 폴더 · 파일 이름 */
|
|
132
132
|
const VENDOR_DIR = /^(?:vendors?|libs?|third[-_]?party|external|plugins?)$/i;
|
|
133
133
|
const VENDOR_FILE = /[.-]min\.m?js$/i;
|
|
@@ -231,7 +231,7 @@ function checkFiles(input, opts = {}) {
|
|
|
231
231
|
if (!exact.has(file)) add('manifest.entry-missing', `${spec.manifest.file}에 적은 ${mode} 화면 파일이 없습니다: ${file}`, spec.manifest.file);
|
|
232
232
|
}
|
|
233
233
|
const commentaryFile = manifest.commentary === undefined ? undefined : files.find(f => f.path === manifest.commentary);
|
|
234
|
-
// LXP 업로드는 학습 참고 내용이 없는 자료 본문을 거절한다 (
|
|
234
|
+
// LXP 업로드는 학습 참고 내용이 없는 자료 본문을 거절한다 (실제 업로드로 확인. 스펙은 선택이었음)
|
|
235
235
|
if ((manifest.kind ?? spec.manifest.defaultKind) !== 'description' && manifest.commentary === undefined) add('manifest.commentary-missing', `학습 참고 내용 파일이 없어 LXP 업로드가 거절됩니다. 프로젝트 맨 위에 ${spec.manifest.commentaryFile}(이 자료의 핵심 개념 · 활동 · 문제 의도, 정답 제외)을 만들고 ${spec.manifest.file}에 "commentary": "${spec.manifest.commentaryFile}"를 적어 주세요.`, spec.manifest.file);
|
|
236
236
|
if (manifest.commentary !== undefined && !commentaryFile) add('manifest.entry-missing', `${spec.manifest.file}에 적은 학습 참고 내용 파일이 없습니다: ${manifest.commentary}`, spec.manifest.file);
|
|
237
237
|
// LXP 학습 참고 내용 칸으로 옮길 텍스트라 UTF-8이어야 한다 (메모장 ANSI · EUC-KR 저장이면 깨짐)
|
package/es/rules/csp.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RulesSpec } from './types.js';
|
|
2
2
|
/**
|
|
3
|
-
* 운영 콘텐츠 응답 CSP 초안 (
|
|
3
|
+
* 운영 콘텐츠 응답 CSP 초안 (서버에 제안한 값).
|
|
4
4
|
* 서버 CSP가 확정되면 이 목록을 맞춘다. `ecdk dev` 콘텐츠 서버가 이 값으로 응답하고, CLI README가 같은 글을 보인다
|
|
5
5
|
* (`docs.test.ts`가 대조). 허용 외부 출처는 rules.json `externalAllow` 한 곳에서 해당 지시어에 더한다.
|
|
6
6
|
* - sandbox는 `allow-same-origin`까지 (LXP iframe 속성과 같게, 콘텐츠는 제 하위 도메인 출처로 돈다)
|
package/es/rules/csp.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { rules } from './spec.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* 운영 콘텐츠 응답 CSP 초안 (
|
|
4
|
+
* 운영 콘텐츠 응답 CSP 초안 (서버에 제안한 값).
|
|
5
5
|
* 서버 CSP가 확정되면 이 목록을 맞춘다. `ecdk dev` 콘텐츠 서버가 이 값으로 응답하고, CLI README가 같은 글을 보인다
|
|
6
6
|
* (`docs.test.ts`가 대조). 허용 외부 출처는 rules.json `externalAllow` 한 곳에서 해당 지시어에 더한다.
|
|
7
7
|
* - sandbox는 `allow-same-origin`까지 (LXP iframe 속성과 같게, 콘텐츠는 제 하위 도메인 출처로 돈다)
|
package/es/rules/index.d.ts
CHANGED
|
@@ -4,6 +4,6 @@ export { COMPLETION_POLICIES_IGNORED, graderTypeError, LEGACY_COMPLETION_FIELDS,
|
|
|
4
4
|
export { globToRegExp } from './path.js';
|
|
5
5
|
export { commentOnlyLines, lineSkipper } from './skip.js';
|
|
6
6
|
export { rules, RULES_VERSION } from './spec.js';
|
|
7
|
-
export { findUnreferenced } from './unused.js';
|
|
7
|
+
export { findUnreferenced, TEXT_FILE } from './unused.js';
|
|
8
8
|
export { filesFromHtml, filesFromZip, ZipLimitError } from './zip.js';
|
|
9
9
|
export type * from './types.js';
|
package/es/rules/index.js
CHANGED
|
@@ -4,5 +4,5 @@ export { COMPLETION_POLICIES_IGNORED, LEGACY_COMPLETION_FIELDS, LEGACY_COMPLETIO
|
|
|
4
4
|
export { globToRegExp } from './path.js';
|
|
5
5
|
export { commentOnlyLines, lineSkipper } from './skip.js';
|
|
6
6
|
export { RULES_VERSION, rules } from './spec.js';
|
|
7
|
-
export { findUnreferenced } from './unused.js';
|
|
7
|
+
export { TEXT_FILE, findUnreferenced } from './unused.js';
|
|
8
8
|
export { ZipLimitError, filesFromHtml, filesFromZip } from './zip.js';
|
package/es/rules/unused.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { ContentFile, Manifest } from './types.js';
|
|
2
|
+
/** 다른 파일 이름을 담을 수 있는 텍스트 파일 */
|
|
3
|
+
export declare const TEXT_FILE: RegExp;
|
|
2
4
|
/**
|
|
3
5
|
* 어디서도 이름이 나오지 않는 파일 (용량을 줄일 후보). 다른 텍스트 파일에 경로나 파일 이름이 한 번이라도
|
|
4
6
|
* 나오면 쓰는 것으로 본다: JS에서 `img/${n}.png`처럼 이름을 조합하면 못 찾으므로 일부러 넓게 본다.
|
package/es/rules/unused.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/** 다른 파일 이름을 담을 수 있는 텍스트 파일 */
|
|
2
|
+
const TEXT_FILE = /\.(?:html?|css|m?js|json|svg)$/i;
|
|
2
3
|
/**
|
|
3
4
|
* 어디서도 이름이 나오지 않는 파일 (용량을 줄일 후보). 다른 텍스트 파일에 경로나 파일 이름이 한 번이라도
|
|
4
5
|
* 나오면 쓰는 것으로 본다: JS에서 `img/${n}.png`처럼 이름을 조합하면 못 찾으므로 일부러 넓게 본다.
|
|
@@ -8,7 +9,7 @@ function findUnreferenced(files, manifest) {
|
|
|
8
9
|
const real = files.filter(f => !f.dir);
|
|
9
10
|
const entries = new Set(Object.values(manifest?.entries ?? {}));
|
|
10
11
|
const decoder = new TextDecoder();
|
|
11
|
-
const texts = real.filter(f =>
|
|
12
|
+
const texts = real.filter(f => TEXT_FILE.test(f.path)).map(f => ({
|
|
12
13
|
path: f.path,
|
|
13
14
|
text: decoder.decode(f.data)
|
|
14
15
|
}));
|
|
@@ -18,4 +19,4 @@ function findUnreferenced(files, manifest) {
|
|
|
18
19
|
}).map(f => f.path).sort();
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
export { findUnreferenced };
|
|
22
|
+
export { TEXT_FILE, findUnreferenced };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eliceio/cdk-cli",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.7",
|
|
4
4
|
"description": "교육자용 Custom HTML 콘텐츠 CLI",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"rollup": "^4.0.0",
|
|
41
41
|
"tslib": "^2.6.1",
|
|
42
42
|
"typescript": "~5.9.3",
|
|
43
|
-
"@eliceio/cdk": "^1.0.0-alpha.
|
|
43
|
+
"@eliceio/cdk": "^1.0.0-alpha.7"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"prebuild": "del-cli \"buildcache/*\" \"es/*\"",
|
|
@@ -14,7 +14,8 @@ Read guide topics with the Read tool from the sibling `elice-content-guide` skil
|
|
|
14
14
|
1. **Design before code.** Read `../elice-content-guide/topics/00-what-the-person-decides.md` (what the person decides) and `../elice-content-guide/topics/02-design-the-material.md`. Decide ① what the student does, ② whether the student submits and the grading (`type` `pattern` or `rubric`, set on the edit screen; the quiz template uses `pattern`, so do not ask for a quiz). Do not decide the completion policy: 완료 정책은 LXP에 올린 뒤 설정 탭에서 교육자가 고른다 (the instructor picks `on_access` · `on_submit` · `on_graded` in the LXP settings tab after the upload; do not write it in `metadata.json`). Only tell the person which policy fits, ③ the instructor screen, ④ the content edit screen, ⑤ the purpose. Decide what the request leaves out and tell the person briefly; ask only when the learning goal is unclear.
|
|
15
15
|
2. **Environment and project.** `ecdk --version && ecdk doctor --json` (`../elice-content-guide/topics/01-check-the-environment.md`; when `cli.latest` warns, offer `ecdk update` and run it only after the person agrees), then `ecdk create --list` to pick a template and `ecdk create <folder> --template <name>` (`../elice-content-guide/topics/03-create-the-project.md`; it runs `npm install` for the SDK, so when that fails run `npm install` in the project).
|
|
16
16
|
3. **Write the screens.** You build the template: screens and code (`../elice-content-guide/topics/05-screen-code.md`, following its UI patterns: kit icon buttons, list rows, drop zones; the quiz template: `../elice-content-guide/topics/06-using-the-quiz-template.md`), and `commentary.txt` (key concepts and intent, no answers). The real content and answers are entered in the LXP edit screen after upload; there is no default content file. In `ecdk dev`, try the edit and learn screens with a little sample input (saved only locally in `.ecdk/settings.json`, never uploaded); do not author the full question set locally.
|
|
17
|
-
-
|
|
17
|
+
- For a material that is not a quiz, start from the blank template and its content editor: design the content JSON shape and its schema first (`../elice-content-guide/topics/02-design-the-material.md` ④-1), put them in `screens/edit.js` (`useContentEditor(app, { initial, schema })`), then write the student screen against that shape. Replace the template's example everywhere it says `이 자료에 맞게 바꿀 곳`.
|
|
18
|
+
- If the person describes the content (for example "5 questions about perceptrons"), give it as draft text with the answers for the person to enter in the LXP edit screen. A quiz material holds one question, so several questions mean several quiz materials (pages). For a material built on the content editor, give the content as one JSON block in the schema's shape for the person to paste into 코드 보기 of the LXP edit screen (no graded answers in it).
|
|
18
19
|
4. **Check.** `ecdk validate`, fix errors (`../elice-content-guide/topics/08-fix-check-errors.md`), then `ecdk dev` and go through the screens (`../elice-content-guide/topics/09-check.md`). The person looks at the screens too.
|
|
19
20
|
5. **Build and report.** `ecdk build --json` must return `ok: true`. Report as `../elice-content-guide/topics/10-build.md` says.
|
|
20
21
|
6. **Upload** only after the person approves: the elice-content-publish skill (`../elice-content-guide/topics/12-upload-with-the-material-mcp.md`), or the person uploads `dist/content.zip` in LXP. Then the person enters the content and answers in the LXP edit screen and saves the page (the edit screen's button, then 저장 at the bottom of the LXP edit page; learners see it after that).
|
|
@@ -5,6 +5,6 @@ ecdk --version && ecdk doctor --json
|
|
|
5
5
|
```
|
|
6
6
|
|
|
7
7
|
- Without `ecdk`: it needs Node.js 20.19 or later (22 LTS recommended) and `@eliceio/cdk-cli`. Tell the user how to install it, and run **a global install (`npm install -g @eliceio/cdk-cli`) only after the user agrees**. Without agreement, run `npx @eliceio/cdk-cli <command>`.
|
|
8
|
-
- `doctor` item `mcp.material` warns when the Elice material server MCP is not registered. It is used later to upload to LXP (the elice-content-publish skill), so it is not needed to make a material. To register it, ask the user first, then run `ecdk setup` (installs the skills and registers the MCP in one go;
|
|
9
|
-
- `doctor` item `cli.latest` warns when npm `latest` has a newer ecdk (`skip` when offline). Tell the user and run `ecdk update` **only after the user agrees** (it runs a global install, refreshes the skills with the new ecdk and runs `npm update @eliceio/cdk` when the current folder is a project; `ecdk update --check` only shows the plan). It never downgrades. After it, Claude Code picks up the changed skills in open sessions; only when the output (or `--json` `skillsDirCreated: true`) says the skills folder was just created, a Claude Code session that was already open needs `/reload-skills` once. Helpy Code desktop needs a restart. If it fails with `EACCES`, show the manual command it prints.
|
|
8
|
+
- `doctor` item `mcp.material` warns when the Elice material server MCP is not registered. It is used later to upload to LXP (the elice-content-publish skill), so it is not needed to make a material. To register it, ask the user first, then run `ecdk setup` (installs the skills and registers the MCP in one go; `ecdk setup --only mcp` registers the MCP only) and tell the user the login step it prints.
|
|
9
|
+
- `doctor` item `cli.latest` warns when npm `latest` has a newer ecdk (`skip` when offline). Tell the user and run `ecdk update` **only after the user agrees** (it runs a global install, refreshes the skills with the new ecdk and runs `npm update @eliceio/cdk` when the current folder is a project; `ecdk update --check` only shows the plan; `ecdk update --project` when the skills are in the project's `.claude/skills/`). It never downgrades. After it, Claude Code picks up the changed skills in open sessions; only when the output (or `--json` `skillsDirCreated: true`) says the skills folder was just created, a Claude Code session that was already open needs `/reload-skills` once. Helpy Code desktop needs a restart. If it fails with `EACCES`, show the manual command it prints.
|
|
10
10
|
- Fix each `fail` item in `doctor` as its `fix.description` says. `--fix` fixes only the items that can be fixed automatically.
|
|
@@ -25,6 +25,8 @@ Read or watch / change values and observe (simulation, visualization) / follow s
|
|
|
25
25
|
|
|
26
26
|
**④ Does it need a content edit screen?** When instructors may want to rewrite text, numbers or lists (for example a simulation's initial values, a card list, step descriptions), keep them in the content the edit screen saves (`app.content`, the material's `settings`) and let the edit screen change them. There is no default content file: until the edit screen saves, `app.content` is `{}`, `app.hasContent` is false, and the student and instructor screens show `app.emptyState()` ("아직 내용이 없습니다 …"). Turn the edit screen off only when the material needs no content at all (everything is in the code).
|
|
27
27
|
|
|
28
|
+
**④-1 Design the content JSON shape** before the screens: the keys the student screen reads (for example `{ "title": "…", "unit": "km", "items": [{ "name": "수성", "value": 4879 }] }`), which are required, number ranges and list sizes. That shape becomes the schema of the kit's content editor (`useContentEditor`, see 5), so the edit screen needs no hand-written fields. Keep it small and flat, and keep graded answers out of it.
|
|
29
|
+
|
|
28
30
|
**⑤ Purpose**: the material itself (`kind: material`, the default), or the **problem description** of another material such as a practice (`kind: description`: student screen only, no grading).
|
|
29
31
|
|
|
30
32
|
**Steps inside one material (paging)**: LXP already draws a bar **under every material** with `< 이전 · 3/6 · 다음 >` that moves between **lecture pages** of the course. Inside the material, never draw a bottom bar with 이전 · 다음 (or "◀ 이전 · 2 / 6 · 다음 ▶") that looks like it: the student cannot tell which one moves the step and which one leaves the material. For a material with several steps (slides, STEP 1~5), use the kit's `app.usePaging` (see 5):
|
|
@@ -1,11 +1,11 @@
|
|
|
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.
|
|
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).
|
|
4
4
|
|
|
5
5
|
| Case | Start with |
|
|
6
6
|
| -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
7
7
|
| A quiz (one question per quiz material; several questions mean several quiz materials) | `ecdk create <folder>` (quiz template: starts with no question; the edit screen adds one question of any of the five types with "문항 추가"; answers set on the edit screen; `pattern` grading, `on_graded` picked in LXP) |
|
|
8
|
-
| Any other material | `ecdk create <folder> --template blank` (
|
|
8
|
+
| Any other material | `ecdk create <folder> --template blank` (three screens with a small example to replace, "예측하고 확인하기", and the kit content editor on the edit screen: see 5) |
|
|
9
9
|
| A dark screen | Add `--theme dark` to the above |
|
|
10
10
|
| A problem description | Create with blank, set `metadata.json` to `{ "kind": "description", "screens": { "learn": { "enabled": true, "entry": "index.html" } }, "commentary": "commentary.txt" }`, delete the other screen files |
|
|
11
11
|
| An existing HTML page | [7. Move existing HTML](07-move-existing-html.md) |
|
|
@@ -55,17 +55,49 @@ app.useSave({ getContent: () => app.content, getGrading: () => grading.getGradin
|
|
|
55
55
|
|
|
56
56
|
- Run simulations and animations with `requestAnimationFrame` and stop them while the view is hidden. Split heavy computation into small pieces.
|
|
57
57
|
|
|
58
|
+
### Content editor (JSON)
|
|
59
|
+
|
|
60
|
+
Design the **content JSON shape first** (for example `{ title, intro, unit, items: [{ name, value, note }] }`); the student and instructor screens only read that shape from `app.content`. Then the edit screen does not need hand-written fields: the kit's content editor draws them from the shape.
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
import { start } from '../lib/elice-content.js';
|
|
64
|
+
import { useContentEditor } from '../lib/elice-content-editor.js';
|
|
65
|
+
|
|
66
|
+
const app = await start({ screen: 'edit' });
|
|
67
|
+
const schema = {
|
|
68
|
+
title: { label: '제목', required: true },
|
|
69
|
+
items: {
|
|
70
|
+
label: '항목',
|
|
71
|
+
min: 2,
|
|
72
|
+
max: 12,
|
|
73
|
+
item: {
|
|
74
|
+
name: { label: '이름', required: true },
|
|
75
|
+
value: { label: '값', type: 'number', required: true },
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
// initial: the sample the editor starts from while nothing is saved (there is still no default content file)
|
|
80
|
+
const editor = useContentEditor(app, { initial: sample, schema });
|
|
81
|
+
app.useSave({ getContent: editor.getContent, validate: editor.validate });
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
- Two tabs. **폼 보기** (default) builds fields from the value: text → input (long text or `multiline` → textarea), number → number input, boolean → switch, `enum` → select, object → a group, list of text or numbers → rows, list of objects → cards. Lists add (a new item has the item shape with empty values), remove (a red ✕ on rows, trash on cards) with an undo notice (`.ec-notice` "항목을 삭제했습니다. 되돌리기", 6 s), reorder by dragging the `⠿` handle, the handle's ↑ · ↓ keys or the card's ↑ · ↓ buttons, and show "N개 이상이어야 합니다" at the minimum. **코드 보기** is the JSON text with colors, "정렬" (pretty print) and pasting; a syntax error shows line and column (`4줄 16칸: 쉼표(,)가 겹쳤습니다`), a schema error shows the path (`items[2].value: 숫자여야 합니다`). Going back to 폼 보기 applies the JSON only when it parses and has the right shape.
|
|
85
|
+
- Schema (optional, a plain object, name → field): `label` · `type` (`string` · `number` · `boolean` · `object` · `array`) · `required` · `min` · `max` (number range, or item count for a list) · `multiline` · `enum` · `hint` · `placeholder` · `item` (list item: one field, or name → field for objects) · `fields` (fields of a group). Without a schema the labels are the key names and the types come from `initial`, so a number in `initial` must stay a number.
|
|
86
|
+
- `validate` blocks the save: in 폼 보기 it shows the message under the field and focuses it (the save bar says `항목 3 › 값: 입력해 주세요`). Pass your own check as `useContentEditor(app, { validate: c => … || '…' })`. With the grader block add `getGrading` to `useSave` as above.
|
|
87
|
+
- Only the edit screen imports `lib/elice-content-editor.js`; `ecdk build` bundles code per screen, so the student screen does not carry it.
|
|
88
|
+
- Use the editor when the content is data (lists, numbers, short texts). Write a custom edit screen when editing needs its own UI (placing points on an image, a per-question answer UI like the quiz template). The content is visible to students: values the student screen reveals (like "정답 보기" of a self-check) may be in it, answers that are graded never are (`settings.grading`).
|
|
89
|
+
|
|
58
90
|
### UI patterns
|
|
59
91
|
|
|
60
92
|
Build screens from the kit's classes in `lib/elice-content.css` (EDS values, both themes) so every material looks and behaves the same. The quiz template follows these patterns; copy its markup from `ui/templates/`.
|
|
61
93
|
|
|
62
|
-
| Where | Pattern
|
|
63
|
-
| ------------------------------------------------- |
|
|
64
|
-
| Edit screen, a card for one item (question, step) | Title on the left, then a type `<select>` in regular weight. On the right, borderless icon buttons `button.ec-icon-button`: ↑ · ↓ · delete with a **trash** icon. Hide ↑ · ↓ when there is only one card.
|
|
65
|
-
| Edit screen, one row in a list (choice, group) | `⠿` drag handle → the answer control (radio or checkbox) → number → text input → remove with `button.ec-icon-button.ec-danger` (a red
|
|
66
|
-
| Student screen, an empty drop target | `.ec-dropzone`: a dashed box with an icon, a bold line `.ec-dropzone-title` (for example "보기를 여기로 끌어 놓으세요") and a hint `<p>` ("또는 보기를 누른 뒤 이곳을 눌러 주세요."). It also takes clicks, not only drops.
|
|
67
|
-
| Student screen, undo actions ("답안 초기화") | Show only when there is something to undo (for example at least one item placed), hide on read-only screens, and keep the row height fixed so nothing below jumps. Keep it away from the submit button.
|
|
68
|
-
| Any Korean text in a narrow box | `word-break: keep-all` so lines do not break inside a word.
|
|
94
|
+
| Where | Pattern |
|
|
95
|
+
| ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
96
|
+
| Edit screen, a card for one item (question, step) | Title on the left, then a type `<select>` in regular weight. On the right, borderless icon buttons `button.ec-icon-button`: ↑ · ↓ · delete with a **trash** icon. Hide ↑ · ↓ when there is only one card. |
|
|
97
|
+
| Edit screen, one row in a list (choice, group) | `⠿` drag handle → the answer control (radio or checkbox) → number → text input → remove with `button.ec-icon-button.ec-danger` (a red **✕**, no border). A wide answer control (a `<select>`) goes after the input instead. Disable remove at the minimum count. |
|
|
98
|
+
| Student screen, an empty drop target | `.ec-dropzone`: a dashed box with an icon, a bold line `.ec-dropzone-title` (for example "보기를 여기로 끌어 놓으세요") and a hint `<p>` ("또는 보기를 누른 뒤 이곳을 눌러 주세요."). It also takes clicks, not only drops. |
|
|
99
|
+
| Student screen, undo actions ("답안 초기화") | Show only when there is something to undo (for example at least one item placed), hide on read-only screens, and keep the row height fixed so nothing below jumps. Keep it away from the submit button. |
|
|
100
|
+
| Any Korean text in a narrow box | `word-break: keep-all` so lines do not break inside a word. |
|
|
69
101
|
|
|
70
102
|
Icon buttons always need `aria-label`. Icons are inline SVG with `stroke="currentColor"`, so color follows the button:
|
|
71
103
|
|
|
@@ -84,18 +116,17 @@ Icon buttons always need `aria-label`. Icons are inline SVG with `stroke="curren
|
|
|
84
116
|
>
|
|
85
117
|
<path d="M4 7h16M10 11v6M14 11v6M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2l1-12M9 7V4h6v3" />
|
|
86
118
|
</svg>
|
|
87
|
-
<!--
|
|
119
|
+
<!-- ✕ (remove one row) -->
|
|
88
120
|
<svg
|
|
89
121
|
viewBox="0 0 24 24"
|
|
90
|
-
width="
|
|
91
|
-
height="
|
|
122
|
+
width="18"
|
|
123
|
+
height="18"
|
|
92
124
|
fill="none"
|
|
93
125
|
stroke="currentColor"
|
|
94
|
-
stroke-width="
|
|
126
|
+
stroke-width="2"
|
|
95
127
|
stroke-linecap="round"
|
|
96
128
|
aria-hidden="true"
|
|
97
129
|
>
|
|
98
|
-
<
|
|
99
|
-
<path d="M8 12h8" />
|
|
130
|
+
<path d="M6 6l12 12M18 6L6 18" />
|
|
100
131
|
</svg>
|
|
101
132
|
```
|
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
ecdk build --json
|
|
5
5
|
```
|
|
6
6
|
|
|
7
|
-
- With `ok: true` the zip is `dist/content.zip`.
|
|
7
|
+
- With `ok: true` the zip is `dist/content.zip`. The build minifies by default (comments do not reach learners' browsers, quiz template about 113 KB → 83 KB) and leaves out the original JS files it bundled into the HTML when nothing else names them (`bundled.dropped` in `--json`). Turn minifying off only to debug, with `"minify": false` in `package.json` `"ecdk"`.
|
|
8
8
|
- Report to the user: what the material is (what the student does, which screens are on, how it completes), the zip path and size, **what to pick in the LXP settings tab** (the completion policy that fits, which the instructor picks there, the grading type, and where the answers are set), the upload steps (Custom HTML material in LXP → upload the zip → settings tab → save → check the student and instructor screens), and anything left to check. Saving makes the new version visible to learners at once, so the person approves it first (see [0. What the person decides](00-what-the-person-decides.md)).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 12. Upload with the material MCP
|
|
2
2
|
|
|
3
|
-
The `elice-material` MCP server (elice-material backend) uploads a built zip to a LXP Custom page and saves it as a new version. Register it with `ecdk setup` (
|
|
3
|
+
The `elice-material` MCP server (elice-material backend) uploads a built zip to a LXP Custom page and saves it as a new version. Register it with `ecdk setup` (MCP only: `ecdk setup --only mcp`) and log in once per tool (Claude Code `/mcp` → elice-material → Authenticate, Helpy Code `⌘ ;`). Every page tool takes `org` (the organization's `name_short`, the subdomain of `https://{org}.elice.io`) and `lecture_page_id`.
|
|
4
4
|
|
|
5
5
|
**Confirm the target page.** Never upload to a page the person has not explicitly confirmed. Before any upload call (`create_package_upload`, `submit_package`), show the full target, 기관 · 과목 · 수업 · 페이지 (names and ids), and its LXP edit URL, then wait for an explicit yes. This holds every time: also when `.ecdk/link.json` exists and when the person gave a URL (confirm the names it resolves to). `.ecdk/link.json` and an edit URL give only the org's `name_short`: get the 기관 name from `list_my_organizations` and the 과목 · 수업 · 페이지 names from `get_material`. Never pick a page yourself (not the first in a list, not a guess by title, not a page from another project); if the answer is ambiguous, ask again. Creating a page (`create_custom_page`) needs its own yes that names the 수업 it goes into.
|
|
6
6
|
|
|
@@ -22,7 +22,7 @@ The `elice-material` MCP server (elice-material backend) uploads a built zip to
|
|
|
22
22
|
After a successful save, write `.ecdk/link.json` in the project (it is not put in the zip; add `.ecdk/` to `.gitignore`):
|
|
23
23
|
|
|
24
24
|
```json
|
|
25
|
-
{ "org": "
|
|
25
|
+
{ "org": "my-school", "lecture_page_id": 129, "version_id": "…" }
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
Next time, read it, confirm the page with the person as above (기관 · 과목 · 수업 · 페이지 and the URL), and compare `version_id` with `get_material`'s `current_version.id`: if they differ, someone saved in LXP since — tell the person before uploading.
|
|
@@ -11,7 +11,7 @@ Read guide topics with the Read tool from the sibling `elice-content-guide` skil
|
|
|
11
11
|
|
|
12
12
|
## Steps
|
|
13
13
|
|
|
14
|
-
1. **MCP ready?** The `elice-material` tools must be available. If not, ask the person to run `ecdk setup --only mcp`
|
|
14
|
+
1. **MCP ready?** The `elice-material` tools must be available. If not, ask the person to run `ecdk setup --only mcp` and log in (Claude Code `/mcp` → elice-material → Authenticate, Helpy Code `⌘ ;`), then stop.
|
|
15
15
|
2. **Build.** `ecdk build --json` must return `ok: true`. Keep `zip` and `zipBytes`.
|
|
16
16
|
3. **Pick the page and confirm it.** Candidates: `.ecdk/link.json`, the LXP edit URL the person gives (`https://{org}.…/lecturepages/{id}/edit`), or the person's choice from `list_my_organizations` → `list_courses` → `list_lectures` → `list_custom_pages`. Never pick a page yourself (not the first in a list, not a guess by title, not a page from another project); if the answer is ambiguous, ask again. Before any upload call (`create_package_upload`, `submit_package`), show the full target, 기관 · 과목 · 수업 · 페이지 with names and ids, and its LXP edit URL, then wait for an explicit yes. Do this every time: also for `.ecdk/link.json` (and compare its `version_id` with `get_material`) and for a URL the person gave (confirm the names it resolves to). `.ecdk/link.json` and an edit URL give only the org's `name_short`: get the 기관 name from `list_my_organizations` and the 과목 · 수업 · 페이지 names from `get_material`. A new page (`create_custom_page`) needs its own yes that names the 수업 it goes into.
|
|
17
17
|
4. **Upload.** `get_material` (keep `current_version.id`) → `create_package_upload` with `size_bytes = zipBytes` → run its `curl_command` with `package.zip` replaced by the zip path → `submit_package` → poll `get_draft` until ready or failed. On failure, report the server's reason with `ecdk validate dist/content.zip` and stop.
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* - 시나리오: 주소에 ?mock=session_expired | rate_limited | request_failed | external_service_error
|
|
18
18
|
* | slow | content_not_ready | unauthorized | draft_not_ready
|
|
19
19
|
*
|
|
20
|
-
* 실제 SDK: @eliceio/cdk 1.x
|
|
20
|
+
* 실제 SDK: @eliceio/cdk 1.x 기준
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
export const ErrorCode = Object.freeze({
|
|
@@ -125,7 +125,7 @@ export function normalizeGradingSettings(grading) {
|
|
|
125
125
|
* elice-material 채점 흉내 (채점 방식 → 점수). 실제 서버처럼 요청 안에서 바로 채점한 `{ isCorrect, score }`만
|
|
126
126
|
* 돌려준다. 완료 정책은 LXP 설정이라 보지 않는다 (ADR 0012): 채점 설정이 있으면 채점하고, 없으면 제출만 받는다.
|
|
127
127
|
* - pattern: 정답 정규식(문자열 하나)이 답 문자열 전체와 맞으면 100, 아니면 0
|
|
128
|
-
* - rubric: 바로 80점으로 흉내, 통과로 봄 (통과 기준 pass_threshold는 정해지지
|
|
128
|
+
* - rubric: 바로 80점으로 흉내, 통과로 봄 (통과 기준 pass_threshold는 정해지지 않음)
|
|
129
129
|
* - 채점 설정 없음: 점수 없음 `{ isCorrect: null, score: null }`
|
|
130
130
|
* @param {object | null} grading settings.grading
|
|
131
131
|
* @param {unknown} answer
|