@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
@@ -0,0 +1,304 @@
1
+ import { copyFileSync, writeFileSync, unlinkSync, readdirSync, statSync, rmdirSync } from 'node:fs';
2
+ import { dirname, sep, join, basename } from 'node:path';
3
+ import { defaultMcpEnv, MCP_NAME, claudeRegistration, helpyConfigPath, readHelpyConfig, helpyRegisteredUrl } from '../mcp/index.js';
4
+ import { skillsDir, skillNames, markedSkillNames, inspectSkill, skillFiles, removeSkillFiles, isDotPath } from '../skill/index.js';
5
+
6
+ const usage = `사용법: ecdk uninstall [--project] [--target claude|helpycode|all] [--dry-run] [--force] [--json]
7
+
8
+ ecdk setup이 설치한 것을 지운다: 스킬 5개(elice-content-create · -migrate · -check · -publish · elice-content-guide),
9
+ 옛 ecdk가 지금은 없는 이름으로 설치한 스킬(SKILL.md 끝에 ecdk 설치 표시가 있는 것)과
10
+ 학습자료 서버 MCP 등록(elice-material, Claude Code 사용자 설정 · Helpy Code 설정).
11
+ --project 현재 폴더의 .claude/skills/에 설치한 스킬만 지운다 (MCP 등록은 모든 프로젝트가 같이 써서 건드리지 않음)
12
+ --target MCP를 지울 도구 claude · helpycode · all(기본). 스킬은 한 곳(~/.claude/skills/)을 같이 써서 늘 지운다
13
+ --dry-run 지울 것을 보여 주기만 한다
14
+ --force 손으로 고친 스킬 · 손으로 고친 Helpy Code 항목도 지운다
15
+ 다른 스킬 · 다른 MCP 서버 · 프로젝트 · .ecdk/는 건드리지 않는다. CLI 자체는 지우지 않는다 (끝에 명령을 알려 줌).
16
+
17
+ 종료 코드: 0 지움(또는 지울 것 없음) · 1 남긴 것 · 직접 할 일이 있음(손으로 고친 스킬, 주석이 있는 설정 파일) · 2 잘못된 사용`;
18
+ const NEXT = ['CLI 지우기: npm uninstall -g @eliceio/cdk-cli (npx로만 실행했다면 지울 것 없음)', '옛 Claude 플러그인 elice-content를 설치했었다면 Claude Code에서: /plugin uninstall elice-content@elice-content → /plugin marketplace remove elice-content'];
19
+ /**
20
+ * SKILL.md와 ecdk가 같이 설치한 파일(files)만 지우고, 폴더는 비었을 때만 지운다 (사람이 더한 파일은 남김)
21
+ */
22
+ function removeSkill(path, files) {
23
+ unlinkSync(path);
24
+ const dir = dirname(path);
25
+ removeSkillFiles(dir, files);
26
+ let rest = readdirSync(dir, {
27
+ recursive: true,
28
+ encoding: 'utf8'
29
+ }).map(p => p.split(sep).join('/'));
30
+ // 남은 것이 점 파일(.DS_Store 같은 OS 파일)과 빈 폴더뿐이면 그것도 지우고 폴더를 지운다. 숨김 폴더 안은 건드리지 않음
31
+ const dirs = rest.filter(p => statSync(join(dir, p)).isDirectory());
32
+ const osFile = p => basename(p).startsWith('.') && !isDotPath(dirname(p).replace(/^\.$/, ''));
33
+ if (rest.every(p => dirs.includes(p) || osFile(p))) {
34
+ for (const p of rest.filter(p => !dirs.includes(p))) unlinkSync(join(dir, p));
35
+ for (const p of dirs.sort().reverse()) rmdirSync(join(dir, p));
36
+ rest = [];
37
+ }
38
+ if (rest.length === 0) rmdirSync(dir);
39
+ return rest.sort();
40
+ }
41
+ function uninstallSkills(opts) {
42
+ // 지금 CLI의 스킬 + 옛 CLI가 지금은 없는 이름으로 설치한 스킬(설치 표시로 알아봄). 표시 없는 남의 스킬은 건드리지 않음
43
+ const names = [...new Set([...skillNames(opts.root), ...markedSkillNames(opts.dir)])].sort();
44
+ return names.map(name => {
45
+ // 지문이 맞으면(버전과 상관없이) ecdk가 설치한 그대로라 지운다. 고친 스킬은 --force일 때만
46
+ const status = inspectSkill(opts.dir, name);
47
+ const base = {
48
+ name,
49
+ path: status.path,
50
+ state: status.state
51
+ };
52
+ if (status.state === 'missing') return {
53
+ ...base,
54
+ action: 'missing'
55
+ };
56
+ if (status.state === 'modified' && !opts.force) return {
57
+ ...base,
58
+ action: 'kept'
59
+ };
60
+ if (opts.dryRun) return {
61
+ ...base,
62
+ action: 'would-remove'
63
+ };
64
+ // 지문이 맞으면 같이 설치한 파일(가이드 topics/)도 지운다. 손으로 고친 스킬(--force)은 이 CLI가 설치하는 이름의 파일만
65
+ const files = status.files ?? (skillNames(opts.root).includes(name) ? skillFiles(name, opts.root) : []);
66
+ const extra = removeSkill(status.path, files);
67
+ return {
68
+ ...base,
69
+ action: 'removed',
70
+ ...(extra.length > 0 ? {
71
+ extraFiles: extra
72
+ } : {})
73
+ };
74
+ });
75
+ }
76
+ const CLAUDE_TIMEOUT_MS = 30000;
77
+ function uninstallClaude(env, dryRun, explicit) {
78
+ if (!env.which('claude')) return explicit ? {
79
+ target: 'claude',
80
+ action: 'not-found',
81
+ message: 'Claude Code(claude)를 찾지 못함'
82
+ } : null;
83
+ const reg = claudeRegistration(env);
84
+ if (reg.state === 'unknown') return {
85
+ target: 'claude',
86
+ action: 'manual',
87
+ message: `등록 여부를 확인하지 못해 건드리지 않았습니다 (${reg.reason}). \`claude mcp remove ${MCP_NAME} --scope user\`로 직접 지워 주세요`
88
+ };
89
+ if (reg.state === 'none') return {
90
+ target: 'claude',
91
+ action: 'none',
92
+ message: '등록 없음'
93
+ };
94
+ if (reg.state === 'other-scope')
95
+ // ecdk setup은 사용자 범위에만 등록한다. 이 폴더 전용 등록은 사람이 한 것이라 그대로 둠
96
+ return {
97
+ target: 'claude',
98
+ action: 'other-scope',
99
+ message: `사용자 범위 등록 없음. ${reg.scope} 범위 등록(${reg.url})은 ecdk가 만든 것이 아니라 그대로 둠 (지우려면 이 폴더에서 claude mcp remove ${MCP_NAME})`
100
+ };
101
+ const rm = ['mcp', 'remove', MCP_NAME, '--scope', 'user'];
102
+ if (dryRun) return {
103
+ target: 'claude',
104
+ action: 'would-remove',
105
+ message: `claude ${rm.join(' ')} (${reg.url})`
106
+ };
107
+ const r = env.exec('claude', rm, CLAUDE_TIMEOUT_MS);
108
+ if (r.code !== 0 || r.timedOut) return {
109
+ target: 'claude',
110
+ action: 'failed',
111
+ message: `claude mcp remove 실패: ${r.stdout.trim() || '시간 초과'}`
112
+ };
113
+ return {
114
+ target: 'claude',
115
+ action: 'removed',
116
+ message: `Claude Code 사용자 설정에서 지움 (${reg.url})`
117
+ };
118
+ }
119
+ /** ecdk setup이 쓴 모양({ type: 'remote', url, enabled })이면 우리 것 */
120
+ function isOurHelpyEntry(entry) {
121
+ if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) return false;
122
+ const e = entry;
123
+ return Object.keys(e).every(k => k === 'type' || k === 'url' || k === 'enabled') && e.type === 'remote' && typeof e.url === 'string';
124
+ }
125
+ function uninstallHelpy(env, dryRun, force, explicit) {
126
+ const path = helpyConfigPath(env);
127
+ const config = readHelpyConfig(path);
128
+ if (config.kind === 'missing') return explicit ? {
129
+ target: 'helpycode',
130
+ action: 'none',
131
+ message: '등록 없음'
132
+ } : null;
133
+ if (config.kind === 'jsonc') {
134
+ const current = helpyRegisteredUrl(env);
135
+ if (!current) return {
136
+ target: 'helpycode',
137
+ action: 'none',
138
+ message: '등록 없음'
139
+ };
140
+ return {
141
+ target: 'helpycode',
142
+ action: 'manual',
143
+ message: `${path}에 주석이나 끝 쉼표가 있어 직접 고치지 않았습니다. "mcp" 안의 "${MCP_NAME}" 항목만 지워 주세요 (다른 항목은 두기).`,
144
+ remove: `"${MCP_NAME}": { "type": "remote", "url": "${current}", … }`
145
+ };
146
+ }
147
+ const data = {
148
+ ...config.data
149
+ };
150
+ const mcp = {
151
+ ...(data.mcp ?? {})
152
+ };
153
+ if (!(MCP_NAME in mcp)) return {
154
+ target: 'helpycode',
155
+ action: 'none',
156
+ message: '등록 없음'
157
+ };
158
+ if (!isOurHelpyEntry(mcp[MCP_NAME]) && !force) return {
159
+ target: 'helpycode',
160
+ action: 'kept',
161
+ message: `${path}의 mcp.${MCP_NAME}가 ecdk가 쓴 모양과 달라(손으로 고침) 그대로 둠. 지우려면 --force`
162
+ };
163
+ const bakExists = env.exists(`${path}.bak`);
164
+ if (dryRun) return {
165
+ target: 'helpycode',
166
+ action: 'would-remove',
167
+ message: `${path}의 mcp.${MCP_NAME}${bakExists ? ' (.bak은 이미 있어 그대로 둠)' : ' (원본은 .bak)'}`
168
+ };
169
+ delete mcp[MCP_NAME];
170
+ if (Object.keys(mcp).length === 0) delete data.mcp;else data.mcp = mcp;
171
+ // .bak은 처음 한 번만 (ecdk setup이 만든 원본을 덮지 않게)
172
+ if (!bakExists) copyFileSync(path, `${path}.bak`);
173
+ writeFileSync(path, `${JSON.stringify(data, null, 2)}\n`);
174
+ return {
175
+ target: 'helpycode',
176
+ action: 'removed',
177
+ message: `${path}에서 mcp.${MCP_NAME}를 지움${bakExists ? ' (.bak은 이미 있어 그대로 둠)' : ' (원본은 .bak)'}`
178
+ };
179
+ }
180
+ function uninstall(opts) {
181
+ const {
182
+ env
183
+ } = opts;
184
+ const dir = skillsDir({
185
+ project: opts.project,
186
+ cwd: opts.cwd,
187
+ home: env.home
188
+ });
189
+ const skills = uninstallSkills({
190
+ dir,
191
+ dryRun: opts.dryRun,
192
+ force: opts.force,
193
+ root: opts.root
194
+ });
195
+ const mcp = [];
196
+ // --project는 그 폴더의 스킬만. MCP 등록은 사용자 범위라 모든 프로젝트가 같이 씀
197
+ if (!opts.project) {
198
+ if (opts.target !== 'helpycode') {
199
+ const s = uninstallClaude(env, opts.dryRun, opts.target === 'claude');
200
+ if (s) mcp.push(s);
201
+ }
202
+ if (opts.target !== 'claude') {
203
+ const s = uninstallHelpy(env, opts.dryRun, opts.force, opts.target === 'helpycode');
204
+ if (s) mcp.push(s);
205
+ }
206
+ }
207
+ const issues = [];
208
+ for (const s of skills) {
209
+ if (s.action === 'kept') issues.push({
210
+ id: 'skill.modified',
211
+ message: `${s.name}: 손으로 고친 스킬이라 그대로 둠 (${s.path}). 지우려면 --force`
212
+ });
213
+ if (s.extraFiles) issues.push({
214
+ id: 'skill.extra-files',
215
+ message: `${s.name}: SKILL.md만 지우고 폴더는 남김 (다른 파일: ${s.extraFiles.join(', ')})`
216
+ });
217
+ }
218
+ for (const s of mcp) {
219
+ if (s.target === 'claude' && s.action === 'manual') issues.push({
220
+ id: 'mcp.claude-unknown',
221
+ message: `MCP(claude): ${s.message}`
222
+ });
223
+ if (s.action === 'failed') issues.push({
224
+ id: 'mcp.claude-failed',
225
+ message: `MCP(claude): ${s.message}`
226
+ });
227
+ if (s.target === 'helpycode' && s.action === 'manual') issues.push({
228
+ id: 'mcp.helpycode-manual',
229
+ message: `MCP(helpycode): ${s.message}`
230
+ });
231
+ if (s.target === 'helpycode' && s.action === 'kept') issues.push({
232
+ id: 'mcp.helpycode-modified',
233
+ message: `MCP(helpycode): ${s.message}`
234
+ });
235
+ }
236
+ const nothing = skills.every(s => s.action === 'missing') && mcp.every(s => s.action === 'none' || s.action === 'not-found' || s.action === 'other-scope');
237
+ return {
238
+ dryRun: opts.dryRun,
239
+ dir,
240
+ skills,
241
+ mcp,
242
+ issues,
243
+ nothing,
244
+ next: NEXT
245
+ };
246
+ }
247
+ const SKILL_ACTION = {
248
+ removed: '지움',
249
+ 'would-remove': '지울 예정',
250
+ kept: '손으로 고친 스킬이라 그대로 둠 (--force로 지움)',
251
+ missing: '없음'
252
+ };
253
+ async function run(args) {
254
+ const target = args.target ?? 'all';
255
+ if (target !== 'claude' && target !== 'helpycode' && target !== 'all') return {
256
+ exitCode: 2,
257
+ output: `--target은 claude · helpycode · all 중 하나입니다.\n\n${usage}`
258
+ };
259
+ if (args.project && args.target !== undefined) return {
260
+ exitCode: 2,
261
+ output: `--project는 그 폴더의 스킬만 지워 --target(MCP)과 같이 쓸 수 없습니다.\n\n${usage}`
262
+ };
263
+ const result = uninstall({
264
+ env: args.env ?? defaultMcpEnv(),
265
+ project: args.project,
266
+ target,
267
+ dryRun: args.dryRun,
268
+ force: args.force,
269
+ cwd: args.cwd
270
+ });
271
+ const exitCode = result.issues.length > 0 ? 1 : 0;
272
+ if (args.json) return {
273
+ exitCode,
274
+ output: JSON.stringify(result, null, 2)
275
+ };
276
+ const lines = [];
277
+ if (result.nothing) {
278
+ lines.push(`ecdk가 설치한 스킬 · MCP 등록이 없습니다 (스킬 위치: ${result.dir}).`, ...result.mcp.filter(s => s.action === 'other-scope').map(s => ` ${s.target}: ${s.message}`));
279
+ } else {
280
+ lines.push(`스킬${result.dryRun ? ' (미리보기, 아무것도 바꾸지 않음)' : ''}: ${result.dir}`);
281
+ for (const s of result.skills) lines.push(` ${s.name}: ${SKILL_ACTION[s.action]}`);
282
+ if (!args.project) {
283
+ lines.push('', `학습자료 서버 MCP (${MCP_NAME})`);
284
+ if (result.mcp.length === 0) lines.push(' Claude Code · Helpy Code 등록 없음');
285
+ for (const s of result.mcp) {
286
+ lines.push(` ${s.target}: ${s.message}`);
287
+ if (s.remove) lines.push(` ${s.remove}`);
288
+ }
289
+ }
290
+ if (result.issues.length > 0) {
291
+ lines.push('', '남긴 것 · 직접 할 일');
292
+ for (const i of result.issues) lines.push(` - ${i.message}`);
293
+ }
294
+ if (!result.dryRun) lines.push('', 'Claude Code · Helpy Code를 새로 열면 적용됩니다.');
295
+ }
296
+ lines.push('', '그 밖에');
297
+ for (const n of result.next) lines.push(` - ${n}`);
298
+ return {
299
+ exitCode,
300
+ output: lines.join('\n')
301
+ };
302
+ }
303
+
304
+ export { run, uninstall, usage };
@@ -0,0 +1,59 @@
1
+ import { type LatestResult } from '../../core/latest.js';
2
+ import type { CommandResult } from '../../types.js';
3
+ export declare const usage = "\uC0AC\uC6A9\uBC95: ecdk update [--check] [--yes] [--json]\n\n npm latest \uD0DC\uADF8\uC758 ecdk\uB85C \uC62C\uB9B0\uB2E4. \uCC28\uB840\uB85C:\n 1. CLI \uC124\uCE58: npm install -g @eliceio/cdk-cli@<latest> (npx\uB85C \uC2E4\uD589 \uC911\uC774\uBA74 \uAC74\uB108\uB700)\n 2. \uC2A4\uD0AC \uAC31\uC2E0: \uC0C8\uB85C \uC124\uCE58\uD55C ecdk\uB85C ecdk setup --only skills (npx\uBA74 npx -y @eliceio/cdk-cli@<latest> setup --only skills)\n \uC190\uC73C\uB85C \uACE0\uCE5C \uC2A4\uD0AC\uC740 \uADF8\uB300\uB85C \uB460, \uBC14\uAFB8\uB824\uBA74 ecdk setup --only skills --force\n 3. \uD504\uB85C\uC81D\uD2B8 SDK: \uD604\uC7AC \uD3F4\uB354\uAC00 @eliceio/cdk\uB97C \uC4F0\uB294 \uD504\uB85C\uC81D\uD2B8\uBA74 npm update @eliceio/cdk (\uD654\uBA74 \u00B7 \uD15C\uD50C\uB9BF \uCF54\uB4DC\uB294 \uBC14\uAFB8\uC9C0 \uC54A\uC74C)\n \uC9C0\uAE08 \uBC84\uC804\uC774 latest\uC640 \uAC19\uAC70\uB098 \uB354 \uC0C8 \uBC84\uC804\uC774\uBA74 \uC544\uBB34\uAC83\uB3C4 \uD558\uC9C0 \uC54A\uB294\uB2E4 (\uB0B4\uB9AC\uC9C0 \uC54A\uC74C).\n --check \uD655\uC778\uB9CC (\uC9C0\uAE08 \u00B7 \uCD5C\uC2E0 \uBC84\uC804\uACFC \uC2E4\uD589\uD560 \uBA85\uB839)\n --yes \uBB3B\uC9C0 \uC54A\uACE0 \uC2E4\uD589 (\uC9C0\uAE08\uC740 \uB298 \uBB3B\uC9C0 \uC54A\uC74C, \uC2A4\uD06C\uB9BD\uD2B8\uC6A9)\n\n\uC885\uB8CC \uCF54\uB4DC: 0 \uCD5C\uC2E0\uC774\uAC70\uB098 \uC5C5\uB370\uC774\uD2B8\uD568 \u00B7 1 \uCD5C\uC2E0 \uBC84\uC804 \uD655\uC778 \uC2E4\uD328 \u00B7 \uB2E8\uACC4 \uC2E4\uD328 \u00B7 2 \uC798\uBABB\uB41C \uC0AC\uC6A9";
4
+ export type StepId = 'cli.install' | 'skill.install' | 'project.sdk';
5
+ export type StepStatus = 'planned' | 'done' | 'warn' | 'skipped' | 'failed' | 'not-run';
6
+ export interface UpdateStep {
7
+ id: StepId;
8
+ status: StepStatus;
9
+ /** 실행한(할) 명령. 없으면 실행하지 않는 단계 */
10
+ command?: string | undefined;
11
+ message?: string | undefined;
12
+ }
13
+ export interface UpdateResult {
14
+ ok: boolean;
15
+ current: string;
16
+ /** npm latest. 확인하지 못하면 null */
17
+ latest: string | null;
18
+ upToDate: boolean;
19
+ /** npx 캐시에서 실행 중 (전역 설치를 건너뜀) */
20
+ npx: boolean;
21
+ steps: UpdateStep[];
22
+ notes: string[];
23
+ /** 스킬 갱신 전에 ~/.claude/skills가 없어 이번에 만듦 (이미 열린 Claude Code 세션은 /reload-skills 한 번) */
24
+ skillsDirCreated: boolean;
25
+ error?: string | undefined;
26
+ }
27
+ export interface RunOutput {
28
+ code: number;
29
+ output: string;
30
+ }
31
+ /** 바깥 세계(npm · 명령 실행 · 현재 폴더)를 바꿔 끼울 수 있게 (테스트는 네트워크 · 전역 설치를 하지 않음) */
32
+ export interface UpdateEnv {
33
+ latest(timeoutMs: number): LatestResult;
34
+ /** 지금 실행 중인 CLI 파일 (npx 캐시면 경로에 _npx가 들어 있음) */
35
+ scriptPath: string;
36
+ cwd: string;
37
+ /** 스킬을 설치할 홈 (없으면 os.homedir(), 테스트는 임시 폴더) */
38
+ home?: string | undefined;
39
+ /** 명령 실행. 출력은 stderr로 흘려 보내고(--json 출력에 섞이지 않게) 같이 돌려준다. quiet면 흘려 보내지 않음 */
40
+ run(command: string, args: string[], opts?: {
41
+ cwd?: string;
42
+ quiet?: boolean;
43
+ }): Promise<RunOutput>;
44
+ /** 진행 줄 (stderr) */
45
+ log(line: string): void;
46
+ }
47
+ export declare function defaultUpdateEnv(): UpdateEnv;
48
+ export declare const isNpx: (scriptPath: string) => boolean;
49
+ /** README "문제 해결 · 설치"의 EACCES 안내와 같은 문구 */
50
+ export declare const PERMISSION_HINT = "`sudo` \uB300\uC2E0 `npx`\uB85C \uC2E4\uD589, \uB610\uB294 fnm \u00B7 Homebrew\uB85C Node.js \uC7AC\uC124\uCE58";
51
+ export declare function update(env: UpdateEnv, opts: {
52
+ check: boolean;
53
+ current?: string | undefined;
54
+ }): Promise<UpdateResult>;
55
+ export declare function formatText(r: UpdateResult, check: boolean): string;
56
+ export declare function run(args: {
57
+ check: boolean;
58
+ json: boolean;
59
+ }, env?: UpdateEnv, current?: string): Promise<CommandResult>;
@@ -0,0 +1,251 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { existsSync } from 'node:fs';
3
+ import { resolve } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ import { loadConfig } from '../../core/config.js';
6
+ import { CLI_PACKAGE, LATEST_UPDATE_TIMEOUT_MS, isNewer, npmLatest } from '../../core/latest.js';
7
+ import { SDK_PACKAGE, UPDATE_COMMAND, readProjectSdk } from '../../core/sdk.js';
8
+ import { listTemplates } from '../../core/templates.js';
9
+ import { VERSION } from '../../version.js';
10
+ import { templateNotice } from '../doctor/index.js';
11
+ import { skillsDir, reloadNotes } from '../skill/index.js';
12
+
13
+ const usage = `사용법: ecdk update [--check] [--yes] [--json]
14
+
15
+ npm latest 태그의 ecdk로 올린다. 차례로:
16
+ 1. CLI 설치: npm install -g ${CLI_PACKAGE}@<latest> (npx로 실행 중이면 건너뜀)
17
+ 2. 스킬 갱신: 새로 설치한 ecdk로 ecdk setup --only skills (npx면 npx -y ${CLI_PACKAGE}@<latest> setup --only skills)
18
+ 손으로 고친 스킬은 그대로 둠, 바꾸려면 ecdk setup --only skills --force
19
+ 3. 프로젝트 SDK: 현재 폴더가 ${SDK_PACKAGE}를 쓰는 프로젝트면 ${UPDATE_COMMAND} (화면 · 템플릿 코드는 바꾸지 않음)
20
+ 지금 버전이 latest와 같거나 더 새 버전이면 아무것도 하지 않는다 (내리지 않음).
21
+ --check 확인만 (지금 · 최신 버전과 실행할 명령)
22
+ --yes 묻지 않고 실행 (지금은 늘 묻지 않음, 스크립트용)
23
+
24
+ 종료 코드: 0 최신이거나 업데이트함 · 1 최신 버전 확인 실패 · 단계 실패 · 2 잘못된 사용`;
25
+ /** 실행 못 함(명령 없음 등)은 code -1 */
26
+ function runCommand(command, args, opts = {}) {
27
+ return new Promise(done => {
28
+ const child = spawn(command, args, {
29
+ cwd: opts.cwd,
30
+ stdio: ['ignore', 'pipe', 'pipe'],
31
+ shell: process.platform === 'win32'
32
+ });
33
+ let output = '';
34
+ const tee = chunk => {
35
+ output += chunk.toString();
36
+ if (!opts.quiet) process.stderr.write(chunk);
37
+ };
38
+ child.stdout.on('data', tee);
39
+ child.stderr.on('data', tee);
40
+ child.on('error', e => done({
41
+ code: -1,
42
+ output: `${output}${e.message}`
43
+ }));
44
+ child.on('close', code => done({
45
+ code: code ?? 1,
46
+ output
47
+ }));
48
+ });
49
+ }
50
+ function defaultUpdateEnv() {
51
+ return {
52
+ latest: npmLatest,
53
+ scriptPath: fileURLToPath(import.meta.url),
54
+ cwd: process.cwd(),
55
+ run: runCommand,
56
+ log: line => process.stderr.write(`${line}\n`)
57
+ };
58
+ }
59
+ const isNpx = scriptPath => /[\\/]_npx[\\/]/.test(scriptPath);
60
+ const PERMISSION = /\bEACCES\b|\bEPERM\b|permission denied/i;
61
+ /** README "문제 해결 · 설치"의 EACCES 안내와 같은 문구 */
62
+ const PERMISSION_HINT = '`sudo` 대신 `npx`로 실행, 또는 fnm · Homebrew로 Node.js 재설치';
63
+ const HELPY_NOTE = "Helpy Code 데스크톱(macOS)에서 ecdk · npm을 찾지 못하면 로그인 셸로 실행합니다: zsh -ilc 'ecdk update'";
64
+ const cliCommand = latest => `npm install -g ${CLI_PACKAGE}@${latest}`;
65
+ const SKILL_ARGS = ['setup', '--only', 'skills'];
66
+ const SKILL_COMMAND = `ecdk ${SKILL_ARGS.join(' ')}`;
67
+ /**
68
+ * npx로 실행 중이면 이 프로세스(옛 캐시일 수 있음)가 아니라 latest 버전으로 스킬을 설치한다.
69
+ * 옛 ecdk의 update도 새로 설치한 ecdk를 실행하므로 새 명령(setup --only skills)을 써도 된다
70
+ */
71
+ const npxSkillArgs = latest => ['-y', `${CLI_PACKAGE}@${latest}`, ...SKILL_ARGS];
72
+ const skillCommand = (latest, npx) => npx ? ['npx', ...npxSkillArgs(latest)].join(' ') : SKILL_COMMAND;
73
+ /** 프로젝트 SDK 단계: 현재 폴더 package.json에 @eliceio/cdk가 있을 때만 */
74
+ async function projectStep(cwd) {
75
+ if (!(await readProjectSdk(cwd))) return {
76
+ id: 'project.sdk',
77
+ status: 'skipped',
78
+ message: `현재 폴더가 ${SDK_PACKAGE}를 쓰는 프로젝트가 아님`
79
+ };
80
+ return {
81
+ id: 'project.sdk',
82
+ status: 'planned',
83
+ command: UPDATE_COMMAND
84
+ };
85
+ }
86
+ /** 할 일 (아직 실행하지 않음) */
87
+ async function plan(env, latest, npx) {
88
+ return [npx ? {
89
+ id: 'cli.install',
90
+ status: 'skipped',
91
+ message: `npx로 실행 중이라 전역 설치하지 않음 (다음에 npx ${CLI_PACKAGE}@latest로 실행하면 새 버전)`
92
+ } : {
93
+ id: 'cli.install',
94
+ status: 'planned',
95
+ command: cliCommand(latest)
96
+ }, {
97
+ id: 'skill.install',
98
+ status: 'planned',
99
+ command: skillCommand(latest, npx),
100
+ message: npx ? `npx로 ${latest} ecdk를 받아 설치` : '새로 설치한 ecdk로 설치'
101
+ }, await projectStep(env.cwd)];
102
+ }
103
+ /** 새로 설치한 ecdk의 템플릿 목록. 읽지 못하면 undefined (안내만 빠짐) */
104
+ async function installedTemplates(env) {
105
+ const r = await env.run('ecdk', ['create', '--list', '--json'], {
106
+ quiet: true
107
+ });
108
+ if (r.code !== 0) return undefined;
109
+ try {
110
+ return JSON.parse(r.output.slice(r.output.indexOf('{'))).templates;
111
+ } catch {
112
+ return undefined;
113
+ }
114
+ }
115
+ async function update(env, opts) {
116
+ const current = opts.current ?? VERSION;
117
+ const npx = isNpx(env.scriptPath);
118
+ // JSON 필드 순서를 늘 같게
119
+ const make = fields => ({
120
+ ok: fields.ok,
121
+ current,
122
+ latest: fields.latest,
123
+ upToDate: fields.upToDate,
124
+ npx,
125
+ steps: fields.steps ?? [],
126
+ notes: [],
127
+ skillsDirCreated: false,
128
+ ...(fields.error ? {
129
+ error: fields.error
130
+ } : {})
131
+ });
132
+ const latest = env.latest(LATEST_UPDATE_TIMEOUT_MS);
133
+ if (!latest.ok) return make({
134
+ ok: false,
135
+ latest: null,
136
+ upToDate: false,
137
+ error: `npm에서 ${CLI_PACKAGE} 최신 버전을 확인하지 못했습니다 (${latest.error}). 네트워크 · 프록시(npm config get registry)를 확인해 주세요. 아무것도 바꾸지 않았습니다.`
138
+ });
139
+ if (!isNewer(latest.version, current)) return make({
140
+ ok: true,
141
+ latest: latest.version,
142
+ upToDate: true
143
+ });
144
+ const steps = await plan(env, latest.version, npx);
145
+ const result = make({
146
+ ok: true,
147
+ latest: latest.version,
148
+ upToDate: false,
149
+ steps
150
+ });
151
+ if (opts.check) return result;
152
+ const [cli, skills, project] = steps;
153
+ const stop = from => {
154
+ for (const s of from) if (s.status === 'planned') s.status = 'not-run';
155
+ result.ok = false;
156
+ return result;
157
+ };
158
+ // 1. CLI
159
+ if (cli.status === 'planned') {
160
+ env.log(`[1/3] CLI 설치: ${cli.command}`);
161
+ const r = await env.run('npm', ['install', '-g', `${CLI_PACKAGE}@${latest.version}`]);
162
+ if (r.code !== 0) {
163
+ cli.status = 'failed';
164
+ cli.message = PERMISSION.test(r.output) ? `권한이 없어 전역 설치하지 못했습니다 (EACCES). 직접 실행해 주세요: ${cli.command} (${PERMISSION_HINT})` : `설치하지 못했습니다 (${r.code < 0 ? r.output.trim() : `종료 코드 ${r.code}`}). 직접 실행해 주세요: ${cli.command}`;
165
+ return stop([skills, project]);
166
+ }
167
+ cli.status = 'done';
168
+ } else env.log(`[1/3] CLI 설치 건너뜀: ${cli.message}`);
169
+ // 2. 스킬: 새 스킬은 새 버전에 들어 있으므로 새 ecdk로 설치한다 (PATH의 새 ecdk, npx면 npx로 latest를 받아서)
170
+ // 이 프로세스(npx 옛 캐시일 수 있음)에서 설치하면 옛 스킬을 깔고 완료로 알리게 되므로 하지 않는다
171
+ const skillCmd = skills.command ?? SKILL_COMMAND;
172
+ // 새 ecdk가 쓰기 전에 본다 (새 ecdk의 안내는 옛 ecdk와 다를 수 있어 여기서 다시 알린다)
173
+ const userSkills = skillsDir({
174
+ project: false,
175
+ home: env.home
176
+ });
177
+ const skillsDirExisted = existsSync(userSkills);
178
+ env.log(`[2/3] 스킬 갱신: ${skillCmd}`);
179
+ const sr = npx ? await env.run('npx', npxSkillArgs(latest.version)) : await env.run('ecdk', SKILL_ARGS);
180
+ if (sr.code === 0) skills.status = 'done';else if (sr.code === 1) {
181
+ skills.status = 'warn';
182
+ skills.message = `손으로 고친 스킬은 그대로 둠 (바꾸려면 ${SKILL_COMMAND} --force)`;
183
+ } else {
184
+ skills.status = 'failed';
185
+ const why = PERMISSION.test(sr.output) ? `권한이 없어 설치하지 못했습니다 (EACCES). ${PERMISSION_HINT}` : `새 ecdk를 실행하지 못했습니다 (${sr.code < 0 ? sr.output.trim() : `종료 코드 ${sr.code}`})`;
186
+ skills.message = npx ? `${why}. 직접 실행해 주세요: ${skillCmd}` : `${why}. 터미널을 새로 연 뒤 ${skillCmd}`;
187
+ }
188
+ result.skillsDirCreated = skills.status !== 'failed' && !skillsDirExisted && existsSync(userSkills);
189
+ // 3. 프로젝트 SDK (화면 · 템플릿 코드는 건드리지 않고 안내만)
190
+ if (project.status === 'planned') {
191
+ env.log(`[3/3] 프로젝트 SDK: ${UPDATE_COMMAND} (${env.cwd})`);
192
+ const r = await env.run('npm', ['update', SDK_PACKAGE], {
193
+ cwd: env.cwd
194
+ });
195
+ project.status = r.code === 0 ? 'done' : 'failed';
196
+ if (r.code !== 0) project.message = `실패 (종료 코드 ${r.code}). 프로젝트 폴더에서 직접 ${UPDATE_COMMAND}`;
197
+ try {
198
+ const templates = npx ? listTemplates() : await installedTemplates(env);
199
+ const notice = templates && templateNotice(await loadConfig(env.cwd), templates);
200
+ if (notice) result.notes.push(`프로젝트 템플릿 ${notice}`);
201
+ } catch {
202
+ // 설정을 읽지 못하면 안내만 빠진다 (ecdk doctor가 알림)
203
+ }
204
+ } else env.log(`[3/3] 프로젝트 SDK 건너뜀: ${project.message}`);
205
+ result.ok = !steps.some(s => s.status === 'failed');
206
+ return result;
207
+ }
208
+ const STATUS = {
209
+ planned: '할 일',
210
+ done: '완료',
211
+ warn: '완료 (확인할 것 있음)',
212
+ skipped: '건너뜀',
213
+ failed: '실패',
214
+ 'not-run': '실행 안 함'
215
+ };
216
+ const STEP_NAME = {
217
+ 'cli.install': 'CLI 설치',
218
+ 'skill.install': '스킬 갱신',
219
+ 'project.sdk': '프로젝트 SDK'
220
+ };
221
+ function formatText(r, check) {
222
+ if (r.error) return r.error;
223
+ const lines = [`ecdk ${r.current} · npm latest ${r.latest ?? '-'}`];
224
+ if (r.upToDate) {
225
+ lines.push(r.latest === r.current ? '최신입니다.' : `최신입니다 (지금 버전이 npm latest보다 새 버전이라 내리지 않음).`);
226
+ return lines.join('\n');
227
+ }
228
+ if (check) lines.push('새 버전이 있습니다. ecdk update가 할 일:');
229
+ r.steps.forEach((s, i) => {
230
+ const detail = [s.command, s.message].filter(Boolean).join(' · ');
231
+ lines.push(` ${i + 1}. ${STEP_NAME[s.id]}: ${check ? detail : `${STATUS[s.status]}${detail ? ` · ${detail}` : ''}`}`);
232
+ });
233
+ for (const n of r.notes) lines.push('', n);
234
+ if (check) lines.push('', '실행: ecdk update');else if (r.ok) lines.push('', ...reloadNotes(r.skillsDirCreated), HELPY_NOTE);else lines.push('', '업데이트가 끝나지 않았습니다. 위 실패 단계의 명령을 직접 실행해 주세요.');
235
+ return lines.join('\n');
236
+ }
237
+ async function run(args, env = defaultUpdateEnv(), current) {
238
+ const result = await update({
239
+ ...env,
240
+ cwd: resolve(env.cwd)
241
+ }, {
242
+ check: args.check,
243
+ current
244
+ });
245
+ return {
246
+ exitCode: result.ok ? 0 : 1,
247
+ output: args.json ? JSON.stringify(result, null, 2) : formatText(result, args.check)
248
+ };
249
+ }
250
+
251
+ export { PERMISSION_HINT, defaultUpdateEnv, formatText, isNpx, run, update, usage };
@@ -1,6 +1,6 @@
1
1
  import type { CheckResult } from '../../rules/index.js';
