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

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 (107) hide show
  1. package/README.md +215 -152
  2. package/es/cli.js +65 -66
  3. package/es/commands/build/index.d.ts +1 -1
  4. package/es/commands/build/index.js +20 -7
  5. package/es/commands/create/index.d.ts +1 -1
  6. package/es/commands/create/index.js +5 -9
  7. package/es/commands/dev/index.d.ts +1 -1
  8. package/es/commands/dev/index.js +5 -5
  9. package/es/commands/doctor/index.d.ts +18 -1
  10. package/es/commands/doctor/index.js +137 -27
  11. package/es/commands/mcp/index.d.ts +0 -12
  12. package/es/commands/mcp/index.js +6 -57
  13. package/es/commands/setup/index.d.ts +11 -3
  14. package/es/commands/setup/index.js +112 -37
  15. package/es/commands/skill/index.d.ts +46 -8
  16. package/es/commands/skill/index.js +151 -35
  17. package/es/commands/uninstall/index.d.ts +54 -0
  18. package/es/commands/uninstall/index.js +304 -0
  19. package/es/commands/update/index.d.ts +59 -0
  20. package/es/commands/update/index.js +251 -0
  21. package/es/commands/{check → validate}/index.d.ts +1 -1
  22. package/es/commands/{check → validate}/index.js +1 -1
  23. package/es/core/collect.js +1 -1
  24. package/es/core/config.d.ts +20 -37
  25. package/es/core/config.js +36 -89
  26. package/es/core/latest.d.ts +21 -0
  27. package/es/core/latest.js +43 -0
  28. package/es/core/prepare.js +4 -3
  29. package/es/core/project-check.d.ts +2 -2
  30. package/es/core/project-check.js +2 -2
  31. package/es/core/sandbox.js +6 -3
  32. package/es/core/templates.d.ts +1 -3
  33. package/es/core/templates.js +1 -4
  34. package/es/dev/grading.d.ts +7 -8
  35. package/es/dev/grading.js +6 -16
  36. package/es/dev/host-page.d.ts +1 -1
  37. package/es/dev/host-page.js +29 -12
  38. package/es/dev/inject.d.ts +6 -0
  39. package/es/dev/inject.js +16 -1
  40. package/es/dev/mock-api.d.ts +8 -12
  41. package/es/dev/mock-api.js +50 -81
  42. package/es/dev/server.d.ts +4 -2
  43. package/es/dev/server.js +18 -29
  44. package/es/rules/check.js +80 -41
  45. package/es/rules/csp.d.ts +26 -0
  46. package/es/rules/csp.js +42 -0
  47. package/es/rules/index.d.ts +2 -1
  48. package/es/rules/index.js +2 -1
  49. package/es/rules/manifest.d.ts +28 -20
  50. package/es/rules/manifest.js +58 -55
  51. package/es/rules/refs.d.ts +12 -2
  52. package/es/rules/refs.js +50 -18
  53. package/es/rules/types.d.ts +6 -13
  54. package/es/rules.json.js +2 -2
  55. package/package.json +2 -3
  56. package/rules.json +48 -57
  57. package/skills/_shared/always.md +5 -4
  58. package/skills/elice-content-check/SKILL.md +10 -9
  59. package/skills/elice-content-create/SKILL.md +7 -7
  60. package/skills/elice-content-guide/SKILL.md +42 -0
  61. package/skills/elice-content-guide/topics/00-what-the-person-decides.md +11 -0
  62. package/skills/elice-content-guide/topics/01-check-the-environment.md +10 -0
  63. package/skills/elice-content-guide/topics/02-design-the-material.md +35 -0
  64. package/skills/elice-content-guide/topics/03-create-the-project.md +22 -0
  65. package/skills/elice-content-guide/topics/04-rules.md +14 -0
  66. package/skills/elice-content-guide/topics/05-screen-code.md +101 -0
  67. package/skills/elice-content-guide/topics/06-using-the-quiz-template.md +22 -0
  68. package/skills/elice-content-guide/topics/07-move-existing-html.md +10 -0
  69. package/skills/elice-content-guide/topics/08-fix-check-errors.md +27 -0
  70. package/skills/elice-content-guide/topics/09-check.md +11 -0
  71. package/skills/elice-content-guide/topics/10-build.md +8 -0
  72. package/skills/elice-content-guide/topics/11-more.md +4 -0
  73. package/skills/elice-content-guide/topics/12-upload-with-the-material-mcp.md +41 -0
  74. package/skills/elice-content-migrate/SKILL.md +10 -8
  75. package/skills/elice-content-publish/SKILL.md +8 -8
  76. package/templates/_shared/lib/cdk-mock.d.ts +5 -13
  77. package/templates/_shared/lib/cdk-mock.js +41 -136
  78. package/templates/_shared/lib/elice-content.css +81 -1
  79. package/templates/_shared/lib/elice-content.d.ts +6 -37
  80. package/templates/_shared/lib/elice-content.js +23 -236
  81. package/templates/blank/README.md +5 -6
  82. package/templates/blank/metadata.json +1 -3
  83. package/templates/blank/package.json +2 -2
  84. package/templates/blank/screens/edit.js +1 -1
  85. package/templates/blank/template.json +2 -2
  86. package/templates/quiz/README.md +4 -4
  87. package/templates/quiz/core/behaviors.js +4 -1
  88. package/templates/quiz/core/editor.d.ts +11 -9
  89. package/templates/quiz/core/editor.js +32 -32
  90. package/templates/quiz/core/model.js +3 -3
  91. package/templates/quiz/metadata.json +1 -3
  92. package/templates/quiz/package.json +2 -2
  93. package/templates/quiz/screens/edit.js +121 -29
  94. package/templates/quiz/screens/learn.js +5 -2
  95. package/templates/quiz/styles.css +96 -37
  96. package/templates/quiz/template.json +2 -2
  97. package/templates/quiz/ui/templates/edit.d.ts +4 -0
  98. package/templates/quiz/ui/templates/edit.js +69 -19
  99. package/templates/quiz/ui/templates/group.js +10 -2
  100. package/templates/quiz/ui/templates/page.js +1 -2
  101. package/templates/quiz/ui/templates/text.js +10 -7
  102. package/templates/quiz/ui/texts.js +14 -12
  103. package/es/commands/guide/index.d.ts +0 -29
  104. package/es/commands/guide/index.js +0 -120
  105. package/guides/content-development.md +0 -302
  106. package/templates/blank/completion.html +0 -15
  107. package/templates/blank/screens/completion.js +0 -7
