@eliceio/cdk-cli 0.1.0-alpha.2 → 0.1.0-alpha.4

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 (103) hide show
  1. package/README.md +263 -191
  2. package/es/cli.js +93 -33
  3. package/es/commands/build/index.d.ts +1 -1
  4. package/es/commands/build/index.js +21 -12
  5. package/es/commands/check/index.d.ts +11 -2
  6. package/es/commands/check/index.js +51 -5
  7. package/es/commands/create/index.d.ts +6 -0
  8. package/es/commands/create/index.js +56 -8
  9. package/es/commands/create/install.d.ts +17 -0
  10. package/es/commands/create/install.js +53 -0
  11. package/es/commands/create/scaffold.d.ts +6 -1
  12. package/es/commands/create/scaffold.js +27 -17
  13. package/es/commands/dev/index.d.ts +1 -1
  14. package/es/commands/dev/index.js +6 -2
  15. package/es/commands/doctor/index.d.ts +21 -0
  16. package/es/commands/doctor/index.js +255 -38
  17. package/es/commands/mcp/index.d.ts +134 -0
  18. package/es/commands/mcp/index.js +399 -0
  19. package/es/commands/setup/index.d.ts +40 -0
  20. package/es/commands/setup/index.js +157 -0
  21. package/es/commands/skill/index.d.ts +2 -5
  22. package/es/commands/skill/index.js +1 -29
  23. package/es/core/collect.d.ts +5 -2
  24. package/es/core/config.d.ts +141 -31
  25. package/es/core/config.js +341 -59
  26. package/es/core/manifest.d.ts +2 -1
  27. package/es/core/manifest.js +2 -1
  28. package/es/core/minify.js +2 -2
  29. package/es/core/prepare.d.ts +18 -2
  30. package/es/core/prepare.js +47 -18
  31. package/es/core/project-check.d.ts +26 -0
  32. package/es/core/project-check.js +53 -0
  33. package/es/core/sandbox.js +2 -2
  34. package/es/core/sdk.d.ts +39 -0
  35. package/es/core/sdk.js +95 -0
  36. package/es/core/templates.d.ts +25 -0
  37. package/es/core/templates.js +41 -0
  38. package/es/dev/grading.d.ts +14 -7
  39. package/es/dev/grading.js +27 -13
  40. package/es/dev/host-page.d.ts +1 -1
  41. package/es/dev/host-page.js +34 -34
  42. package/es/dev/mock-api.d.ts +19 -4
  43. package/es/dev/mock-api.js +75 -9
  44. package/es/dev/server.d.ts +7 -0
  45. package/es/dev/server.js +112 -32
  46. package/es/rules/check.js +95 -10
  47. package/es/rules/index.d.ts +1 -1
  48. package/es/rules/index.js +1 -1
  49. package/es/rules/manifest.d.ts +23 -9
  50. package/es/rules/manifest.js +60 -35
  51. package/es/rules/node.js +3 -1
  52. package/es/rules/semver.d.ts +5 -0
  53. package/es/rules/semver.js +32 -0
  54. package/es/rules/types.d.ts +38 -7
  55. package/es/rules.json.js +2 -2
  56. package/es/test-packages.d.ts +7 -0
  57. package/guides/content-development.md +150 -55
  58. package/package.json +3 -3
  59. package/rules.json +77 -7
  60. package/skills/_shared/always.md +4 -2
  61. package/skills/elice-content-check/SKILL.md +3 -1
  62. package/skills/elice-content-create/SKILL.md +5 -4
  63. package/skills/elice-content-migrate/SKILL.md +2 -2
  64. package/skills/elice-content-publish/SKILL.md +23 -0
  65. package/templates/_shared/lib/cdk-mock.d.ts +21 -3
  66. package/templates/_shared/lib/cdk-mock.js +241 -82
  67. package/templates/_shared/lib/elice-content.css +204 -0
  68. package/templates/_shared/lib/elice-content.d.ts +115 -6
  69. package/templates/_shared/lib/elice-content.js +656 -43
  70. package/templates/blank/README.md +19 -7
  71. package/templates/blank/completion.html +15 -0
  72. package/templates/blank/gitignore +1 -0
  73. package/templates/blank/metadata.json +11 -0
  74. package/templates/blank/package.json +13 -0
  75. package/templates/blank/screens/completion.js +7 -0
  76. package/templates/blank/screens/edit.js +3 -0
  77. package/templates/blank/screens/instructor.js +12 -5
  78. package/templates/blank/screens/learn.js +16 -11
  79. package/templates/blank/template.json +6 -0
  80. package/templates/quiz/README.md +41 -31
  81. package/templates/quiz/core/behaviors.d.ts +5 -0
  82. package/templates/quiz/core/behaviors.js +12 -0
  83. package/templates/quiz/core/editor.d.ts +12 -1
  84. package/templates/quiz/core/editor.js +28 -5
  85. package/templates/quiz/core/model.d.ts +41 -1
  86. package/templates/quiz/core/model.js +272 -5
  87. package/templates/quiz/gitignore +1 -0
  88. package/templates/quiz/metadata.json +11 -0
  89. package/templates/quiz/package.json +13 -0
  90. package/templates/quiz/screens/edit.js +176 -46
  91. package/templates/quiz/screens/instructor.js +18 -12
  92. package/templates/quiz/screens/learn.js +43 -38
  93. package/templates/quiz/styles.css +47 -0
  94. package/templates/quiz/template.json +6 -0
  95. package/templates/quiz/ui/templates/edit.d.ts +3 -0
  96. package/templates/quiz/ui/templates/edit.js +53 -14
  97. package/templates/quiz/ui/texts.js +56 -29
  98. package/templates/_shared/lib/cdk.js +0 -3
  99. package/templates/blank/content.json +0 -4
  100. package/templates/blank/elice.config.json +0 -12
  101. package/templates/quiz/content.json +0 -81
  102. package/templates/quiz/elice.config.json +0 -14
  103. package/templates/quiz/grading.json +0 -13