2
2
  import type { CommandResult } from '../../types.js';
3
- export declare const usage = "\uC0AC\uC6A9\uBC95: ecdk check [\uACBD\uB85C] [--json]\n\n \uACBD\uB85C \uD3F4\uB354, .zip, .html (\uAE30\uBCF8\uAC12: \uD604\uC7AC \uD3F4\uB354)\n ecdk \uD504\uB85C\uC81D\uD2B8 \uD3F4\uB354(package.json\uC5D0 \"ecdk\" \uD0A4\uB098 @eliceio/cdk \uC758\uC874\uC131, \uC61B elice.config.json)\uB294\n ecdk build\uAC00 \uB9CC\uB4E4 zip \uAE30\uC900\uC73C\uB85C \uAC80\uC0AC\uD55C\uB2E4\n (\uC815\uB2F5 \u00B7 \uC124\uC815 \u00B7 \uAC1C\uBC1C\uC6A9 \uD30C\uC77C\uC744 \uBE7C\uACE0 metadata.json\uC744 \uB9CC\uB4E0 \uB4A4). \uADF8 \uBC16\uC758 \uD3F4\uB354\uB294 \uADF8\uB300\uB85C \uC62C\uB9B4 zip\uC73C\uB85C \uBCF8\uB2E4\n --json \uAE30\uACC4\uC6A9 \uCD9C\uB825 (Claude \uC2A4\uD0AC\u00B7CI)\n\n\uC885\uB8CC \uCF54\uB4DC: 0 \uD1B5\uACFC \u00B7 1 \uC624\uB958 \uC788\uC74C \u00B7 2 \uC798\uBABB\uB41C \uC0AC\uC6A9";
3
+ export declare const usage = "\uC0AC\uC6A9\uBC95: ecdk validate [\uACBD\uB85C] [--json]\n\n \uACBD\uB85C \uD3F4\uB354, .zip, .html (\uAE30\uBCF8\uAC12: \uD604\uC7AC \uD3F4\uB354)\n ecdk \uD504\uB85C\uC81D\uD2B8 \uD3F4\uB354(package.json\uC5D0 \"ecdk\" \uD0A4\uB098 @eliceio/cdk \uC758\uC874\uC131, \uC61B elice.config.json)\uB294\n ecdk build\uAC00 \uB9CC\uB4E4 zip \uAE30\uC900\uC73C\uB85C \uAC80\uC0AC\uD55C\uB2E4\n (\uC815\uB2F5 \u00B7 \uC124\uC815 \u00B7 \uAC1C\uBC1C\uC6A9 \uD30C\uC77C\uC744 \uBE7C\uACE0 metadata.json\uC744 \uB9CC\uB4E0 \uB4A4). \uADF8 \uBC16\uC758 \uD3F4\uB354\uB294 \uADF8\uB300\uB85C \uC62C\uB9B4 zip\uC73C\uB85C \uBCF8\uB2E4\n --json \uAE30\uACC4\uC6A9 \uCD9C\uB825 (Claude \uC2A4\uD0AC\u00B7CI)\n\n\uC885\uB8CC \uCF54\uB4DC: 0 \uD1B5\uACFC \u00B7 1 \uC624\uB958 \uC788\uC74C \u00B7 2 \uC798\uBABB\uB41C \uC0AC\uC6A9";
4
4
  /** 검사 방식: project = build가 만들 zip 기준, path = 주어진 폴더 · zip · html을 그대로 */