package/es/dev/grading.js CHANGED
@@ -12,24 +12,14 @@ function matchesPattern(answerKey, answer) {
12
12
  }
13
13
  }
14
14
  /**
15
- * elice-material 채점 흉내 (ADR 0009: 완료 정책 → 채점 방식 → 점수). 채점은 모두 요청 안에서 끝난다.
16
- * 템플릿 mock(`lib/cdk-mock.js`의 gradeLocally)과 같은 판정이다.
17
- * - on_access: 열면 완료, 제출은 점수 없음 `{ null, null }`
18
- * - on_submit: 제출하면 100
19
- * - on_graded + pattern: 답 문자열 전체를 정규식 하나로 비교 0 / 100
20
- * - on_graded + rubric: 흉내 점수 RUBRIC_DEV_SCORE, 통과로 본다 (통과 기준 pass_threshold는 정해지지 않음, G136)
21
- * - on_graded인데 답(편집 화면이 저장하는 settings.grading)이 아직 없으면 채점할 수 없어 `{ null, null }`
15
+ * elice-material 채점 흉내 (채점 방식 → 점수). 채점은 모두 요청 안에서 끝난다.
16
+ * 템플릿 mock(`lib/cdk-mock.js`의 gradeLocally)과 같은 판정이다. 완료 정책은 LXP 설정이라 보지 않는다 (ADR 0012):
17
+ * 채점 설정이 있으면 채점하고, 없으면 제출만 받는다.
18
+ * - pattern: 답 문자열 전체를 정규식 하나로 비교 0 / 100
19
+ * - rubric: 흉내 점수 RUBRIC_DEV_SCORE, 통과로 본다 (통과 기준 pass_threshold는 정해지지 않음, G136)
20
+ * - 채점 설정(편집 화면이 저장하는 settings.grading)이 없으면 제출만 받고 `{ null, null }`
22
21
  */