@@ -0,0 +1,157 @@
1
+ import { checkNode, checkSkills, checkMcp } from '../doctor/index.js';
2
+ import { defaultMcpEnv, resolveUrl, formatSetupLines, NEEDS_PERSON, setup } from '../mcp/index.js';
3
+ import { skillsDir, install, skillNames, inspectSkill } from '../skill/index.js';
4
+
5
+ const usage = `사용법: ecdk setup [--env prod|qa5] [--url <주소>] [--target claude|helpycode|all] [--dry-run] [--force] [--json]
6
+
7
+ 처음 한 번 실행한다. 차례로:
8
+ 1. 스킬 설치 (ecdk skill install과 같음, ~/.claude/skills/)
9
+ 2. 학습자료 서버 MCP 등록 (ecdk mcp setup과 같음, 옵션도 같음)
10
+ 3. 점검 요약 (Node · 스킬 · MCP)
11
+ 4. 도구별 로그인 안내
12
+ MCP는 아직 배포되지 않았거나 직접 할 일이 있어도 실패로 치지 않는다 ("직접 할 일"에 적음, 스킬이 쓸 수 있으면 종료 코드 0).
13
+ --force는 MCP 등록에만 쓴다. 손으로 고친 스킬까지 바꾸려면 ecdk skill install --force.
14
+
15
+ 종료 코드: 0 스킬 설치됨(MCP는 직접 할 일이 남아도) · 1 스킬을 설치하지 못함 · 2 잘못된 사용`;
16
+ const SKILL_ACTION = {
17
+ installed: '설치',
18
+ updated: '바꿈',
19
+ skipped: '최신이라 건너뜀',
20
+ kept: '손으로 고친 스킬이라 그대로 둠',
21
+ newer: 'CLI보다 새 버전이라 그대로 둠',
22
+ 'would-install': '설치할 예정',
23
+ 'would-update': '바꿀 예정'
24
+ };
25
+ /** --dry-run: 스킬 폴더를 쓰지 않고 무엇을 할지만 */
26
+ function planSkills(home) {
27
+ const dir = skillsDir({
28
+ project: false,
29
+ home
30
+ });
31
+ return skillNames().map(name => {
32
+ const state = inspectSkill(dir, name).state;
33
+ const action = state === 'missing' ? 'would-install' : state === 'outdated' ? 'would-update' : state === 'current' ? 'skipped' : state === 'newer' ? 'newer' : 'kept';
34
+ return {
35
+ name,
36
+ action
37
+ };
38
+ });
39
+ }
40
+ async function setupAll(opts) {
41
+ const {
42
+ env
43
+ } = opts;
44
+ let skills;
45
+ if (opts.dryRun) {
46
+ skills = {
47
+ ok: true,
48
+ dir: skillsDir({
49
+ project: false,
50
+ home: env.home
51
+ }),
52
+ version: '',
53
+ items: planSkills(env.home)
54
+ };
55
+ } else {
56
+ try {
57
+ const r = await install({
58
+ project: false,
59
+ force: false,
60
+ home: env.home
61
+ });
62
+ skills = {
63
+ ok: true,
64
+ dir: r.dir,
65
+ version: r.version,
66
+ items: r.skills.map(s => ({
67
+ name: s.name,
68
+ action: s.action
69
+ }))
70
+ };
71
+ } catch (e) {
72
+ skills = {
73
+ ok: false,
74
+ error: e.message
75
+ };
76
+ }
77
+ }
78
+ const mcp = await setup({
79
+ env,
80
+ envName: opts.envName,
81
+ url: opts.url,
82
+ target: opts.target,
83
+ dryRun: opts.dryRun,
84
+ force: opts.force
85
+ });
86
+ const checks = [checkNode(opts.nodeVersion ?? process.version), checkSkills(env.home, env.home), checkMcp(env)];
87
+ const todo = [];
88
+ if (!skills.ok) todo.push(`스킬을 설치하지 못했습니다: ${skills.error}`);else if (skills.items.some(s => s.action === 'kept')) todo.push('손으로 고친 스킬이 있어 그대로 두었습니다. 바꾸려면 ecdk skill install --force');
89
+ {
90
+ if (mcp.targets.length === 0) todo.push('MCP: Claude Code나 Helpy Code를 찾지 못했습니다. 설치한 뒤 ecdk setup을 다시 실행하세요.');
91
+ for (const s of mcp.steps) {
92
+ if (s.action === 'unreachable') todo.push(`MCP(${s.target}): 아직 배포되지 않아 건너뜀 (배포 뒤 ecdk setup 다시 실행). QA는 --env qa5`);else if (NEEDS_PERSON.includes(s.action)) todo.push(`MCP(${s.target}): ${s.message}`);
93
+ }
94
+ }
95
+ return {
96
+ skills,
97
+ mcp,
98
+ checks,
99
+ todo
100
+ };
101
+ }
102
+ async function run(args) {
103
+ const target = args.target ?? 'all';
104
+ if (target !== 'claude' && target !== 'helpycode' && target !== 'all') return {
105
+ exitCode: 2,
106
+ output: `--target은 claude · helpycode · all 중 하나입니다.\n\n${usage}`
107
+ };
108
+ const env = args.env ?? defaultMcpEnv();
109
+ const resolved = resolveUrl(args, env);
110
+ if (!resolved.ok) return {
111
+ exitCode: 2,
112
+ output: `${resolved.error}\n\n${usage}`
113
+ };
114
+ const result = await setupAll({
115
+ env,
116
+ envName: resolved.envName,
117
+ url: resolved.url,
118
+ target,
119
+ dryRun: args.dryRun,
120
+ force: args.force,
121
+ nodeVersion: args.nodeVersion
122
+ });
123
+ // 스킬이 쓸 수 있으면 성공: MCP는 publish 스킬 전까지 쓰지 않고, 배포 전 · 주석 있는 설정은 사람이 나중에 해도 됨
124
+ const exitCode = result.skills.ok ? 0 : 1;
125
+ if (args.json) return {
126
+ exitCode,
127
+ output: JSON.stringify(result, null, 2)
128
+ };
129
+ const lines = [];
130
+ lines.push(`1. 스킬${args.dryRun ? ' (미리보기)' : ''}`);
131
+ if (result.skills.ok) {
132
+ lines.push(` 위치: ${result.skills.dir}${result.skills.version ? ` (ecdk ${result.skills.version})` : ''}`);
133
+ for (const s of result.skills.items) lines.push(` ${s.name}: ${SKILL_ACTION[s.action] ?? s.action}`);
134
+ } else lines.push(` 설치하지 못함: ${result.skills.error}`);
135
+ lines.push('', '2. 학습자료 서버 MCP');
136
+ {
137
+ if (result.mcp.targets.length === 0) lines.push(' Claude Code · Helpy Code를 찾지 못함');else lines.push(...formatSetupLines(result.mcp, resolved.source, args.dryRun).map(l => ` ${l}`));
138
+ }
139
+ lines.push('', '3. 점검');
140
+ for (const c of result.checks) lines.push(` [${c.level}] ${c.id.padEnd(16)} ${c.message}`);
141
+ // 등록했거나(할 예정이거나) 이미 등록된 도구가 있을 때만 로그인 안내 (배포 전이면 할 수 없음)
142
+ if (result.mcp.steps.some(s => !NEEDS_PERSON.includes(s.action))) {
143
+ lines.push('', '4. 로그인 (MCP를 등록한 도구에서, 자료를 LXP에 올릴 때 필요)');
144
+ for (const l of result.mcp.login) lines.push(` - ${l}`);
145
+ }
146
+ if (result.todo.length > 0) {
147
+ lines.push('', '직접 할 일');
148
+ for (const t of result.todo) lines.push(` - ${t}`);
149
+ }
150
+ lines.push('', result.skills.ok ? 'Claude Code · Helpy Code를 새로 열거나 /reload-skills를 입력하면 스킬이 적용됩니다.' : '스킬 설치가 끝나지 않았습니다. 위 오류를 확인하세요.');
151
+ return {
152
+ exitCode,
153
+ output: lines.join('\n')
154
+ };
155
+ }
156
+
157
+ export { run, setupAll, usage };
@@ -1,4 +1,6 @@
1
+ import { compareVersions } from '../../rules/semver.js';
1
2
  import type { CommandResult } from '../../types.js';