5
5
  export type CheckMode = 'project' | 'path';
6
6
  /**
@@ -10,7 +10,7 @@ import '../../rules/spec.js';
10
10
  import 'fflate';
11
11
  import { checkPath } from '../../rules/node.js';
12
12
 
13
- const usage = `사용법: ecdk check [경로] [--json]
13
+ const usage = `사용법: ecdk validate [경로] [--json]
14
14
 
15
15
  경로 폴더, .zip, .html (기본값: 현재 폴더)
16
16
  ecdk 프로젝트 폴더(package.json에 "ecdk" 키나 @eliceio/cdk 의존성, 옛 elice.config.json)는
@@ -1,8 +1,8 @@
1
1
  import { readdir, readFile } from 'node:fs/promises';
2
2
  import { join, relative, sep } from 'node:path';
3
3
  import 'fflate';
4
- import { globToRegExp } from '../rules/path.js';
5
4
  import { rules } from '../rules/spec.js';
5
+ import { globToRegExp } from '../rules/path.js';
6
6
 
7
7
  /** 콘텐츠가 아니라 프로젝트 도구가 쓰는 파일. 원본 폴더가 프로젝트 루트일 때 빠진다. */
8
8
  const PROJECT_FILES = ['package.json', 'package-lock.json', 'pnpm-lock.yaml', 'pnpm-workspace.yaml', 'yarn.lock', 'bun.lockb', 'tsconfig*.json', '*.d.ts',