23
22
  function grade(local, answer) {
24
- const policy = local?.completion_policy ?? 'on_submit';
25
- if (policy === 'on_access') return {
26
- isCorrect: null,
27
- score: null
28
- };
29
- if (policy === 'on_submit') return {
30
- isCorrect: true,
31
- score: 100
32
- };
33
23
  const grading = local?.grading;
34
24
  if (grading?.type === 'pattern') {
35
25
  const ok = matchesPattern(grading.answer_key, answer);
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * LXP 학습 · 편집 페이지 흉내. 보기를 바꾸고 콘텐츠를 sandbox iframe으로 띄우며,
3
- * @eliceio/cdk가 보내는 postMessage(settings-saved · navigate-*)를 받아 처리한다
3
+ * @eliceio/cdk가 보내는 postMessage(status · settings-saved · navigate-*)를 받아 처리한다
4
4
  */
5
5
  export declare function hostPage(opts: {
6
6
  title: string;
@@ -1,8 +1,9 @@
1
+ import { DEV_MESSAGE_SOURCE } from './inject.js';
1
2
  import { DEV_MATERIAL_ID } from './mock-api.js';
2
3
 
3
4
  /**
4
5
  * LXP 학습 · 편집 페이지 흉내. 보기를 바꾸고 콘텐츠를 sandbox iframe으로 띄우며,
5
- * @eliceio/cdk가 보내는 postMessage(settings-saved · navigate-*)를 받아 처리한다
6
+ * @eliceio/cdk가 보내는 postMessage(status · settings-saved · navigate-*)를 받아 처리한다
6
7
  */
7
8
  function hostPage(opts) {
8
9
  return `<!doctype html>
@@ -75,19 +76,19 @@ function hostPage(opts) {
75
76
  </header>
76
77
  <div id="check">검사 중…</div>
77
78
  <pre id="messages" aria-live="polite"></pre>
78
- <main><iframe id="content" sandbox="allow-scripts" title="콘텐츠"></iframe></main>
79
+ <main><iframe id="content" sandbox="allow-scripts allow-same-origin" title="콘텐츠"></iframe></main>
79
80
  <script type="module">
80
81
  const MATERIAL_ID = ${JSON.stringify(DEV_MATERIAL_ID)};
81
82
  const SDK_SOURCE = 'eliceio-content-sdk';
83
+ // ecdk dev가 콘텐츠 HTML에 넣는 스크립트(inject.ts)의 메시지: 콘텐츠 CSP가 막은 요청
84
+ const DEV_SOURCE = ${JSON.stringify(DEV_MESSAGE_SOURCE)};
82
85
  // [보기, 이름, 화면, 주소 조각]. token은 흉내 서버가 발급. 내용 편집은 LXP처럼 저장된 버전을 edit 토큰으로 연다
83
86
  const SCENARIOS = [
84
87
  ['student', '학생', 'learn', 'token'],
85
88
  ['tutor', '튜터링', 'learn', 'token'],
86
89
  ['instructor', '교육자 화면', 'instructor', 'token'],
87
90
  ['edit', '내용 편집', 'edit', 'token'],
88
- // 완료 정책 화면 (ADR 0009): LXP 설정 탭처럼 edit 토큰 + screen=completionPolicy. screens.completionPolicy를 켠
89
- // 자료에서만 보인다 (퀴즈처럼 completionPolicies가 하나면 없음). 저장하면 .ecdk/completion.json, 채점 방식 · 답은 내용 편집
90
- ['completionPolicy', '완료 정책', 'completionPolicy', 'token'],
91
+ // 완료 정책 보기는 없다: 완료 정책은 LXP에 올린 뒤 설정 탭에서 교육자가 고른다 (ADR 0012)
91
92
  ];
92
93
  // 토큰 없는 미리보기(#preview=1)는 settings가 비고 늘 100점이라 학생 보기와 구분이 안 돼 보기 버튼에서 빼고,
93
94
  // SDK 기능 안의 도구로만 연다 (SDK · 키트는 이 상태를 따로 다룸: isDraftPreview, "기록되지 않음" 안내)
@@ -117,8 +118,11 @@ function hostPage(opts) {
117
118
  // 교육자 화면은 instructor 진입 파일이 없으면 학생 화면을 연다 (@eliceio/cdk resolveScreen과 같음)
118
119
  const entryOf = (screen) => state.entries[screen] || (screen === 'instructor' ? state.entries.learn : undefined);
119
120
 
121
+ // 막힌 외부 요청은 콘텐츠를 열 때마다 한 번씩만 적는다
122
+ let blocked = new Set();
120
123
  async function open(scenario) {
121
124
  current = scenario;
125
+ blocked = new Set();
122
126
  try { sessionStorage.setItem('ecdk-scenario', scenario); } catch {}
123
127
  for (const b of scenariosEl.children) b.setAttribute('aria-pressed', String(b.dataset.scenario === scenario));
124
128
  previewEl.setAttribute('aria-pressed', String(scenario === PREVIEW[0]));
@@ -129,7 +133,7 @@ function hostPage(opts) {
129
133
  const url = state.contentBase + entry + '?ecdk=' + Date.now();
130
134
  if (fragment === 'token') {
131
135
  const { token } = await (await fetch('/__ecdk/token?scenario=' + scenario)).json();
132
- frame.src = url + '#token=' + token + '&baseUrl=' + BASE_URL + (screen === 'completionPolicy' ? '&screen=completionPolicy' : '');
136
+ frame.src = url + '#token=' + token + '&baseUrl=' + BASE_URL;
133
137
  } else {
134
138
  frame.src = url + '#' + fragment + '&baseUrl=' + BASE_URL;
135
139
  }
@@ -137,7 +141,7 @@ function hostPage(opts) {
137
141
  (state.kind === 'description' ? '문제 설명 · ' : '') + entry + ' · ' + (TOOLS.some((t) => t[0] === scenario) ? label : scenario);
138
142
  }
139
143
 
140
- // 화면(learn · instructor · edit · completionPolicy)은 검사기가 kindModes로 이미 걸러 state.entries에 켠 것만 온다.
144
+ // 화면(learn · instructor · edit)은 검사기가 kindModes로 이미 걸러 state.entries에 켠 것만 온다.
141
145
  // 문제 설명에는 학생 보기만 둔다: 다른 보기가 있는지는 서버 · LXP와 아직 정하지 않았다 (progress G81)
142
146
  const available = (s) => entryOf(s[2]) && (state.kind !== 'description' || s[0] === 'student');
143
147
  function renderScenarios() {
@@ -163,17 +167,30 @@ function hostPage(opts) {
163
167
  window.addEventListener('message', (event) => {
164
168
  if (event.source !== frame.contentWindow) return;
165
169
  const data = event.data;
170
+ if (data && typeof data === 'object' && data.source === DEV_SOURCE && data.type === 'csp-violation') {
171
+ const p = data.payload || {};
172
+ const key = p.blockedURI + ' ' + p.violatedDirective;
173
+ if (!blocked.has(key)) {
174
+ blocked.add(key);
175
+ note('막힌 외부 요청: ' + p.blockedURI + ' (' + p.violatedDirective + ') — LXP 콘텐츠 CSP도 막습니다. zip 안에 넣어 주세요');
176
+ }
177
+ return;
178
+ }
166
179
  if (!data || typeof data !== 'object' || data.source !== SDK_SOURCE) return;
167
180
  const payload = data.payload || {};
168
181
  switch (data.type) {
169
182
  // 편집 화면의 saveSettings 결과. 저장은 콘텐츠가 edit 토큰으로 이미 했고, 편집 페이지는 표시만 한다
170
183
  case 'settings-saved':
171
184
  note(payload.status === 'saved'
172
- ? (current === 'completionPolicy'
173
- ? 'settings-saved: 완료 정책을 저장했습니다 (.ecdk/completion.json). 학생 보기가 이 정책으로 완료 · 채점합니다'
174
- : 'settings-saved: 저장했습니다. 다른 보기에서 material.settings로 받습니다 (내용 · 채점 방식 · 답은 .ecdk/settings.json)')
185
+ ? 'settings-saved: 저장했습니다. 다른 보기에서 material.settings로 받습니다 (내용 · 채점 방식 · 답은 .ecdk/settings.json)'
175
186
  : 'settings-saved: 저장 실패 (' + payload.code + ')');
176
187
  return;
188
+ // init의 불러오기 상태 (PLAT-5246). loading · ready는 매번 오므로 적지 않고, 실패만 적는다
189
+ // (LXP는 failed를 받으면 자기 실패 화면을 띄움: reason network · auth · config)
190
+ case 'status':
191
+ if (payload.state === 'failed')
192
+ note('status: 불러오기 실패 (' + payload.reason + ', ' + payload.code + ') — LXP는 실패 화면을 보여 줍니다');
193
+ return;
177
194
  case 'navigate-prev':
178
195
  note('navigate-prev: 이전 차시로 이동 (dev는 이동하지 않음)');
179
196
  return;
@@ -194,8 +211,8 @@ function hostPage(opts) {
194
211
  hasNextLecturePage: document.getElementById('has-next').checked,
195
212
  },
196
213
  };
197
- // sandbox iframe의 출처는 null이라 '*'로만 보낼 수 있다
198
- event.source.postMessage(reply, '*');
214
+ // 콘텐츠는 콘텐츠 서버 출처로 돈다 (allow-same-origin): 그 출처로만 보낸다
215
+ event.source.postMessage(reply, new URL(state.contentBase).origin);
199
216
  note('navigate-state-sync → ' + JSON.stringify(reply.payload));
200
217
  return;
201
218
  }
@@ -2,7 +2,13 @@
2
2
  * dev에서만 콘텐츠 HTML의 <head> 맨 앞에 넣는 스크립트 (zip에는 들어가지 않음).
3
3
  * - 키트가 흉내 서버를 쓰도록 API 주소를, 콘텐츠 주소를 직접 열어 mock으로 돌 때 쓸 로컬 채점 설정 주소를 알려 줌 (window.__ECDK_DEV__)
4
4
  * - 콘솔 오류 · 처리 안 된 예외 · 불러오지 못한 파일을 터미널로 보냄
5
+ * - 콘텐츠 CSP(rules/csp.ts)가 막은 요청(securitypolicyviolation)을 dev 화면(부모 창, 호스트 출처로만)과 터미널에 알림.
6
+ * 키트가 아니라 여기서 듣는 이유: 이 스크립트는 ecdk dev 응답에만 들어가 운영 LXP에서는 돌지 않고, 다른 스크립트보다
7
+ * 먼저 돌아 HTML의 <img> · CSS 글꼴처럼 키트(모듈 스크립트)가 뜨기 전에 막힌 요청도 놓치지 않으며, 키트를 쓰지 않는
8
+ * 옮겨 온 HTML에서도 동작한다
5
9
  */
10
+ /** dev 스크립트 → dev 화면 메시지 (SDK 메시지 source와 다름) */
11
+ export declare const DEV_MESSAGE_SOURCE = "ecdk-dev";
6
12
  export declare function devScript(hostOrigin: string): string;
7
13
  /** <head> 바로 뒤(없으면 맨 앞)에 넣는다. 다른 스크립트보다 먼저 돌아야 오류를 놓치지 않는다 */
8
14
  export declare function injectDevScript(html: string, hostOrigin: string): string;
package/es/dev/inject.js CHANGED
@@ -2,7 +2,13 @@
2
2
  * dev에서만 콘텐츠 HTML의 <head> 맨 앞에 넣는 스크립트 (zip에는 들어가지 않음).
3
3
  * - 키트가 흉내 서버를 쓰도록 API 주소를, 콘텐츠 주소를 직접 열어 mock으로 돌 때 쓸 로컬 채점 설정 주소를 알려 줌 (window.__ECDK_DEV__)
4
4
  * - 콘솔 오류 · 처리 안 된 예외 · 불러오지 못한 파일을 터미널로 보냄
5
+ * - 콘텐츠 CSP(rules/csp.ts)가 막은 요청(securitypolicyviolation)을 dev 화면(부모 창, 호스트 출처로만)과 터미널에 알림.
6
+ * 키트가 아니라 여기서 듣는 이유: 이 스크립트는 ecdk dev 응답에만 들어가 운영 LXP에서는 돌지 않고, 다른 스크립트보다
7
+ * 먼저 돌아 HTML의 <img> · CSS 글꼴처럼 키트(모듈 스크립트)가 뜨기 전에 막힌 요청도 놓치지 않으며, 키트를 쓰지 않는
8
+ * 옮겨 온 HTML에서도 동작한다
5
9
  */
10
+ /** dev 스크립트 → dev 화면 메시지 (SDK 메시지 source와 다름) */
11
+ const DEV_MESSAGE_SOURCE = 'ecdk-dev';
6
12
  function devScript(hostOrigin) {
7
13
  const api = `${hostOrigin}/api`;
8
14
  const log = `${hostOrigin}/__ecdk/log`;
@@ -23,6 +29,15 @@ function devScript(hostOrigin) {
23
29
  else send('error', (e.error && e.error.stack) || e.message);
24
30
  }, true);
25
31
  addEventListener('unhandledrejection', (e) => send('error', 'Promise 오류: ' + ((e.reason && e.reason.stack) || e.reason)));
32
+ const blocked = new Set();
33
+ addEventListener('securitypolicyviolation', (e) => {
34
+ const payload = { blockedURI: e.blockedURI || '(알 수 없음)', violatedDirective: e.effectiveDirective || e.violatedDirective };
35
+ const key = payload.blockedURI + ' ' + payload.violatedDirective;
36
+ if (blocked.has(key)) return;
37
+ blocked.add(key);
38
+ try { parent.postMessage({ source: ${JSON.stringify(DEV_MESSAGE_SOURCE)}, type: 'csp-violation', payload }, ${JSON.stringify(hostOrigin)}); } catch (err) {}
39
+ send('warn', '막힌 외부 요청: ' + payload.blockedURI + ' (' + payload.violatedDirective + ')');
40
+ });
26
41
  })();
27
42
  </script>`;
28
43
  }
@@ -35,4 +50,4 @@ function injectDevScript(html, hostOrigin) {
35
50
  return html.slice(0, at) + script + html.slice(at);
36
51
  }
37
52
 
38
- export { devScript, injectDevScript };
53
+ export { DEV_MESSAGE_SOURCE, devScript, injectDevScript };
@@ -1,4 +1,4 @@
1
- import { type CompletionPolicy, type LocalGrading } from '../core/config.js';
1
+ import { type LocalGrading } from '../core/config.js';
2
2
  import type { IncomingMessage, ServerResponse } from 'node:http';
3
3
  /**
4
4
  * elice-material API 흉내 (서버 설계 v25, @eliceio/cdk 1.x가 부르는 것만).
@@ -20,14 +20,14 @@ export type MaterialViewer = 'student' | 'instructor' | 'tutor';
20
20
  /**
21
21
  * dev 호스트 화면의 보기 (dev 전용). 토큰은 scope + viewer로 바뀐다.
22
22
  * - student · instructor · tutor: `#token=…` (scope learn)
23
- * - edit: `#token=…` (scope edit). LXP 편집 페이지처럼 저장된 버전의 편집 화면을 edit 토큰으로 열고,
24
- * 콘텐츠의 `saveSettings`가 이 토큰으로 바로 PATCH한다 (토큰 없는 `#edit=1` draft는 저장할 수 없음)
25
- * - completionPolicy: `#token=…&screen=completionPolicy` (scope edit). 완료 정책 화면 (ADR 0009). SDK
26
- * `saveCompletionPolicy`가 보낸 `PATCH { completion_policy }`를 `.ecdk/completion.json`에 쓴다 (운영은 material_version)
23
+ * - edit: `#token=…` (scope edit). LXP 편집 페이지처럼 편집 화면을 edit 토큰으로 열고,
24
+ * 콘텐츠의 `saveSettings`가 이 토큰으로 `PATCH /materials/{id}/draft`를 부른다 (토큰 없는 `#edit=1` draft는 저장할 수 없음).
25
+ * dev에는 draft 발행 단계가 없어 draft에 저장한 settings가 바로 지금 버전 settings가 된다
26
+ * 완료 정책은 LXP 설정이라 (ADR 0012) 흉내 내지 않는다: 채점 설정이 있으면 채점하고, 없으면 제출만 받는다.
27
27
  * 편집 화면의 `saveSettings`가 보낸 settings(내용 + `grading` { type: pattern | rubric })는 통째로 `.ecdk/settings.json`에 쓰고,
28
28
  * edit 범위 응답에는 `grading`까지, 학생 · 튜터 · 교육자(learn scope) 응답에는 서버처럼 `grading`을 빼고 준다
29
29
  */
30
- export type DevScenario = 'student' | 'instructor' | 'tutor' | 'edit' | 'completionPolicy';
30
+ export type DevScenario = 'student' | 'instructor' | 'tutor' | 'edit';
31
31
  /** 토큰을 발급하는 보기 */
32
32
  export type TokenScenario = DevScenario;
33
33
  export declare const TOKEN_SCENARIOS: Readonly<Record<DevScenario, {
@@ -53,7 +53,7 @@ interface Result {
53
53
  export interface MockState {
54
54
  /** 저장된 settings 전체 (내용 + grading). ecdk dev는 `.ecdk/settings.json`에서 읽고 저장할 때 씀 */
55
55
  settings: Record<string, unknown>;
56
- /** 저장할 때마다 올라가는 버전 번호. 응답의 `current_version.id`는 `dev-{n}` */
56
+ /** 버전 번호. 응답의 `current_version.id`는 `dev-{n}` */
57
57
  version: number;
58
58
  submissions: Submission[];
59
59
  /** 계정별 결과. 자료당 하나이고 버전이 바뀌어도 지우지 않는다 */
@@ -64,15 +64,11 @@ export interface MockState {
64
64
  export declare const createState: () => MockState;
65
65
  export interface MockApiOptions {
66
66
  state: MockState;
67
- /** 채점에 쓰는 값 (로컬 완료 정책 + 저장한 settings.grading) */
67
+ /** 채점에 쓰는 값 (저장한 settings.grading) */
68
68
  getGrading: () => LocalGrading | undefined;
69
69
  /** 편집 화면이 저장한 settings 전체(내용 + grading)를 `.ecdk/settings.json`에 쓴다 */
70
70
  saveSettings?: (settings: Record<string, unknown>) => Promise<void>;
71
71
  getEntries: () => Record<string, string>;
72
- /** metadata completionPolicies (서버가 metadata를 그대로 돌려준다고 보고 응답에 넣는다, G132) */
73
- getCompletionPolicies?: () => string[];
74
- /** 완료 정책 화면이 저장한 completion_policy를 .ecdk/completion.json에 쓴다 */
75
- saveCompletionPolicy?: (policy: CompletionPolicy) => Promise<void>;
76
72
  onEvent?: (message: string) => void;
77
73
  }
78
74
  /** `/api` 아래 요청을 처리한다 */
@@ -1,4 +1,4 @@
1
- import { COMPLETION_POLICIES, parseGrading } from '../core/config.js';
1
+ import { parseGrading } from '../core/config.js';
2
2
  import { grade } from './grading.js';
3
3
 
4
4
  /**
@@ -21,10 +21,6 @@ const TOKEN_SCENARIOS = Object.freeze({
21
21
  scope: 'edit',
22
22
  viewer: 'instructor'
23
23
  },
24
- completionPolicy: {
25
- scope: 'edit',
26
- viewer: 'instructor'
27
- },
28
24
  instructor: {
29
25
  scope: 'learn',
30
26
  viewer: 'instructor'
@@ -40,7 +36,6 @@ const TOKEN_SCENARIOS = Object.freeze({
40
36
  });
41
37
  const isTokenScenario = v => typeof v === 'string' && Object.hasOwn(TOKEN_SCENARIOS, v);
42
38
  const TOKEN_TTL_SECONDS = 7200;
43
- const SESSION_SECONDS = 12 * 3600;
44
39
  const b64url = s => Buffer.from(s).toString('base64url');
45
40
  const nowSeconds = () => Math.floor(Date.now() / 1000);
46
41
  /** SDK는 서명을 검사하지 않고 claim만 읽는다. 흉내 서버도 서명은 보지 않는다 */
@@ -136,7 +131,7 @@ function record(state, accountId, change, completed) {
136
131
  const now = new Date().toISOString();
137
132
  state.results.set(accountId, {
138
133
  score: change.score ?? prev.score,
139
- submit_count: prev.submit_count + (change.submit_count ?? 0),
134
+ submit_count: prev.submit_count + (change.submit_count),
140
135
  completed_at: prev.completed_at ?? (completed ? now : null)
141
136
  });
142
137
  }
@@ -147,22 +142,7 @@ async function handleMockApi(req, res, path, opts) {
147
142
  } = opts;
148
143
  const method = req.method ?? 'GET';
149
144
  const log = m => opts.onEvent?.(m);
150
- if (method === 'POST' && path === '/auth/token/refresh') {
151
- const claims = readClaims(req);
152
- if (!claims) return fail(res, 401, 'AUTHENTICATION_INVALID', 'token expired (dev)');
153
- if (nowSeconds() - claims.session_started_at > SESSION_SECONDS) return fail(res, 401, 'AUTHENTICATION_INVALID', 'session expired (dev)', [{
154
- reason: 'session_expired'
155
- }]);
156
- const exp = nowSeconds() + TOKEN_TTL_SECONDS;
157
- return send(res, 200, {
158
- access_token: sign({
159
- ...claims,
160
- exp
161
- }),
162
- expires_at: new Date(exp * 1000).toISOString()
163
- });
164
- }
165
- const m = path.match(/^\/materials\/([0-9a-f-]{36})(\/me|\/submissions|\/submissions\/me)?$/);
145
+ const m = path.match(/^\/materials\/([0-9a-f-]{36})(\/me|\/draft|\/submissions|\/submissions\/me)?$/);
166
146
  if (!m) return fail(res, 404, 'RESOURCE_NOT_FOUND', `no route: ${method} ${path}`);
167
147
  const claims = readClaims(req);
168
148
  if (!claims) return fail(res, 401, 'AUTHENTICATION_INVALID', 'missing or expired token (dev)');
@@ -195,82 +175,70 @@ async function handleMockApi(req, res, path, opts) {
195
175
  screens: Object.fromEntries(Object.entries(opts.getEntries()).map(([screen, entry]) => [screen, {
196
176
  entry,
197
177
  enabled: true
198
- }])),
199
- completionPolicies: opts.getCompletionPolicies?.() ?? []
178
+ }]))
200
179
  },
201
180
  file_tree: [],
202
- settings: withGrading(settings),
203
- completion_policy: opts.getGrading()?.completion_policy ?? 'on_access'
181
+ settings: withGrading(settings)
204
182
  }
205
183
  });
206
184
  if (method === 'GET' && sub === '') return send(res, 200, material(state.settings));
207
- // 편집 화면의 saveSettings · 완료 정책 화면의 saveCompletionPolicy: edit 토큰으로 지금 버전을 바로 고침.
208
- // 기준 버전이 다르면 409 (그 사이 다른 저장)
185
+ // 서버처럼 PATCH /materials/{id}는 settings를 받지 않는다 (422 extra_forbidden). dev는 발행 · 복원을 흉내 내지 않는다
209
186
  if (method === 'PATCH' && sub === '') {
187
+ if (claims.scope !== 'edit') return fail(res, 403, 'AUTH_PERMISSION_DENIED', 'save only with an edit token');
188
+ const {
189
+ json
190
+ } = await body(req);
191
+ if (json && typeof json === 'object' && 'settings' in json) return fail(res, 422, 'VALIDATION_ERROR', 'settings: use PATCH /materials/{id}/draft', [{
192
+ type: 'extra_forbidden',
193
+ loc: ['body', 'settings']
194
+ }]);
195
+ return fail(res, 400, 'INVALID_INPUT', 'empty_patch');
196
+ }
197
+ // 편집 화면의 saveSettings: edit 토큰으로 draft의 settings를 고침 (dev에서는 바로 지금 버전 settings)
198
+ if (method === 'PATCH' && sub === '/draft') {
210
199
  if (claims.scope !== 'edit') return fail(res, 403, 'AUTH_PERMISSION_DENIED', 'settings only with an edit token');
211
200
  const {
212
201
  json
213
202
  } = await body(req);
214
- const request = json;
215
- const settings = request?.settings;
216
- const rawPolicy = request?.completion_policy;
217
- if (settings === undefined && rawPolicy === undefined) return fail(res, 400, 'INVALID_INPUT', 'empty_patch');
218
- if (settings !== undefined && (!settings || typeof settings !== 'object')) return fail(res, 400, 'INVALID_INPUT', 'settings must be an object');
219
- if (rawPolicy !== undefined && !COMPLETION_POLICIES.includes(rawPolicy)) return fail(res, 400, 'INVALID_INPUT', `unknown completion_policy: ${JSON.stringify(rawPolicy)}`);
220
- const policy = rawPolicy;
221
- const expected = request?.expected_current_version_id;
222
- if (expected != null && expected !== `dev-${state.version}`) return fail(res, 409, 'MATERIAL_CHANGED', `current version is dev-${state.version}`);
223
- if (policy !== undefined) {
224
- // 서버는 enum만 본다. dev는 metadata completionPolicies 밖의 값도 알려 준다 (완료 정책 화면은 그 안에서만 고름)
225
- const allowed = opts.getCompletionPolicies?.() ?? [];
226
- if (allowed.length > 0 && !allowed.includes(policy)) return fail(res, 400, 'INVALID_INPUT', `completion_policy ${policy} is not in metadata completionPolicies (${allowed.join(', ')})`);
227
- // 서버처럼 채점 설정이 없는 on_graded는 거절 (편집 화면에서 답을 먼저 저장)
228
- if (policy === 'on_graded' && !state.settings.grading) return fail(res, 422, 'MATERIAL_GRADING_REQUIRED', 'on_graded needs settings.grading');
229
- }
203
+ const settings = json?.settings;
204
+ if (settings === undefined) return fail(res, 400, 'INVALID_INPUT', 'empty_patch');
205
+ if (!settings || typeof settings !== 'object') return fail(res, 400, 'INVALID_INPUT', 'settings must be an object');
230
206
  // 편집 화면이 보낸 settings는 통째로 .ecdk/settings.json으로 (dev 전용 저장 위치). grading이 없으면 저장된 채점 설정은 그대로
231
- if (settings !== undefined) {
232
- const {
233
- grading,
234
- ...rest
235
- } = settings;
236
- let next = rest;
237
- if (grading !== undefined && grading !== null) {
238
- const parsed = parseGrading(grading);
239
- if (typeof parsed === 'string') return fail(res, 400, 'INVALID_INPUT', `grading: ${parsed}`);
240
- next = {
241
- ...rest,
242
- grading: parsed
243
- };
244
- } else if (state.settings.grading !== undefined) next = {
207
+ const {
208
+ grading,
209
+ ...rest
210
+ } = settings;
211
+ let next = rest;
212
+ if (grading !== undefined && grading !== null) {
213
+ const parsed = parseGrading(grading);
214
+ if (typeof parsed === 'string') return fail(res, 400, 'INVALID_INPUT', `grading: ${parsed}`);
215
+ next = {
245
216
  ...rest,
246
- grading: state.settings.grading
217
+ grading: parsed
247
218
  };
248
- state.settings = next;
249
- await opts.saveSettings?.(next);
250
- log(`내용을 .ecdk/settings.json에 저장했습니다${next.grading ? ` (채점 설정 ${next.grading.type})` : ''}`);
251
- }
252
- if (policy !== undefined) {
253
- await opts.saveCompletionPolicy?.(policy);
254
- log(`완료 정책을 .ecdk/completion.json에 저장했습니다 (${policy})`);
255
- }
256
- state.version += 1;
257
- log(`자료를 저장했습니다 (${settings !== undefined ? 'settings' : 'completion_policy'}, 버전 dev-${state.version})`);
258
- return send(res, 200, material(state.settings));
219
+ } else if (state.settings.grading !== undefined) next = {
220
+ ...rest,
221
+ grading: state.settings.grading
222
+ };
223
+ state.settings = next;
224
+ await opts.saveSettings?.(next);
225
+ log(`내용을 .ecdk/settings.json에 저장했습니다${next.grading ? ` (채점 설정 ${next.grading.type})` : ''}`);
226
+ const {
227
+ metadata
228
+ } = material(state.settings).current_version;
229
+ return send(res, 200, {
230
+ id: 'dev-draft',
231
+ status: 'ready',
232
+ metadata,
233
+ file_tree: [],
234
+ settings: state.settings
235
+ });
259
236
  }
260
237
  if (method === 'GET' && sub === '/me') {
261
238
  const user = claims.viewer === 'instructor' ? MANAGER : STUDENT;
262
- if (claims.scope === 'learn' && claims.viewer === 'student' && opts.getGrading()?.completion_policy === 'on_access' && !state.results.has(subject)) {
263
- record(state, subject, {
264
- score: 100
265
- }, true);
266
- log('열람 완료로 100점 (on_access)');
267
- }
268
- const local = opts.getGrading();
269
239
  return send(res, 200, {
270
240
  scope: claims.scope,
271
241
  viewer: claims.viewer,
272
- completion_policy: local?.completion_policy ?? 'on_access',
273
- grading_type: local?.completion_policy === 'on_graded' ? local.grading?.type ?? null : null,
274
242
  user: {
275
243
  anonymous_id: user.anonymous_id,
276
244
  fullname: user.fullname
@@ -319,10 +287,11 @@ async function handleMockApi(req, res, path, opts) {
319
287
  is_correct: isCorrect,
320
288
  score
321
289
  });
290
+ // 채점 설정이 있으면 통과해야, 없으면 제출만으로 기록에 완료 시각을 남긴다 (운영 완료 여부는 LXP 완료 정책이 정함)
322
291
  record(state, subject, {
323
292
  score,
324
293
  submit_count: 1
325
- }, isCorrect === true);
294
+ }, isCorrect === true || !opts.getGrading()?.grading);
326
295
  log(`학생 제출: ${score ?? '-'}점 (${isCorrect === null ? '채점 없음' : isCorrect ? '정답' : '오답'})`);
327
296
  return send(res, 200, {
328
297
  is_correct: isCorrect,
@@ -25,8 +25,10 @@ export declare class DevPortError extends Error {
25
25
  /**
26
26
  * 로컬에서 운영과 같은 조건으로 콘텐츠를 띄운다.
27
27
  * - 호스트(localhost): LXP 흉내 화면 + elice-material 흉내 API(/api) + 콘솔 수집
28
- * - 콘텐츠(127.0.0.1, 다른 출처): build와 같은 파일(모듈 묶기 포함)을 운영 헤더(CSP sandbox allow-scripts)로.
29
- * LXP 자료 파일 서버처럼 CORS 헤더를 주지 않아, 묶지 않은 모듈 스크립트 · fetch가 LXP에서처럼 막힌다
28
+ * - 콘텐츠(127.0.0.1, 다른 출처): build와 같은 파일(모듈 묶기 포함)을 운영 콘텐츠 CSP 초안(rules/csp.ts,
29
+ * 서버 수정 제안 1번과 같은 값, sandbox allow-scripts allow-same-origin)으로. 콘텐츠는 제 출처(127.0.0.1:<port+1>)로 돌아
30
+ * 저장소는 호스트와 따로 쓰고, 제 파일 요청은 같은 출처라 막히지 않는다. 외부 이미지 · 글꼴 · fetch 등은 LXP에서처럼
31
+ * 막히고, 막힌 요청은 dev 스크립트가 화면 기록 · 터미널에 "막힌 외부 요청"으로 알린다. LXP 자료 파일 서버처럼 CORS 헤더는 주지 않는다
30
32
  * - 원본이 바뀌면 다시 준비 · 검사 → 호스트가 iframe을 다시 띄움
31
33
  */
32
34
  export declare function startDevServer(opts: DevServerOptions): Promise<DevServer>;
package/es/dev/server.js CHANGED
@@ -2,12 +2,13 @@ import { watch } from 'node:fs';
2
2
  import { rm, mkdir, writeFile } from 'node:fs/promises';
3
3
  import { createServer } from 'node:http';
4
4
  import { resolve, extname, join, basename, relative, sep, dirname } from 'node:path';
5
- import { loadConfig, loadSavedSettings, savedGrading, loadCompletionPolicy, SETTINGS_DATA_FILE, PACKAGE_FILE, CONFIG_FILE, COMPLETION_DATA_FILE } from '../core/config.js';
5
+ import { loadConfig, loadSavedSettings, savedGrading, SETTINGS_DATA_FILE, PACKAGE_FILE, CONFIG_FILE } from '../core/config.js';
6
6
  import { prepareContent } from '../core/prepare.js';
7
7
  import { projectCheckOptions } from '../core/project-check.js';
8
8
  import { inlineModuleScripts } from '../core/sandbox.js';
9
9
  import { missingSdkMessage } from '../core/sdk.js';
10
10
  import { checkFiles } from '../rules/check.js';
11
+ import { contentCsp } from '../rules/csp.js';
11
12
  import '../rules/spec.js';
12
13
  import 'fflate';
13
14
  import { hostPage } from './host-page.js';
@@ -49,7 +50,7 @@ function summarize(check) {
49
50
  const warns = check.issues.length - errors.length;
50
51
  const head = `${check.ok ? '[ok]' : '[fail]'} 검사 오류 ${errors.length} · 경고 ${warns} (규칙 ${check.rulesVersion})`;
51
52
  const lines = check.issues.slice(0, 5).map(i => ` [${i.level}] ${i.id}${i.path ? ` ${i.path}${i.line ? `:${i.line}` : ''}` : ''} ${i.message}`);
52
- if (check.issues.length > 5) lines.push(` … 외 ${check.issues.length - 5}개 (ecdk check로 전체 보기)`);
53
+ if (check.issues.length > 5) lines.push(` … 외 ${check.issues.length - 5}개 (ecdk validate로 전체 보기)`);
53
54
  return [head, ...lines].join('\n');
54
55
  }
55
56
  /** 포트가 이미 쓰일 때: 어느 포트(호스트 · 콘텐츠)인지 알린다 */
@@ -85,8 +86,10 @@ async function servedFiles(prepared, log) {
85
86
  /**
86
87
  * 로컬에서 운영과 같은 조건으로 콘텐츠를 띄운다.
87
88
  * - 호스트(localhost): LXP 흉내 화면 + elice-material 흉내 API(/api) + 콘솔 수집
88
- * - 콘텐츠(127.0.0.1, 다른 출처): build와 같은 파일(모듈 묶기 포함)을 운영 헤더(CSP sandbox allow-scripts)로.
89
- * LXP 자료 파일 서버처럼 CORS 헤더를 주지 않아, 묶지 않은 모듈 스크립트 · fetch가 LXP에서처럼 막힌다
89
+ * - 콘텐츠(127.0.0.1, 다른 출처): build와 같은 파일(모듈 묶기 포함)을 운영 콘텐츠 CSP 초안(rules/csp.ts,
90
+ * 서버 수정 제안 1번과 같은 값, sandbox allow-scripts allow-same-origin)으로. 콘텐츠는 제 출처(127.0.0.1:<port+1>)로 돌아
91
+ * 저장소는 호스트와 따로 쓰고, 제 파일 요청은 같은 출처라 막히지 않는다. 외부 이미지 · 글꼴 · fetch 등은 LXP에서처럼
92
+ * 막히고, 막힌 요청은 dev 스크립트가 화면 기록 · 터미널에 "막힌 외부 요청"으로 알린다. LXP 자료 파일 서버처럼 CORS 헤더는 주지 않는다
90
93
  * - 원본이 바뀌면 다시 준비 · 검사 → 호스트가 iframe을 다시 띄움
91
94
  */
92
95
  async function startDevServer(opts) {
@@ -97,10 +100,8 @@ async function startDevServer(opts) {
97
100
  // 편집 화면이 저장한 settings(내용 + grading)는 .ecdk/settings.json에 남겨 dev를 다시 열어도 그대로 (운영은 서버 settings)
98
101
  state.settings = await loadSavedSettings(dir);
99
102
  savedGrading(state.settings); // grading 형식이 틀리면 시작할 때 알린다
100
- let policy = await loadCompletionPolicy(dir, config);
101
- /** 로컬 채점 흉내: 완료 정책 + 저장한 settings.grading. 문제 설명은 채점 없음 */
103
+ /** 로컬 채점 흉내: 저장한 settings.grading (없으면 제출만 받음). 문제 설명은 채점 없음 */
102
104
  const localGrading = () => config.kind === 'description' ? undefined : {
103
- completion_policy: policy,
104
105
  grading: savedGrading(state.settings)
105
106
  };
106
107
  async function writeJson(file, data) {
@@ -111,20 +112,10 @@ async function startDevServer(opts) {
111
112
  await writeFile(path, `${JSON.stringify(data, null, 2)}\n`);
112
113
  }
113
114
  /**
114
- * 편집 화면의 saveSettings(PATCH settings)를 흉내 서버가 받으면 settings 전체(내용 + grading)를 `.ecdk/settings.json`에 쓴다
115
+ * 편집 화면의 saveSettings(PATCH /draft settings)를 흉내 서버가 받으면 settings 전체(내용 + grading)를 `.ecdk/settings.json`에 쓴다
115
116
  * (운영은 material_version.settings). 값 검사는 흉내 서버가 한다. 점(.) 폴더라 감시 · zip에서 빠진다
116
117
  */
117
118
  const saveSettings = settings => writeJson(SETTINGS_DATA_FILE, settings);
118
- /**
119
- * 완료 정책 화면의 saveCompletionPolicy(PATCH completion_policy)를 흉내 서버가 받으면 `.ecdk/completion.json`에 쓴다
120
- * (운영은 material_version.completion_policy). 값 검사는 흉내 서버가 한다
121
- */
122
- async function saveCompletionPolicy(next) {
123
- await writeJson(COMPLETION_DATA_FILE, {
124
- completion_policy: next
125
- });
126
- policy = await loadCompletionPolicy(dir, config);
127
- }
128
119
  // SDK를 설치하기 전에도 mock으로는 열린다 (실제 SDK 모드 ?sdk=real만 lib/cdk.js가 없어 실패, 아래에서 알림)
129
120
  let prepared = await prepareContent(dir, config, {
130
121
  requireSdk: false
@@ -153,8 +144,13 @@ async function startDevServer(opts) {
153
144
  // 콘텐츠 서버
154
145
  const content = createServer((req, res) => {
155
146
  const url = new URL(req.url ?? '/', 'http://x');
147
+ // CONTENT_HOST: 콘텐츠 출처, MATERIAL_API: 흉내 API · dev 기록이 있는 호스트 출처, LXP_ORIGINS: 흉내 화면 출처
156
148
  const headers = {
157
- 'Content-Security-Policy': `sandbox allow-scripts; frame-ancestors ${hostOrigin}`,
149
+ 'Content-Security-Policy': contentCsp({
150
+ contentHost: contentOrigin,
151
+ materialApi: hostOrigin,
152
+ lxpOrigins: hostOrigin
153
+ }),
158
154
  'X-Content-Type-Options': 'nosniff',
159
155
  'Referrer-Policy': 'no-referrer',
160
156
  'Cache-Control': 'no-store'
@@ -205,13 +201,11 @@ async function startDevServer(opts) {
205
201
  getGrading: localGrading,
206
202
  saveSettings,
207
203
  getEntries: entries,
208
- getCompletionPolicies: () => check.manifest?.completionPolicies ?? [],
209
- saveCompletionPolicy,
210
204
  onEvent: m => log(`[api] ${m}`)
211
205
  });
212
206
  return;
213
207
  }
214
- // 콘텐츠 주소를 직접 열어 mock으로 돌 때: .ecdk(저장한 settings · 완료 정책)는 zip에 없어 콘텐츠 서버가 주지 않으므로
208
+ // 콘텐츠 주소를 직접 열어 mock으로 돌 때: .ecdk(저장한 settings)는 zip에 없어 콘텐츠 서버가 주지 않으므로
215
209
  // 흉내 서버가 채점에 쓰는 것과 같은 로컬 채점 설정을 여기서 준다 (dev 전용)
216
210
  // CORS *로 둔다: ecdk dev는 작성자 PC에서만 돌고 내주는 값도 작성자 본인이 저장한 답이라, 막아도 지킬 대상이 없다
217
211
  // (실행마다 열쇠를 두는 방식은 콘텐츠 주소가 예측 가능해 열쇠까지 읽혀 효과가 없어서 되돌림, !19 리뷰)
@@ -220,12 +214,8 @@ async function startDevServer(opts) {
220
214
  ...cors,
221
215
  'Content-Type': 'application/json; charset=utf-8'
222
216
  });
223
- // { completion_policy, grading, completion_policies }: 콘텐츠를 직접 연 mock이 로컬 채점 · 완료 정책 흉내에 쓴다
224
- const local = localGrading();
225
- res.end(JSON.stringify(local ? {
226
- ...local,
227
- completion_policies: check.manifest?.completionPolicies ?? []
228
- } : null));
217
+ // { grading }: 콘텐츠를 직접 연 mock이 로컬 채점 흉내에 쓴다
218
+ res.end(JSON.stringify(localGrading() ?? null));
229
219
  return;
230
220
  }
231
221
  if (url.pathname === '/favicon.ico') {
@@ -328,7 +318,6 @@ async function startDevServer(opts) {
328
318
  async function reload() {
329
319
  try {
330
320
  config = await loadConfig(dir);
331
- policy = await loadCompletionPolicy(dir, config);
332
321
  // 손으로 고친 .ecdk/settings.json도 다시 읽는다 (편집 화면 저장은 흉내 서버가 이미 state에 넣음)
333
322
  const saved = await loadSavedSettings(dir);
334
323
  savedGrading(saved);