3
+ export { compareVersions };
2
4
  export declare const usage = "\uC0AC\uC6A9\uBC95: ecdk skill install [--project] [--force] [--json]\n\n Claude Code\uAC00 Elice \uD559\uC2B5\uC790\uB8CC \uC694\uCCAD\uC744 \uC54C\uC544\uBCF4\uACE0 ecdk guide\uB97C \uC77D\uAC8C \uD558\uB294 \uC2A4\uD0AC(stub)\uC744 \uC124\uCE58\uD55C\uB2E4.\n \uAE30\uBCF8\uC740 ~/.claude/skills/ (\uBAA8\uB4E0 \uD504\uB85C\uC81D\uD2B8), --project\uBA74 \uD604\uC7AC \uD3F4\uB354\uC758 .claude/skills/.\n \uAC19\uC740 \uBC84\uC804\uC774\uBA74 \uAC74\uB108\uB6F0\uACE0, \uC61B \uBC84\uC804\uC774\uBA74 \uBC14\uAFBC\uB2E4. CLI\uBCF4\uB2E4 \uC0C8 \uBC84\uC804\uC774\uAC70\uB098 \uC190\uC73C\uB85C \uACE0\uCE5C \uC2A4\uD0AC\uC740 --force\uC77C \uB54C\uB9CC \uBC14\uAFBC\uB2E4.\n\n\uC885\uB8CC \uCF54\uB4DC: 0 \uC131\uACF5 \u00B7 1 \uC190\uC73C\uB85C \uACE0\uCE5C \uC2A4\uD0AC\uC774 \uC788\uC5B4 \uAC74\uB108\uB700 \u00B7 2 \uC798\uBABB\uB41C \uC0AC\uC6A9";
3
5
  export type SkillState = 'missing' | 'current' | 'outdated' | 'newer' | 'modified';
4
6
  export interface SkillStatus {
@@ -8,11 +10,6 @@ export interface SkillStatus {
8
10
  /** 설치된 스킬의 버전 (없으면 undefined) */
9
11
  version?: string | undefined;
10
12
  }
11
- /**
12
- * semver 순서로 a가 b보다 앞이면 음수, 뒤면 양수, 같으면 0. 읽을 수 없는 버전은 undefined.
13
- * 정식 버전은 같은 숫자의 pre-release보다 뒤 (1.0.0-alpha.1 < 1.0.0)
14
- */
15
- export declare function compareVersions(a: string, b: string): number | undefined;
16
13
  /** 패키지에 든 스킬 이름 (공통 폴더 제외) */
17
14
  export declare function skillNames(root?: string): string[];
18
15
  /** 원본에 공통 규칙과 버전 줄을 넣는다. 지문은 버전 줄을 뺀 본문으로 */
@@ -4,6 +4,7 @@ import { mkdir, writeFile } from 'node:fs/promises';
4
4
  import { homedir } from 'node:os';
5
5
  import { join, resolve } from 'node:path';
6
6
  import { fileURLToPath } from 'node:url';
7
+ import { compareVersions } from '../../rules/semver.js';
7
8
 
8
9
  const usage = `사용법: ecdk skill install [--project] [--force] [--json]
9
10
 
@@ -20,35 +21,6 @@ const PACKAGE_VERSION = JSON.parse(readFileSync(fileURLToPath(new URL('../../../
20
21
  /** 설치한 스킬 맨 끝 줄. 버전 · 내용 지문으로 오래됨 · 손으로 고침을 알아본다 */
21
22
  const STAMP = /<!-- ecdk-skill: (\S+) (\S+) (sha256-[A-Za-z0-9+/=]+) -->\s*$/;
22
23
  const sha = text => `sha256-${createHash('sha256').update(text).digest('base64')}`;
23
- const SEMVER = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/;
24
- /**
25
- * semver 순서로 a가 b보다 앞이면 음수, 뒤면 양수, 같으면 0. 읽을 수 없는 버전은 undefined.
26
- * 정식 버전은 같은 숫자의 pre-release보다 뒤 (1.0.0-alpha.1 < 1.0.0)
27
- */
28
- function compareVersions(a, b) {
29
- const pa = SEMVER.exec(a);
30
- const pb = SEMVER.exec(b);
31
- if (!pa || !pb) return undefined;
32
- for (let i = 1; i <= 3; i++) {
33
- const d = Number(pa[i]) - Number(pb[i]);
34
- if (d !== 0) return d;
35
- }
36
- if (pa[4] === pb[4]) return 0;
37
- if (pa[4] === undefined) return 1;
38
- if (pb[4] === undefined) return -1;
39
- const xa = pa[4].split('.');
40
- const xb = pb[4].split('.');
41
- for (let i = 0; i < Math.min(xa.length, xb.length); i++) {
42
- const [x = '', y = ''] = [xa[i], xb[i]];
43
- if (x === y) continue;
44
- const nx = /^\d+$/.test(x);
45
- const ny = /^\d+$/.test(y);
46
- if (nx && ny) return Number(x) - Number(y);
47
- if (nx !== ny) return nx ? -1 : 1;
48
- return x < y ? -1 : 1;
49
- }
50
- return xa.length - xb.length;
51
- }
52
24
  /** 패키지에 든 스킬 이름 (공통 폴더 제외) */
53
25
  function skillNames(root = SKILLS_ROOT) {
54
26
  return readdirSync(root, {
@@ -4,8 +4,11 @@ export interface SourceFile {
4
4
  }
5
5
  export interface Excluded {
6
6
  path: string;
7
- /** link: 심볼릭 링크 등 일반 파일 · 폴더가 아닌 항목 (따라가지 않고 빼되 보고는 한다) */
8
- reason: 'secret' | 'dev' | 'junk' | 'project' | 'config' | 'link';
7
+ /**
8
+ * link: 심볼릭 링크 등 일반 파일 · 폴더가 아닌 항목 (따라가지 않고 빼되 보고는 한다).
9
+ * sdk: 옛 lib/cdk.js 복사본. package.json의 @eliceio/cdk(설치된 SDK)를 대신 넣는다
10
+ */
11
+ reason: 'secret' | 'dev' | 'junk' | 'project' | 'config' | 'link' | 'sdk';
9
12
  }
10
13
  /**
11
14
  * 원본 폴더에서 콘텐츠 파일만 모은다. 정답·비밀·개발용·OS 파일, 프로젝트 파일, 산출물 폴더, 설정의 exclude를 뺀다.
@@ -1,25 +1,61 @@
1
1
  /**
2
- * 채점 유형. 원본은 rules.json `manifest.gradingTypes`이고, 타입 검사(오타 · 막아 둔 manual)를 위해 여기 리터럴로 둔다.
3
- * 둘이 같은지는 docs.test.ts가 대조한다. 수동 채점 manual · 채점 없음 none은 Custom HTML에서 쓰지 않음
2
+ * 완료 정책 (ADR 0009). 원본은 rules.json `manifest.completionPolicies`이고, 타입 검사를 위해 여기 리터럴로 둔다.
3
+ * 둘이 같은지는 docs.test.ts가 대조한다. 수동 채점 manual · 채점 없음 none은 Custom HTML에서 쓰지 않음.
4
+ * 자료가 지원하는 완료 정책은 metadata `completionPolicies`(서버가 첫 값으로 정함), 바꾸기는 완료 정책 화면 · SDK
5
+ * `saveCompletionPolicy`(PATCH completion_policy). settings.grading에는 없다
4
6
  */
5
- export declare const GRADING_TYPES: readonly ["on_access", "on_submit", "pattern", "rubric"];
6
- export type GradingType = (typeof GRADING_TYPES)[number];
7
+ export declare const COMPLETION_POLICIES: readonly ["on_access", "on_submit", "on_graded"];
7
8
  /**
8
- * 로컬 채점 설정(유형 · 정답 · 채점 기준). 프로젝트 맨 위 `grading.json`에 적는다. LXP 채점 설정에서 교육자가 고르고
9
- * 넣는 값과 같다. zip에는 들어가지 않는다 (운영은 LXP 채점 설정). CLI · mock의 로컬 채점에만 쓴다.
9
+ * 채점 방식 = `settings.grading.type` (on_graded일 때만). 원본은 rules.json `manifest.graderTypes`.
10
+ * pattern: 정답 정규식 · rubric: AI 평가 기준. code_exec는 이번 범위 밖
10
11
  */
11
- export interface GradingData {
12
- /** 로컬에서 흉내 낼 유형 (gradingTypes 중 하나). 없으면 gradingTypes의 첫 유형 */
13
- type?: GradingType;
14
- match?: 'exact' | 'regex';
15
- answer_key?: unknown;
12
+ export declare const GRADER_TYPES: readonly ["pattern", "rubric"];
13
+ export type CompletionPolicy = (typeof COMPLETION_POLICIES)[number];
14
+ export type GraderType = (typeof GRADER_TYPES)[number];
15
+ /**
16
+ * 채점 설정 = 운영 `settings.grading` (서버 §5.1 스키마, 2026-11-11 결정). 편집 화면이 saveSettings로 저장한다.
17
+ * 로컬은 `ecdk dev`의 편집 화면이 저장한 settings(`.ecdk/settings.json`)의 grading뿐이다 (grading.json은 없앰, ADR 0011).
18
+ *
19
+ * { "type": "pattern", "answer_key": "^q1=b;q2=a,d$" } // 정규식 하나. 답 문자열 앞뒤 공백을 자르고 전체 일치
20
+ * { "type": "rubric", "rubric": "핵심 개념 2개 이상 언급하면 만점" }
21
+ *
22
+ * on_access · on_submit은 grading에서 빠졌다 (완료 정책은 completion_policy, 2026-11-11).
23
+ */
24
+ export interface GradingConfig {
25
+ type: GraderType;
26
+ /** pattern: 정답 정규식 (문자열 하나) */
27
+ answer_key?: string;
28
+ /** rubric: 평가 기준 */
16
29
  rubric?: string;
17
30
  }
18
- /** 로컬 채점에 쓰는 값: grading.json에 유형을 채운 것. elice-material `material_version.grading`과 같은 모양 */
19
- export interface GradingConfig extends GradingData {
20
- type: GradingType;
31
+ /** 로컬 채점 흉내에 쓰는 값: 완료 정책(로컬 `.ecdk/completion.json` · completionPolicies 첫 값)과 채점 설정(`.ecdk/settings.json` grading) */
32
+ export interface LocalGrading {
33
+ completion_policy: CompletionPolicy;
34
+ /** `ecdk dev` 편집 화면이 저장한 settings.grading (없으면 null) */
35
+ grading: GradingConfig | null;
21
36
  }
22
- export declare const GRADING_DATA_FILE = "grading.json";
37
+ /**
38
+ * 로컬 settings (dev 전용): `ecdk dev` 편집 화면의 saveSettings(PATCH settings)를 흉내 서버가 통째로(내용 + grading) 여기에 쓴다.
39
+ * 운영은 서버 material_version.settings. 프로젝트의 점(.) 폴더라 zip에 들어가지 않는다. build · check는 읽지 않는다
40
+ */
41
+ export declare const SETTINGS_DATA_FILE = ".ecdk/settings.json";
42
+ /**
43
+ * 로컬 완료 정책 (dev 전용): `ecdk dev` 완료 정책 화면의 saveCompletionPolicy를 흉내 서버가 여기에 쓴다.
44
+ * 운영은 서버 material_version.completion_policy. 프로젝트의 점(.) 폴더라 zip에 들어가지 않는다
45
+ */
46
+ export declare const COMPLETION_DATA_FILE = ".ecdk/completion.json";
47
+ /** completionPolicies가 없을 때(검사 오류) ecdk dev가 흉내 내는 정책 (제출하면 완료) */
48
+ export declare const DEFAULT_COMPLETION_POLICY: CompletionPolicy;
49
+ /**
50
+ * 채점 설정 값 검사 (편집 화면이 저장한 settings.grading). 문제가 있으면 문장, 없으면 GradingConfig.
51
+ * 옛 모양(`type: on_access · on_submit`, `completion_policy` · `grader_type`, `match` · 객체 정답)은 바꾸는 법을 알려 준다.
52
+ */
53
+ export declare function parseGrading(data: unknown): GradingConfig | string;
54
+ /**
55
+ * 프로젝트 설정 (ADR 0011). 빌드 옵션은 package.json `"ecdk"` 키, 플랫폼 필드(kind · screens · completionPolicies ·
56
+ * commentary)는 작성자가 쓰는 원본의 metadata.json(build가 그대로 복사하고 build만 채움)에 둔다.
57
+ * kind · completionPolicies는 dev · doctor가 쓰도록 metadata.json에서 읽어 둔 값이다 (옛 프로젝트는 elice.config.json에서).
58
+ */
23
59
  export interface ContentConfig {
24
60
  /** 콘텐츠 원본 폴더 (프로젝트 기준). 기본 '.' */
25
61
  root: string;
@@ -27,29 +63,103 @@ export interface ContentConfig {
27
63
  outDir: string;
28
64
  /** 추가로 뺄 파일·폴더 (basename glob `*` 또는 프로젝트 기준 경로 접두사) */
29
65
  exclude: string[];
30
- /** 용도 → metadata.json `kind`. material: 자료 본문(기본) · description: 다른 자료(실습 등)의 문제 설명 */
31
- kind?: 'material' | 'description';
32
- /** 화면별 진입 파일 → build가 metadata.json로 만든다. 없으면 원본의 metadata.json, 그것도 없으면 { learn: 'index.html' } */
33
- screens?: Record<string, string>;
34
- /** 이 자료가 지원하는 채점 유형 → metadata.json `gradingTypes` (자료 본문은 필수). 로컬 채점 유형 · 정답은 grading.json */
35
- gradingTypes?: GradingType[];
36
66
  /** true면 build가 JS · CSS · JSON을 줄여 zip에 넣는다 (용량 줄이기). 기본 false */
37
67
  minify?: boolean;
38
- /**
39
- * 학습 참고 내용 파일 이름 (원본 최상위 .txt). 기본 rules.json `manifest.commentaryFile`(commentary.txt)이 있으면 그것.
40
- * zip에 그대로 들어가고 build가 metadata.json `commentary`에 이름을 적는다
41
- */
42
- commentary?: string;
43
68
  /** minify와 함께: 줄인 JS · CSS마다 .map을 zip에 넣어 운영에서도 원본 위치로 오류를 본다 (용량이 늘어남) */
44
69
  sourcemap?: boolean;
45
- /** ecdk create가 적는 템플릿과 버전 (예: "quiz@0.1.0"). metadata.json build.template으로 */
70
+ /** ecdk create가 적는 템플릿과 버전 (예: "quiz@1.0.0"). metadata.json build.template으로 */
46
71
  template?: string;
72
+ /** 설정을 읽은 파일. 없으면 기본값 (프로젝트 설정 없음) */
73
+ configFile?: typeof PACKAGE_FILE | typeof CONFIG_FILE;
74
+ /** metadata.json `kind` (dev · doctor용으로 읽어 둔 값). material: 자료 본문(기본) · description: 문제 설명 */
75
+ kind?: 'material' | 'description';
76
+ /** metadata.json `completionPolicies` (dev · doctor용으로 읽어 둔 값, 첫 값이 기본) */
77
+ completionPolicies?: CompletionPolicy[];
78
+ /**
79
+ * 옛 elice.config.json에서 읽은 플랫폼 필드 (ADR 0011 전). 있으면 build가 이것으로 metadata.json을 만들고
80
+ * project.legacy-file이 옮기는 법을 알린다 (`ecdk doctor --fix`). 새 프로젝트에는 없다
81
+ */
82
+ legacy?: LegacyPlatformFields;
47
83
  }
84
+ /** 옛 elice.config.json의 플랫폼 필드 (metadata.json으로 옮길 것) */
85
+ export interface LegacyPlatformFields {
86
+ kind?: 'material' | 'description';
87
+ /** 켤 화면만 파일 이름으로: { "learn": "index.html" } */
88
+ screens?: Record<string, string>;
89
+ completionPolicies?: CompletionPolicy[];
90
+ /** 학습 참고 내용 파일 이름. 없으면 commentary.txt가 있을 때 그것 */
91
+ commentary?: string;
92
+ /** @deprecated 2026-11-10 삭제 (ADR 0008 · 0009). 경고만 하고 옮기지 않는다 */
93
+ gradingTypes?: unknown;
94
+ }
95
+ /** 옛 설정 파일 (ADR 0011에서 없앰). 있으면 경고하고 `ecdk doctor --fix`가 옮긴다. zip에는 들어가지 않는다 */
48
96
  export declare const CONFIG_FILE = "elice.config.json";
49
- /** 1단계는 JSON만. `.ts` 설정은 Node 20의 TS 실행 지원 문제로 엔진 작업(3단계)과 함께 결정. */
97
+ export declare const PACKAGE_FILE = "package.json";
98
+ /** package.json에서 ecdk 빌드 옵션을 담는 키 */
99
+ export declare const PACKAGE_CONFIG_KEY = "ecdk";
100
+ /** package.json "ecdk"에 적을 수 있는 키 */
101
+ export declare const BUILD_OPTION_KEYS: readonly ["template", "root", "outDir", "exclude", "minify", "sourcemap"];
102
+ /** metadata.json에 적는 플랫폼 필드 (package.json "ecdk" · 옛 elice.config.json에 있으면 옮기라고 알림) */
103
+ export declare const PLATFORM_KEYS: readonly ["kind", "screens", "completionPolicies", "commentary"];
104
+ /** package.json을 읽는다 (없으면 null). JSON 형식이 틀리면 오류 */
105
+ export declare function readPackageJson(projectDir: string): Promise<Record<string, unknown> | null>;
106
+ /**
107
+ * 프로젝트 설정 (ADR 0011): package.json "ecdk"(빌드 옵션) → 없으면 옛 elice.config.json → 없으면 기본값.
108
+ * kind · completionPolicies는 원본 metadata.json에서 읽는다 (옛 elice.config.json이면 거기서).
109
+ * 둘 다 있으면 package.json "ecdk"를 쓰고 elice.config.json은 남은 옛 파일로 경고만 한다
110
+ */
50
111
  export declare function loadConfig(projectDir: string): Promise<ContentConfig>;
112
+ /** 옮기기 계획 (ecdk doctor --fix). 옮길 수 없으면 reason */
113
+ export interface LegacyMigration {
114
+ /** 옮길 수 있는지. 아니면 reason에 이유 */
115
+ ok: boolean;
116
+ reason?: string;
117
+ /** package.json "ecdk"에 더할 빌드 옵션 */
118
+ ecdk: Record<string, unknown>;
119
+ /** 새로 쓸 metadata.json (원본 폴더 기준 경로 · 내용). 이미 있으면 null */
120
+ metadata: {
121
+ path: string;
122
+ text: string;
123
+ } | null;
124
+ /** 옮기지 않고 버리는 것 (gradingTypes) */
125
+ dropped: string[];
126
+ }
127
+ /**
128
+ * 옛 elice.config.json을 metadata.json + package.json "ecdk"로 옮기는 계획 (ADR 0011). 디스크는 바꾸지 않는다.
129
+ * 플랫폼 필드는 build가 만들던 것과 같은 metadata.json으로(학습 참고 내용은 commentary.txt가 있으면), 빌드 옵션 · template은
130
+ * package.json "ecdk"로 (이미 있는 키는 그대로). 원본에 metadata.json이 이미 있는데 플랫폼 필드도 있으면 옮기지 않는다
131
+ */
132
+ export declare function planLegacyMigration(projectDir: string): Promise<LegacyMigration>;
133
+ /**
134
+ * 계획대로 옮긴다: metadata.json을 쓰고, package.json "ecdk"에 빌드 옵션을 더하고(package.json이 없으면 만듦),
135
+ * elice.config.json을 지운다. 옮긴 파일 목록을 돌려준다
136
+ */
137
+ export declare function applyLegacyMigration(projectDir: string, plan: LegacyMigration): Promise<string[]>;
138
+ /** elice.config.json에 옛 `gradingTypes`가 남아 있을 때 build · doctor가 보여 줄 경고. 없으면 null */
139
+ export declare function legacyGradingTypesWarning(config: ContentConfig): string | null;
140
+ /**
141
+ * 로컬 완료 정책 (ecdk dev 흉내): `.ecdk/completion.json`(ecdk dev 완료 정책 화면이 저장)이 completionPolicies 안에
142
+ * 있으면 그것, 아니면 completionPolicies 첫 값(서버가 업로드 때 정하는 값), 없으면 on_submit.
143
+ * completionPolicies가 바뀌어 저장해 둔 값이 목록에서 빠졌으면 첫 값으로 돌아간다
144
+ */
145
+ export declare function loadCompletionPolicy(projectDir: string, config: ContentConfig): Promise<CompletionPolicy>;
146
+ /**
147
+ * `ecdk dev` 편집 화면이 저장한 settings (`.ecdk/settings.json`, 없으면 {}). 흉내 서버가 시작할 때 읽어 다시 열어도 남는다.
148
+ * 형식이 틀리면 오류
149
+ */
150
+ export declare function loadSavedSettings(projectDir: string): Promise<Record<string, unknown>>;
151
+ /** 저장한 settings의 grading (없으면 null). 형식이 틀리면 오류 */
152
+ export declare function savedGrading(settings: Record<string, unknown>): GradingConfig | null;
153
+ /**
154
+ * 로컬 채점 흉내용 값: 완료 정책 + `.ecdk/settings.json`의 grading. 문제 설명(채점 없음)은 undefined
155
+ */
156
+ export declare function loadGrading(projectDir: string, config: ContentConfig): Promise<LocalGrading | undefined>;
51
157
  /**
52
- * 로컬 채점용 설정: grading.json(있으면) + 유형. 유형은 grading.json `type`, 없으면 gradingTypes의 첫 유형.
53
- * 지원 유형이 없으면(문제 설명) undefined.
158
+ * 더 쓰지 않는 프로젝트 파일 (ADR 0011). 있으면 build · check가 경고(project.legacy-file)하고 옮기는 법을 알려 준다.
159
+ * content.json은 원본 폴더(root), 그 밖은 프로젝트 맨 위
54
160
  */
55
- export declare function loadGrading(projectDir: string, config: ContentConfig): Promise<GradingConfig | undefined>;
161
+ export declare const LEGACY_FILES: Readonly<{
162
+ config: "elice.config.json";
163
+ content: "content.json";
164
+ grading: "grading.json";
165
+ }>;