@modootoday/datalab-extension-mcp 1.12.0 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.en.md +12 -25
  2. package/README.md +12 -24
  3. package/dist/{chunk-OOT6JOYE.js → chunk-C6TR4AD5.js} +39 -9
  4. package/dist/cli.js +5 -36
  5. package/dist/{dist-H4FFG2Z2.js → dist-ME5TF3Z7.js} +1090 -1146
  6. package/dist/index.d.ts +0 -2
  7. package/dist/index.js +1 -1
  8. package/package.json +2 -3
  9. package/dist/skills-5JDMNON3.js +0 -101
  10. package/skills/datalab-ad-budget-review/SKILL.md +0 -37
  11. package/skills/datalab-ad-disclosure-check/SKILL.md +0 -86
  12. package/skills/datalab-ad-disclosure-check/references/ad-disclosure-rules.md +0 -98
  13. package/skills/datalab-ad-disclosure-check/references/naver-terms-excerpt.md +0 -28
  14. package/skills/datalab-blog-diagnosis/SKILL.md +0 -39
  15. package/skills/datalab-blog-widget/SKILL.md +0 -76
  16. package/skills/datalab-blog-widget/references/naver-constraints.md +0 -51
  17. package/skills/datalab-blog-widget/references/templates.md +0 -123
  18. package/skills/datalab-card-news/SKILL.md +0 -105
  19. package/skills/datalab-card-news/references/slide-structure.md +0 -48
  20. package/skills/datalab-comment-reaction/SKILL.md +0 -37
  21. package/skills/datalab-commerce-health/SKILL.md +0 -37
  22. package/skills/datalab-cta-rewrite/SKILL.md +0 -66
  23. package/skills/datalab-cta-rewrite/references/output-format.md +0 -24
  24. package/skills/datalab-cta-rewrite/references/principles.md +0 -36
  25. package/skills/datalab-material-suggestion/SKILL.md +0 -81
  26. package/skills/datalab-material-suggestion/references/discovery.md +0 -47
  27. package/skills/datalab-material-suggestion/references/output-format.md +0 -41
  28. package/skills/datalab-naver-workbench/SKILL.md +0 -37
  29. package/skills/datalab-place-reputation/SKILL.md +0 -38
  30. package/skills/datalab-pumasi/SKILL.md +0 -36
  31. package/skills/datalab-reader-simulation/SKILL.md +0 -94
  32. package/skills/datalab-reader-simulation/references/checklist-format.md +0 -36
  33. package/skills/datalab-research-brief/SKILL.md +0 -88
  34. package/skills/datalab-research-brief/references/brief-format.md +0 -39
  35. package/skills/datalab-shopping-demand/SKILL.md +0 -37
  36. package/skills/datalab-social-repurpose/SKILL.md +0 -81
  37. package/skills/datalab-social-repurpose/references/output-format.md +0 -43
  38. package/skills/datalab-social-repurpose/references/platform-specs.md +0 -44
  39. package/skills/datalab-tone-manner/SKILL.md +0 -70
  40. package/skills/datalab-tone-manner/references/analysis-dimensions.md +0 -51
  41. package/skills/datalab-tone-manner/references/spec-format.md +0 -58
  42. package/skills/datalab-tutorial-post/SKILL.md +0 -72
  43. package/skills/datalab-tutorial-post/references/analogy-and-case-templates.md +0 -37
  44. package/skills/datalab-tutorial-post/references/structure-and-length.md +0 -22
  45. package/skills/datalab-tutorial-post/references/tone-and-hooks.md +0 -26
  46. package/skills/datalab-video-script/SKILL.md +0 -96
  47. package/skills/datalab-video-script/references/scene-structure.md +0 -41
  48. package/skills/datalab-video-script/references/writing-for-the-ear.md +0 -22
@@ -1,33 +1,10 @@
1
1
  import "./chunk-MLKGABMK.js";
2
2
 
3
3
  // ../mcp-installer/dist/index.js
4
- import { join as joinNative } from "path";
5
- import { fileURLToPath } from "url";
6
4
  import { execFile, spawn as nodeSpawn } from "child_process";
7
5
  import { promises as fs } from "fs";
8
6
  import { homedir } from "os";
9
7
  import { createInterface } from "readline";
10
- var WORDMARK = "\uB370\uC774\uD130\uB7A9\uD234\uC988 \xB7 datalab.tools";
11
- var RULE = "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500";
12
- function printBanner(out, subtitle) {
13
- out("");
14
- out(WORDMARK);
15
- out(subtitle);
16
- out(RULE);
17
- }
18
- function printStep(out, step, total, title) {
19
- out("");
20
- out(`[${String(step)}/${String(total)}] ${title}`);
21
- }
22
- function printBody(out, text) {
23
- out(` ${text}`);
24
- }
25
- function printItem(out, title, detail) {
26
- out(` - ${title}`);
27
- if (detail) out(` ${detail}`);
28
- }
29
- var INSTALL_SUBTITLE = "\uC5F0\uACB0 \uD504\uB85C\uADF8\uB7A8 \uC124\uCE58 \uB3C4\uC6B0\uBBF8";
30
- var UNINSTALL_SUBTITLE = "\uC5F0\uACB0 \uD504\uB85C\uADF8\uB7A8 \uC815\uB9AC \uB3C4\uC6B0\uBBF8";
31
8
  var SERVER_NAME = "datalab";
32
9
  var SERVER_PACKAGE = "@modootoday/datalab-extension-mcp";
33
10
  var DEFAULT_PORT = "8765";
@@ -881,372 +858,119 @@ var SUPPORTED_APPS = [
881
858
  { name: "LM Studio", url: "https://lmstudio.ai/" },
882
859
  { name: "Warp", url: "https://www.warp.dev/" }
883
860
  ];
884
- var MARKER_NAME = ".datalab-installed.json";
885
- var SOURCE = "@modootoday/datalab-extension-mcp";
886
- function join(io, ...parts) {
887
- return io.platform === "win32" ? parts.join("\\") : parts.join("/");
888
- }
889
- function dirOf(rel) {
890
- const cut2 = rel.lastIndexOf("/");
891
- return cut2 === -1 ? "" : rel.slice(0, cut2);
892
- }
893
- async function readMarker(io, dir) {
894
- const path = join(io, dir, MARKER_NAME);
895
- if (!await io.exists(path)) {
896
- return "none";
861
+ var CATALOG_SERVER_NAME = "modoo-today-skills";
862
+ var CATALOG_URL = "https://skills.modoo.today/mcp";
863
+ var COMMANDS = {
864
+ claude: {
865
+ bin: "claude",
866
+ add: () => [
867
+ "mcp",
868
+ "add",
869
+ "--transport",
870
+ "http",
871
+ CATALOG_SERVER_NAME,
872
+ CATALOG_URL,
873
+ "--scope",
874
+ "user"
875
+ ],
876
+ remove: () => ["mcp", "remove", CATALOG_SERVER_NAME, "--scope", "user"]
877
+ },
878
+ codex: {
879
+ bin: "codex",
880
+ add: () => ["mcp", "add", CATALOG_SERVER_NAME, "--url", CATALOG_URL],
881
+ remove: () => ["mcp", "remove", CATALOG_SERVER_NAME]
897
882
  }
898
- let raw;
899
- try {
900
- raw = await io.readFile(path);
901
- } catch {
902
- return "bad";
883
+ };
884
+ function catalogCommand(hostId) {
885
+ return COMMANDS[hostId] ?? null;
886
+ }
887
+ var DESKTOP_IDS = /* @__PURE__ */ new Set(["claude-desktop", "claude-desktop-linux"]);
888
+ function catalogGuide(hostId) {
889
+ if (DESKTOP_IDS.has(hostId)) {
890
+ return ["\uC124\uC815 \u203A \uCEE4\uB125\uD130 \u203A \uC0AC\uC6A9\uC790 \uC9C0\uC815 \uCEE4\uB125\uD130 \uCD94\uAC00", `\uC8FC\uC18C ${CATALOG_URL}`];
891
+ }
892
+ return [
893
+ "MCP \uC124\uC815\uC5D0 \uC6D0\uACA9(HTTP) \uC11C\uBC84\uB85C \uC544\uB798\uB97C \uCD94\uAC00\uD574 \uC8FC\uC138\uC694.",
894
+ `\uC774\uB984 ${CATALOG_SERVER_NAME}`,
895
+ `\uC8FC\uC18C ${CATALOG_URL}`
896
+ ];
897
+ }
898
+ async function detectHosts(io) {
899
+ const detected = [];
900
+ const cliDetected = /* @__PURE__ */ new Set();
901
+ for (const host of CLI_HOSTS) {
902
+ if (!await cliResponds(io, host)) continue;
903
+ cliDetected.add(host.id);
904
+ detected.push({
905
+ tier: 1,
906
+ id: host.id,
907
+ displayName: host.displayName,
908
+ cli: host
909
+ });
903
910
  }
904
- try {
905
- const parsed = JSON.parse(raw);
906
- if (typeof parsed !== "object" || parsed === null || typeof parsed.source !== "string" || !Array.isArray(parsed.files)) {
907
- return "bad";
908
- }
909
- return parsed;
910
- } catch {
911
- return "bad";
911
+ for (const host of FILE_HOSTS) {
912
+ const configPath = await presentConfigPath(io, host);
913
+ if (configPath === null) continue;
914
+ detected.push({
915
+ tier: 2,
916
+ id: host.id,
917
+ displayName: host.displayName,
918
+ file: host,
919
+ configPath
920
+ });
912
921
  }
913
- }
914
- async function inspectSkillDir(io, root, slug) {
915
- const dir = join(io, root, slug);
916
- if (!await io.exists(dir)) {
917
- return { kind: "absent" };
922
+ for (const host of SNIPPET_HOSTS) {
923
+ if (!await snippetPresent(io, host, cliDetected)) continue;
924
+ detected.push({
925
+ tier: 3,
926
+ id: host.id,
927
+ displayName: host.displayName,
928
+ snippet: host
929
+ });
918
930
  }
919
- const marker = await readMarker(io, dir);
920
- if (marker === "none") return { kind: "refused", refusal: "unmarked" };
921
- if (marker === "bad") return { kind: "refused", refusal: "unreadable" };
922
- if (marker.source !== SOURCE) return { kind: "refused", refusal: "foreign" };
923
- return {
924
- kind: "ours",
925
- version: marker.version,
926
- installedAt: marker.installedAt
927
- };
931
+ return detected;
928
932
  }
929
- async function installSkillDir(io, root, payload, version) {
930
- const dir = join(io, root, payload.slug);
931
- const files = [];
932
- if (await io.exists(dir)) {
933
- const marker2 = await readMarker(io, dir);
934
- if (marker2 === "none") {
935
- return { ok: false, path: dir, refusal: "unmarked", files };
936
- }
937
- if (marker2 === "bad") {
938
- return { ok: false, path: dir, refusal: "unreadable", files };
939
- }
940
- if (marker2.source !== SOURCE) {
941
- return { ok: false, path: dir, refusal: "foreign", files };
942
- }
943
- }
944
- await io.mkdir(dir);
945
- for (const [rel, content] of payload.files) {
946
- const sub = dirOf(rel);
947
- if (sub !== "") {
948
- await io.mkdir(join(io, dir, ...sub.split("/")));
949
- }
950
- await io.writeFile(join(io, dir, ...rel.split("/")), content);
951
- files.push(rel);
952
- }
953
- const marker = {
954
- source: SOURCE,
955
- version,
956
- installedAt: io.now().toISOString(),
957
- files
958
- };
959
- await io.writeFile(
960
- join(io, dir, MARKER_NAME),
961
- `${JSON.stringify(marker, null, 2)}
962
- `
963
- );
964
- return { ok: true, path: dir, files };
933
+ function filterByRequestedHosts(detected, hosts) {
934
+ if (hosts === void 0 || hosts.length === 0) return detected;
935
+ return detected.filter((d) => hosts.includes(d.id));
965
936
  }
966
- async function removeSkillDir(io, root, slug) {
967
- const dir = join(io, root, slug);
968
- const removed = [];
969
- if (!await io.exists(dir)) {
970
- return { ok: true, path: dir, files: removed };
971
- }
972
- const marker = await readMarker(io, dir);
973
- if (marker === "none") {
974
- return { ok: false, path: dir, refusal: "unmarked", files: removed };
975
- }
976
- if (marker === "bad") {
977
- return { ok: false, path: dir, refusal: "unreadable", files: removed };
978
- }
979
- if (marker.source !== SOURCE) {
980
- return { ok: false, path: dir, refusal: "foreign", files: removed };
981
- }
982
- for (const rel of marker.files) {
983
- const path = join(io, dir, ...rel.split("/"));
984
- try {
985
- await io.unlink(path);
986
- removed.push(rel);
987
- } catch {
988
- }
989
- }
937
+ async function cliResponds(io, host) {
990
938
  try {
991
- await io.unlink(join(io, dir, MARKER_NAME));
939
+ const result = await io.spawn(host.bin, ["--version"], {
940
+ shell: io.platform === "win32"
941
+ });
942
+ return result.code === 0;
992
943
  } catch {
944
+ return false;
993
945
  }
994
- const subs = [...new Set(marker.files.map(dirOf).filter((d) => d !== ""))];
995
- for (const sub of subs.sort((a, b) => b.length - a.length)) {
946
+ }
947
+ async function presentConfigPath(io, host) {
948
+ let configPath = null;
949
+ if (host.resolveConfigPath !== void 0) {
996
950
  try {
997
- await io.rmdir(join(io, dir, ...sub.split("/")));
951
+ configPath = await host.resolveConfigPath(io);
998
952
  } catch {
953
+ configPath = null;
999
954
  }
1000
955
  }
1001
- try {
1002
- await io.rmdir(dir);
1003
- } catch {
1004
- }
1005
- return { ok: true, path: dir, files: removed };
1006
- }
1007
- var PAYLOAD_DIR = "skills";
1008
- function skillsPayloadRoot() {
1009
- const here = fileURLToPath(new URL(".", import.meta.url));
1010
- return joinNative(here, "..", PAYLOAD_DIR);
1011
- }
1012
- function join2(io, ...parts) {
1013
- return io.platform === "win32" ? parts.join("\\") : parts.join("/");
1014
- }
1015
- async function readPayloads(io, root) {
1016
- if (!await io.exists(root)) {
1017
- return null;
1018
- }
1019
- const out = [];
1020
- for (const slug of await io.listDir(root)) {
1021
- const files = /* @__PURE__ */ new Map();
1022
- const skillMd = join2(io, root, slug, "SKILL.md");
1023
- if (!await io.exists(skillMd)) {
1024
- continue;
1025
- }
1026
- const skillText = await io.readFile(skillMd);
1027
- files.set("SKILL.md", skillText);
1028
- const refs = join2(io, root, slug, "references");
1029
- if (await io.exists(refs)) {
1030
- for (const name of await io.listDir(refs)) {
1031
- files.set(
1032
- `references/${name}`,
1033
- await io.readFile(join2(io, refs, name))
1034
- );
1035
- }
1036
- }
1037
- const declared = /^\s+install:\s*([^\s]+)\s*$/m.exec(skillText)?.[1];
1038
- const install = declared === "optional" ? "optional" : declared === void 0 || declared === "default" ? "default" : "optional";
1039
- out.push({ slug, install, files });
1040
- }
1041
- return out;
1042
- }
1043
- function descriptionOf(skillMd) {
1044
- const block = /^---\n([\s\S]*?)\n---/.exec(skillMd)?.[1] ?? "";
1045
- const raw = /^description:\s*(.+)$/m.exec(block)?.[1]?.trim() ?? "";
1046
- return raw.split(/(?<=[.。])\s|(?<=다)\.\s/)[0] ?? raw;
1047
- }
1048
- function parseSkillSelection(answer, optional) {
1049
- const value = answer.trim();
1050
- if (value === "") return /* @__PURE__ */ new Set();
1051
- if (["a", "all", "\uC804\uCCB4"].includes(value.toLowerCase())) {
1052
- return new Set(optional.map((payload) => payload.slug));
1053
- }
1054
- const selected = /* @__PURE__ */ new Set();
1055
- for (const token of value.split(/[,\s]+/).filter(Boolean)) {
1056
- const number = Number(token);
1057
- const byNumber = Number.isInteger(number) ? optional[number - 1] : void 0;
1058
- const bySlug = optional.find((payload2) => payload2.slug === token);
1059
- const payload = byNumber ?? bySlug;
1060
- if (!payload) return null;
1061
- selected.add(payload.slug);
1062
- }
1063
- return selected;
1064
- }
1065
- async function chooseSkillSelection(io, staged, options = {}) {
1066
- const defaults = staged.filter((payload) => payload.install === "default");
1067
- const optional = staged.filter((payload) => payload.install === "optional");
1068
- let selected = /* @__PURE__ */ new Set();
1069
- if (options.all === true) {
1070
- selected = new Set(optional.map((payload) => payload.slug));
1071
- } else if ((options.requested?.length ?? 0) > 0) {
1072
- const known = new Set(staged.map((payload) => payload.slug));
1073
- const unknown = [...new Set(options.requested)].filter(
1074
- (slug) => !known.has(slug)
1075
- );
1076
- if (unknown.length > 0) {
1077
- io.out(`\uC120\uD0DD\uD560 \uC218 \uC5C6\uB294 \uC2A4\uD0AC: ${unknown.join(", ")}`);
1078
- return null;
1079
- }
1080
- selected = new Set(
1081
- options.requested?.filter(
1082
- (slug) => optional.some((payload) => payload.slug === slug)
1083
- )
1084
- );
1085
- } else if (options.interactive === true && optional.length > 0) {
1086
- printBody(
1087
- (line) => io.out(line),
1088
- `\uCD94\uCC9C \uC2A4\uD0AC ${defaults.length}\uAC1C\uB294 \uAE30\uBCF8\uC73C\uB85C \uC124\uCE58\uD574\uC694.`
1089
- );
1090
- printBody((line) => io.out(line), "\uD544\uC694\uD55C \uCD94\uAC00 \uC2A4\uD0AC\uC744 \uACE8\uB77C \uC8FC\uC138\uC694.");
1091
- optional.forEach((payload, index) => {
1092
- const description = descriptionOf(payload.files.get("SKILL.md") ?? "");
1093
- printItem(
1094
- (line) => io.out(line),
1095
- `${index + 1}. ${payload.slug}`,
1096
- description
1097
- );
1098
- });
1099
- for (let attempt = 0; attempt < 2; attempt += 1) {
1100
- const answer = await io.prompt(
1101
- " \uCD94\uAC00\uD560 \uBC88\uD638\uB97C \uC785\uB825\uD574 \uC8FC\uC138\uC694 (\uC608: 1,3 / all = \uC804\uCCB4 / Enter = \uAC74\uB108\uB6F0\uAE30):"
1102
- );
1103
- const parsed = parseSkillSelection(answer, optional);
1104
- if (parsed !== null) {
1105
- selected = parsed;
1106
- break;
1107
- }
1108
- io.out(" \uBC88\uD638\uB098 \uC2A4\uD0AC \uC774\uB984\uC744 \uBAA9\uB85D\uC5D0 \uB9DE\uAC8C \uB2E4\uC2DC \uC785\uB825\uD574 \uC8FC\uC138\uC694.");
1109
- if (attempt === 1) return null;
1110
- }
1111
- }
1112
- return {
1113
- selected,
1114
- defaultCount: defaults.length,
1115
- optionalCount: optional.length,
1116
- total: defaults.length + selected.size
1117
- };
1118
- }
1119
- var REFUSAL_MESSAGE = {
1120
- unmarked: "\uB2E4\uB978 \uB3C4\uAD6C\uAC00 \uB9CC\uB4E0 \uD3F4\uB354\uAC00 \uC788\uC5B4 \uAC74\uB4DC\uB9AC\uC9C0 \uC54A\uC558\uC5B4\uC694.",
1121
- foreign: "\uB2E4\uB978 \uB3C4\uAD6C\uAC00 \uC124\uCE58\uD55C \uC2A4\uD0AC\uC774 \uC788\uC5B4 \uADF8\uB300\uB85C \uB480\uC5B4\uC694.",
1122
- unreadable: "\uC124\uCE58 \uD45C\uC2DD\uC744 \uC77D\uC744 \uC218 \uC5C6\uC5B4 \uAC74\uB4DC\uB9AC\uC9C0 \uC54A\uC558\uC5B4\uC694."
1123
- };
1124
- async function placeSkills(io, payloadRoot, detectedIds, version, selection = false) {
1125
- const results = [];
1126
- const staged = await readPayloads(io, payloadRoot);
1127
- if (staged === null || staged.length === 0) {
1128
- return results;
1129
- }
1130
- const payloads = selection === true ? staged : staged.filter(
1131
- (payload) => payload.install === "default" || selection instanceof Set && selection.has(payload.slug)
956
+ configPath ??= host.configPath(io);
957
+ if (configPath === null) return null;
958
+ if (await io.exists(configPath)) return configPath;
959
+ const cut2 = Math.max(
960
+ configPath.lastIndexOf("/"),
961
+ configPath.lastIndexOf("\\")
1132
962
  );
1133
- const held = staged.length - payloads.length;
1134
- for (const host of SKILL_HOSTS) {
1135
- if (!detectedIds.has(host.id)) {
1136
- continue;
1137
- }
1138
- if (host.skills.tier === 3) {
1139
- results.push({
1140
- hostId: host.id,
1141
- displayName: host.displayName,
1142
- tier: 3,
1143
- status: "skipped",
1144
- surface: "skills",
1145
- message: `${host.skills.reason} ${host.skills.instruction}`
1146
- });
1147
- continue;
1148
- }
1149
- const dir = host.skills.skillsDir(io);
1150
- if (dir === null) {
1151
- continue;
1152
- }
1153
- const refused = [];
1154
- let placed = 0;
1155
- for (const payload of payloads) {
1156
- const out = await installSkillDir(io, dir, payload, version);
1157
- if (out.ok) {
1158
- placed += 1;
1159
- } else {
1160
- refused.push(`${payload.slug}: ${REFUSAL_MESSAGE[out.refusal ?? ""]}`);
1161
- }
1162
- }
1163
- const heldNote = held > 0 ? ` (\uC870\uAC74\uBD80 ${held}\uAC1C \uC81C\uC678)` : "";
1164
- results.push({
1165
- hostId: host.id,
1166
- displayName: host.displayName,
1167
- tier: 2,
1168
- status: placed > 0 ? "success" : "skipped",
1169
- surface: "skills",
1170
- message: refused.length > 0 ? `\uC2A4\uD0AC ${placed}\uAC1C\uB97C \uC124\uCE58\uD588\uC5B4\uC694. ${refused.join(" ")}${heldNote}` : `\uC2A4\uD0AC ${placed}\uAC1C\uB97C \uC124\uCE58\uD588\uC5B4\uC694.${heldNote}`
1171
- });
963
+ if (cut2 > 0 && await io.exists(configPath.slice(0, cut2))) {
964
+ return configPath;
1172
965
  }
1173
- return results;
1174
- }
1175
- async function stagedSlugs(io, root) {
1176
- const payloads = await readPayloads(io, root);
1177
- return payloads === null ? [] : payloads.map((p) => p.slug);
966
+ return null;
1178
967
  }
1179
- async function removeSkills(io, detectedIds, slugs) {
1180
- const results = [];
1181
- for (const host of SKILL_HOSTS) {
1182
- if (!detectedIds.has(host.id) || host.skills.tier !== 2) {
1183
- continue;
1184
- }
1185
- const dir = host.skills.skillsDir(io);
1186
- if (dir === null) {
1187
- continue;
1188
- }
1189
- let removed = 0;
1190
- const kept = [];
1191
- for (const slug of slugs) {
1192
- const out = await removeSkillDir(io, dir, slug);
1193
- if (out.ok) {
1194
- removed += out.files.length > 0 ? 1 : 0;
1195
- } else {
1196
- kept.push(slug);
1197
- }
1198
- }
1199
- results.push({
1200
- hostId: host.id,
1201
- displayName: host.displayName,
1202
- tier: 2,
1203
- status: "success",
1204
- surface: "skills",
1205
- message: kept.length > 0 ? `\uC2A4\uD0AC ${removed}\uAC1C\uB97C \uC81C\uAC70\uD588\uC5B4\uC694. ${kept.length}\uAC1C\uB294 \uC6B0\uB9AC\uAC00 \uC124\uCE58\uD55C \uAC83\uC774 \uC544\uB2C8\uB77C \uADF8\uB300\uB85C \uB480\uC5B4\uC694.` : `\uC2A4\uD0AC ${removed}\uAC1C\uB97C \uC81C\uAC70\uD588\uC5B4\uC694.`
1206
- });
968
+ async function snippetPresent(io, host, cliDetected) {
969
+ try {
970
+ return await host.detect(io, { cliDetected });
971
+ } catch {
972
+ return false;
1207
973
  }
1208
- return results;
1209
- }
1210
- var RESTART_NOTICE = "\uB9C8\uC9C0\uB9C9 \uD55C \uB2E8\uACC4: AI \uC571\uC744 \uC644\uC804\uD788 \uC885\uB8CC\uD588\uB2E4\uAC00 \uB2E4\uC2DC \uC2E4\uD589\uD574 \uC8FC\uC138\uC694.\n(Windows: \uC791\uC5C5 \uD45C\uC2DC\uC904 \uD2B8\uB808\uC774 \uC544\uC774\uCF58\uC5D0\uC11C \uC885\uB8CC)";
1211
- var NOTHING_CHANGED = "\uC544\uBB34\uAC83\uB3C4 \uBC14\uAFB8\uC9C0 \uC54A\uC558\uC5B4\uC694.";
1212
- var UNINSTALL_DONE = "\uC815\uB9AC\uAC00 \uB05D\uB0AC\uC5B4\uC694.";
1213
- var UNINSTALL_TOKEN_REMINDER = "\uC774 \uBE0C\uB77C\uC6B0\uC800\uC758 \uB85C\uCEEC \uC5F0\uACB0 \uC815\uBCF4\uB3C4 \uC9C0\uC6B0\uB824\uBA74 \uB370\uC774\uD130\uB7A9\uD234\uC988 \uD328\uB110\uC5D0\uC11C '\uC774 \uBE0C\uB77C\uC6B0\uC800 \uC5F0\uACB0 \uB044\uAE30'\uB97C \uB20C\uB7EC \uC8FC\uC138\uC694. \uC774 \uCEF4\uD4E8\uD130\uC758 \uB4F1\uB85D\uC740 \uB4F1\uB85D\uB41C \uBE0C\uB77C\uC6B0\uC800 \uBAA9\uB85D\uC5D0\uC11C \uBCC4\uB3C4\uB85C \uB0B4\uB9B4 \uC218 \uC788\uC5B4\uC694.";
1214
- var PERMISSION_DENIED_HINT = "\uD30C\uC77C \uAD8C\uD55C \uB54C\uBB38\uC5D0 \uC124\uC815\uC744 \uC4F8 \uC218 \uC5C6\uC5C8\uC5B4\uC694. \uD30C\uC77C \uAD8C\uD55C\uC744 \uD655\uC778\uD55C \uB4A4 \uAC19\uC740 \uBA85\uB839\uC5B4\uB97C \uB2E4\uC2DC \uC2E4\uD589\uD574 \uC8FC\uC138\uC694.";
1215
- var NO_HOSTS_DETECTED = "\uC5F0\uACB0\uD560 \uC218 \uC788\uB294 AI \uD504\uB85C\uADF8\uB7A8\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC5B4\uC694.";
1216
- var FALLBACK_TAIL = "\uADF8\uB798\uC11C AI \uC571\uC774 \uC2DC\uC791\uD560 \uB54C\uB9C8\uB2E4 \uB0B4\uB824\uBC1B\uC544 \uC2E4\uD589\uD558\uB3C4\uB85D \uC5F0\uACB0\uD574\uC694. \uC5F0\uACB0\uC740 \uB418\uC9C0\uB9CC \uC2DC\uC791\uC774 10\uCD08\uCBE4 \uB2A6\uC5B4\uC694.";
1217
- var GLOBAL_INSTALL_FALLBACK = {
1218
- unsupported: `\uC774 \uC2E4\uD589 \uD658\uACBD\uC5D0\uC11C\uB294 \uC5F0\uACB0 \uD504\uB85C\uADF8\uB7A8\uC744 \uC124\uCE58\uD560 \uC218 \uC5C6\uC5B4\uC694. ${FALLBACK_TAIL}`,
1219
- "install-failed": `\uC5F0\uACB0 \uD504\uB85C\uADF8\uB7A8\uC744 \uC124\uCE58\uD558\uC9C0 \uBABB\uD588\uC5B4\uC694. npm \uC804\uC5ED \uC124\uCE58 \uAD8C\uD55C\uC774 \uC5C6\uC744 \uB54C \uC774\uB807\uAC8C \uB3FC\uC694. ${FALLBACK_TAIL}`,
1220
- "not-found": `\uC124\uCE58\uD55C \uC5F0\uACB0 \uD504\uB85C\uADF8\uB7A8\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC5B4\uC694. ${FALLBACK_TAIL}`,
1221
- path: `\uC124\uCE58 \uACBD\uB85C\uC5D0 \uC4F8 \uC218 \uC5C6\uB294 \uAE00\uC790\uAC00 \uC788\uC5B4\uC694. ${FALLBACK_TAIL}`
1222
- };
1223
- var SUPPORTED_APPS_HEADER = "\uC9C0\uC6D0\uD558\uB294 \uD504\uB85C\uADF8\uB7A8\uACFC \uB2E4\uC6B4\uB85C\uB4DC \uC8FC\uC18C\uC608\uC694:";
1224
- var AFTER_INSTALL_RETRY = "\uD504\uB85C\uADF8\uB7A8\uC744 \uC124\uCE58\uD55C \uB4A4 \uAC19\uC740 \uBA85\uB839\uC5B4\uB97C \uB2E4\uC2DC \uC2E4\uD589\uD574 \uC8FC\uC138\uC694.";
1225
- var ALREADY_INSTALLED_HINT = "\uC774\uBBF8 \uC124\uCE58\uD588\uB294\uB370 \uBAA9\uB85D\uC5D0 \uC5C6\uB2E4\uBA74, \uC124\uC815 \uD30C\uC77C\uC774 \uC544\uC9C1 \uB9CC\uB4E4\uC5B4\uC9C0\uC9C0 \uC54A\uC558\uC744 \uC218 \uC788\uC5B4\uC694. \uC124\uC815 \uD30C\uC77C\uC740 \uD504\uB85C\uADF8\uB7A8\uC744 \uC124\uCE58\uD560 \uB54C\uAC00 \uC544\uB2C8\uB77C \uCC98\uC74C \uC4F8 \uB54C \uB9CC\uB4E4\uC5B4\uC838\uC694:\n - ChatGPT \uB370\uC2A4\uD06C\uD1B1: \uC124\uC815 \u2192 MCP \uC11C\uBC84 \u2192 \uC11C\uBC84 \uCD94\uAC00\uB97C \uD55C \uBC88 \uC2E4\uD589\n - VS Code: \uBA85\uB839 \uD314\uB808\uD2B8(Ctrl+Shift+P) \u2192 'MCP: Open User Configuration' \uC2E4\uD589\n\uADF8 \uB4A4 \uAC19\uC740 \uBA85\uB839\uC5B4\uB97C \uB2E4\uC2DC \uC2E4\uD589\uD558\uBA74 \uCC3E\uC744 \uC218 \uC788\uC5B4\uC694.";
1226
- var TOKEN_PROMPT_GUIDE = "\uD06C\uB86C \uD655\uC7A5 \uC124\uC815 \u2192 '\uB2E4\uB978 AI \uC571\uC5D0 \uC5F0\uACB0 (MCP)' \u2192 1\uBC88 [\uC5F0\uACB0 \uD0A4]\uC758 \uAC12\uC744 \uBCF5\uC0AC\uD574 \uC8FC\uC138\uC694.";
1227
- var TOKEN_PROMPT_QUESTION = "\uBCF5\uC0AC\uD55C \uC5F0\uACB0 \uD0A4\uB97C \uBD99\uC5EC\uB123\uC5B4 \uC8FC\uC138\uC694:";
1228
- var TOKEN_PROMPT_RETRY = "\uC5F0\uACB0 \uD0A4 \uD615\uC2DD\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC544\uC694. \uC124\uC815 \uD654\uBA74\uC5D0\uC11C \uB2E4\uC2DC \uBCF5\uC0AC\uD574 \uBD99\uC5EC\uB123\uC5B4 \uC8FC\uC138\uC694.";
1229
- var TOKEN_REQUIRED_NON_INTERACTIVE = "\uC5F0\uACB0 \uD0A4\uAC00 \uD544\uC694\uD574\uC694. \uD06C\uB86C \uD655\uC7A5 \uC124\uC815 \u2192 '\uB2E4\uB978 AI \uC571\uC5D0 \uC5F0\uACB0 (MCP)' \u2192 2\uBC88 \uBA85\uB839\uC758 [\uBCF5\uC0AC] \uBC84\uD2BC\uC744 \uB20C\uB7EC, \uBCF5\uC0AC\uB41C \uBA85\uB839\uC744 \uADF8\uB300\uB85C \uBD99\uC5EC\uB123\uC5B4 \uC2E4\uD589\uD574 \uC8FC\uC138\uC694.";
1230
- var CLI_OFFER_INTRO = "\uC6D0\uD558\uC2DC\uBA74 \uC544\uB798 AI \uD504\uB85C\uADF8\uB7A8 \uC911 \uD558\uB098\uB97C \uC9C0\uAE08 \uBC14\uB85C \uC124\uCE58\uD560 \uC218 \uC788\uC5B4\uC694. Node.js \uAE30\uBC18\uC774\uB77C \uC774 \uC790\uB9AC\uC5D0\uC11C \uC124\uCE58\uB3FC\uC694 \u2014 \uC548 \uD558\uC154\uB3C4 \uAD1C\uCC2E\uC544\uC694.";
1231
- var CLI_OFFER_SKIP_LABEL = "0. \uC9C0\uAE08\uC740 \uC124\uCE58\uD558\uC9C0 \uC54A\uAE30";
1232
- var CLI_OFFER_QUESTION = "\uC124\uCE58\uD560 \uD504\uB85C\uADF8\uB7A8\uC758 \uBC88\uD638\uB97C \uC785\uB825\uD574 \uC8FC\uC138\uC694";
1233
- function cliInstalling(name, pkg) {
1234
- return `${name}\uC744(\uB97C) \uC124\uCE58\uD558\uACE0 \uC788\uC5B4\uC694... (npm install -g ${pkg})`;
1235
- }
1236
- function cliInstalled(name) {
1237
- return `${name} \uC124\uCE58\uB97C \uB9C8\uCCE4\uC5B4\uC694.`;
1238
- }
1239
- function cliInstallFailed(name) {
1240
- return `${name} \uC124\uCE58\uAC00 \uC2E4\uD328\uD588\uC5B4\uC694. \uC7A0\uC2DC \uB4A4 \uB2E4\uC2DC \uC2DC\uB3C4\uD558\uAC70\uB098 \uC9C1\uC811 \uC124\uCE58\uD55C \uB4A4 \uAC19\uC740 \uBA85\uB839\uC744 \uC2E4\uD589\uD574 \uC8FC\uC138\uC694.`;
1241
- }
1242
- function cliInstalledRetry(name) {
1243
- return `${name}\uC744(\uB97C) \uC124\uCE58\uD588\uC5B4\uC694. \uD130\uBBF8\uB110\uC744 \uC0C8\uB85C \uC5F4\uACE0 \uAC19\uC740 \uBA85\uB839\uC744 \uD55C \uBC88 \uB354 \uC2E4\uD589\uD558\uBA74 \uC5F0\uACB0\uB3FC\uC694.`;
1244
- }
1245
- function installQuestion(count, skills) {
1246
- return skills === void 0 ? `\uC704 ${count}\uAC1C \uD504\uB85C\uADF8\uB7A8\uC5D0 \uC5F0\uACB0\uD560\uAE4C\uC694?` : `\uC704 ${count}\uAC1C \uD504\uB85C\uADF8\uB7A8\uC5D0 \uC5F0\uACB0\uD558\uACE0 \uC2A4\uD0AC ${skills}\uAC1C\uB97C \uC124\uCE58\uD560\uAE4C\uC694?`;
1247
- }
1248
- function uninstallQuestion(count) {
1249
- return `\uC704 ${count}\uAC1C \uD504\uB85C\uADF8\uB7A8\uC5D0\uC11C \uC5F0\uACB0\uC744 \uD574\uC81C\uD560\uAE4C\uC694?`;
1250
974
  }
1251
975
  var TOKEN_RE = /^[0-9a-f]{32,128}$/i;
1252
976
  var EXTENSION_ID_RE = /^[a-p]{32}$/;
@@ -1291,6 +1015,70 @@ function validateUninstallOptions(opts) {
1291
1015
  }
1292
1016
  return null;
1293
1017
  }
1018
+ function globalPackageDir(io, root) {
1019
+ const [scope, name] = SERVER_PACKAGE.split("/");
1020
+ return joinPath(io, root, scope, name);
1021
+ }
1022
+ async function resolveGlobalLaunch(io, version) {
1023
+ if (io.execPath === void 0 || io.npmRootGlobal === void 0) {
1024
+ return { ok: false, reason: "unsupported" };
1025
+ }
1026
+ const root = await io.npmRootGlobal();
1027
+ if (root === "") return { ok: false, reason: "not-found" };
1028
+ const dir = globalPackageDir(io, root);
1029
+ let installed;
1030
+ try {
1031
+ installed = JSON.parse(
1032
+ await io.readFile(joinPath(io, dir, "package.json"))
1033
+ );
1034
+ } catch {
1035
+ return { ok: false, reason: "not-found" };
1036
+ }
1037
+ if (installed?.version !== version) {
1038
+ return { ok: false, reason: "not-found" };
1039
+ }
1040
+ const cli = joinPath(io, dir, "dist", "cli.js");
1041
+ if (!await io.exists(cli)) return { ok: false, reason: "not-found" };
1042
+ if (!isLaunchPath(io.execPath) || !isLaunchPath(cli)) {
1043
+ return { ok: false, reason: "path" };
1044
+ }
1045
+ return { ok: true, launch: { node: io.execPath, cli } };
1046
+ }
1047
+ async function installGlobally(io, version, opts) {
1048
+ if (!VERSION_RE.test(version)) return { ok: false, reason: "install-failed" };
1049
+ if (io.execPath === void 0 || io.npmRootGlobal === void 0) {
1050
+ return { ok: false, reason: "unsupported" };
1051
+ }
1052
+ let code = -1;
1053
+ try {
1054
+ const result = await io.spawn(
1055
+ "npm",
1056
+ ["install", "-g", packageSpec(version)],
1057
+ { shell: io.platform === "win32", inheritStdio: opts.inheritStdio }
1058
+ );
1059
+ code = result.code;
1060
+ } catch {
1061
+ code = -1;
1062
+ }
1063
+ if (code !== 0) return { ok: false, reason: "install-failed" };
1064
+ return resolveGlobalLaunch(io, version);
1065
+ }
1066
+ async function uninstallGlobally(io) {
1067
+ if (io.npmRootGlobal === void 0) return false;
1068
+ const root = await io.npmRootGlobal();
1069
+ if (root === "" || !await io.exists(globalPackageDir(io, root))) {
1070
+ return false;
1071
+ }
1072
+ try {
1073
+ const result = await io.spawn("npm", ["uninstall", "-g", SERVER_PACKAGE], {
1074
+ shell: io.platform === "win32",
1075
+ inheritStdio: true
1076
+ });
1077
+ return result.code === 0;
1078
+ } catch {
1079
+ return false;
1080
+ }
1081
+ }
1294
1082
  function parseNetstatListeners(output, port) {
1295
1083
  const pids = /* @__PURE__ */ new Set();
1296
1084
  for (const line of output.split(/\r?\n/)) {
@@ -1422,69 +1210,382 @@ async function reclaimPort(io, token, deps = {}) {
1422
1210
  if (!ended) return { kind: "failed" };
1423
1211
  return await gone() ? { kind: "forced" } : { kind: "failed" };
1424
1212
  }
1425
- function globalPackageDir(io, root) {
1426
- const [scope, name] = SERVER_PACKAGE.split("/");
1427
- return joinPath(io, root, scope, name);
1213
+ var INSTALL_TITLE = "\uB370\uC774\uD130\uB7A9\uD234\uC988 \uC5F0\uACB0 \uB3C4\uC6B0\uBBF8";
1214
+ var UNINSTALL_TITLE = "\uB370\uC774\uD130\uB7A9\uD234\uC988 \uC5F0\uACB0 \uC815\uB9AC";
1215
+ var INSTALL_STEPS = {
1216
+ key: "\uC5F0\uACB0 \uD0A4",
1217
+ find: "AI \uD504\uB85C\uADF8\uB7A8 \uCC3E\uAE30",
1218
+ connect: "\uC5F0\uACB0\uD558\uAE30",
1219
+ finish: "\uB9C8\uBB34\uB9AC"
1220
+ };
1221
+ var SURFACE = {
1222
+ extension: "\uB370\uC774\uD130\uB7A9\uD234\uC988 \uD655\uC7A5",
1223
+ catalog: "\uC2A4\uD0AC \uCE74\uD0C8\uB85C\uADF8"
1224
+ };
1225
+ var SURFACE_NOTE = {
1226
+ extension: "\uB0B4 \uBE0C\uB77C\uC6B0\uC800\uC758 \uB124\uC774\uBC84 \uB370\uC774\uD130",
1227
+ catalog: "\uB9C8\uCF00\uD305\xB7\uAE30\uD68D\xB7\uBC95\uBB34 \uC5C5\uBB34 \uC694\uB839"
1228
+ };
1229
+ var TOKEN_PROMPT_GUIDE = [
1230
+ "\uD06C\uB86C \uD655\uC7A5 \uC124\uC815 \u203A \uB2E4\uB978 AI \uC571\uC5D0 \uC5F0\uACB0 (MCP)",
1231
+ "\u203A 1\uBC88 [\uC5F0\uACB0 \uD0A4]\uB97C \uBCF5\uC0AC\uD574 \uBD99\uC5EC\uB123\uC5B4 \uC8FC\uC138\uC694."
1232
+ ];
1233
+ var TOKEN_PROMPT_QUESTION = " \uC5F0\uACB0 \uD0A4:";
1234
+ var TOKEN_PROMPT_RETRY = "\uC5F0\uACB0 \uD0A4 \uD615\uC2DD\uC774 \uB9DE\uC9C0 \uC54A\uC544\uC694. \uB2E4\uC2DC \uBCF5\uC0AC\uD574 \uBD99\uC5EC\uB123\uC5B4 \uC8FC\uC138\uC694.";
1235
+ var TOKEN_CONFIRMED = "\uC5F0\uACB0 \uD0A4\uB97C \uD655\uC778\uD588\uC5B4\uC694.";
1236
+ var TOKEN_REQUIRED = "\uC5F0\uACB0 \uD0A4\uAC00 \uD544\uC694\uD574\uC694.";
1237
+ var TOKEN_REQUIRED_CARD = {
1238
+ title: "\uC774\uB807\uAC8C \uD574 \uC8FC\uC138\uC694",
1239
+ lines: [
1240
+ "\uD06C\uB86C \uD655\uC7A5 \uC124\uC815 \u203A \uB2E4\uB978 AI \uC571\uC5D0 \uC5F0\uACB0 (MCP)",
1241
+ "\u203A 2\uBC88 \uBA85\uB839\uC758 [\uBCF5\uC0AC]\uB97C \uB20C\uB7EC, \uBCF5\uC0AC\uB41C \uBA85\uB839\uC744 \uADF8\uB300\uB85C",
1242
+ " \uBD99\uC5EC\uB123\uC5B4 \uC2E4\uD589\uD574 \uC8FC\uC138\uC694."
1243
+ ]
1244
+ };
1245
+ function foundPrograms(count) {
1246
+ return `${String(count)}\uAC1C\uB97C \uCC3E\uC558\uC5B4\uC694.`;
1247
+ }
1248
+ var METHOD_AUTO = "\uC790\uB3D9\uC73C\uB85C \uC5F0\uACB0";
1249
+ var METHOD_MANUAL = "\uC548\uB0B4\uB300\uB85C \uC9C1\uC811 \uCD94\uAC00";
1250
+ var TWO_SURFACES = "\uAC01 \uD504\uB85C\uADF8\uB7A8\uC5D0 \uB450 \uAC00\uC9C0\uB97C \uC5F0\uACB0\uD574\uC694.";
1251
+ var ONE_SURFACE = "\uAC01 \uD504\uB85C\uADF8\uB7A8\uC5D0 \uB370\uC774\uD130\uB7A9\uD234\uC988 \uD655\uC7A5\uC744 \uC5F0\uACB0\uD574\uC694.";
1252
+ var INSTALL_QUESTION = "\uC5F0\uACB0\uD560\uAE4C\uC694?";
1253
+ var NOTHING_CHANGED = "\uC544\uBB34\uAC83\uB3C4 \uBC14\uAFB8\uC9C0 \uC54A\uC558\uC5B4\uC694.";
1254
+ var NO_HOSTS_DETECTED = "\uC5F0\uACB0\uD560 \uC218 \uC788\uB294 AI \uD504\uB85C\uADF8\uB7A8\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC5B4\uC694.";
1255
+ var ALREADY_INSTALLED_CARD = {
1256
+ title: "\uC774\uBBF8 \uC124\uCE58\uD588\uB2E4\uBA74",
1257
+ lines: [
1258
+ "\uC124\uC815 \uD30C\uC77C\uC740 \uD504\uB85C\uADF8\uB7A8\uC744 \uCC98\uC74C \uC4F8 \uB54C \uB9CC\uB4E4\uC5B4\uC838\uC694.",
1259
+ "\uC544\uB798\uB97C \uD55C \uBC88 \uD55C \uB4A4 \uB2E4\uC2DC \uC2E4\uD589\uD574 \uC8FC\uC138\uC694.",
1260
+ "\xB7 ChatGPT \uB370\uC2A4\uD06C\uD1B1 \uC124\uC815 \u203A MCP \uC11C\uBC84 \u203A \uC11C\uBC84 \uCD94\uAC00",
1261
+ "\xB7 VS Code \uBA85\uB839 \uD314\uB808\uD2B8 \u203A MCP: Open User Configuration"
1262
+ ]
1263
+ };
1264
+ var SUPPORTED_APPS_TITLE = "\uC9C0\uC6D0\uD558\uB294 \uD504\uB85C\uADF8\uB7A8";
1265
+ var AFTER_INSTALL_RETRY = "\uD504\uB85C\uADF8\uB7A8\uC744 \uC124\uCE58\uD55C \uB4A4 \uAC19\uC740 \uBA85\uB839\uC744 \uB2E4\uC2DC \uC2E4\uD589\uD574 \uC8FC\uC138\uC694.";
1266
+ var CLI_OFFER_INTRO = [
1267
+ "\uC6D0\uD558\uBA74 \uC544\uB798 AI \uD504\uB85C\uADF8\uB7A8 \uC911 \uD558\uB098\uB97C \uC9C0\uAE08 \uC124\uCE58\uD560 \uC218 \uC788\uC5B4\uC694.",
1268
+ "\uC548 \uD574\uB3C4 \uAD1C\uCC2E\uC544\uC694."
1269
+ ];
1270
+ var CLI_OFFER_SKIP_LABEL = "\uC9C0\uAE08\uC740 \uC124\uCE58\uD558\uC9C0 \uC54A\uAE30";
1271
+ var CLI_OFFER_QUESTION = " \uC124\uCE58\uD560 \uBC88\uD638\uB97C \uC785\uB825\uD574 \uC8FC\uC138\uC694";
1272
+ function cliInstalling(name) {
1273
+ return `${name}\uC744(\uB97C) \uC124\uCE58\uD558\uACE0 \uC788\uC5B4\uC694\u2026`;
1428
1274
  }
1429
- async function resolveGlobalLaunch(io, version) {
1430
- if (io.execPath === void 0 || io.npmRootGlobal === void 0) {
1431
- return { ok: false, reason: "unsupported" };
1432
- }
1433
- const root = await io.npmRootGlobal();
1434
- if (root === "") return { ok: false, reason: "not-found" };
1435
- const dir = globalPackageDir(io, root);
1436
- let installed;
1437
- try {
1438
- installed = JSON.parse(
1439
- await io.readFile(joinPath(io, dir, "package.json"))
1275
+ function cliInstalled(name) {
1276
+ return `${name} \uC124\uCE58\uB97C \uB9C8\uCCE4\uC5B4\uC694.`;
1277
+ }
1278
+ function cliInstallFailed(name) {
1279
+ return `${name} \uC124\uCE58\uAC00 \uC2E4\uD328\uD588\uC5B4\uC694. \uC9C1\uC811 \uC124\uCE58\uD55C \uB4A4 \uB2E4\uC2DC \uC2E4\uD589\uD574 \uC8FC\uC138\uC694.`;
1280
+ }
1281
+ function cliInstalledRetry(name) {
1282
+ return `${name}\uC744(\uB97C) \uC124\uCE58\uD588\uC5B4\uC694. \uD130\uBBF8\uB110\uC744 \uC0C8\uB85C \uC5F4\uACE0 \uAC19\uC740 \uBA85\uB839\uC744 \uB2E4\uC2DC \uC2E4\uD589\uD574 \uC8FC\uC138\uC694.`;
1283
+ }
1284
+ var FALLBACK_TAIL = [
1285
+ "AI \uD504\uB85C\uADF8\uB7A8\uC774 \uC2DC\uC791\uD560 \uB54C\uB9C8\uB2E4 \uB0B4\uB824\uBC1B\uC544 \uC2E4\uD589\uD574\uC694.",
1286
+ "\uC5F0\uACB0\uC740 \uB418\uACE0, \uC2DC\uC791\uB9CC 10\uCD08\uCBE4 \uB2A6\uC5B4\uC838\uC694."
1287
+ ];
1288
+ var GLOBAL_INSTALL_FALLBACK = {
1289
+ unsupported: [
1290
+ "\uC774 \uC2E4\uD589 \uD658\uACBD\uC5D0\uB294 \uC5F0\uACB0 \uD504\uB85C\uADF8\uB7A8\uC744 \uC124\uCE58\uD558\uC9C0 \uBABB\uD574\uC694.",
1291
+ ...FALLBACK_TAIL
1292
+ ],
1293
+ "install-failed": [
1294
+ "\uC774 \uCEF4\uD4E8\uD130\uC5D0\uB294 \uC5F0\uACB0 \uD504\uB85C\uADF8\uB7A8\uC744 \uC124\uCE58\uD558\uC9C0 \uBABB\uD588\uC5B4\uC694.",
1295
+ ...FALLBACK_TAIL
1296
+ ],
1297
+ "not-found": ["\uC124\uCE58\uD55C \uC5F0\uACB0 \uD504\uB85C\uADF8\uB7A8\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC5B4\uC694.", ...FALLBACK_TAIL],
1298
+ path: ["\uC124\uCE58 \uACBD\uB85C\uC5D0 \uC4F8 \uC218 \uC5C6\uB294 \uAE00\uC790\uAC00 \uC788\uC5B4\uC694.", ...FALLBACK_TAIL]
1299
+ };
1300
+ function legacySkillsCleaned(count) {
1301
+ return [
1302
+ `\uC608\uC804\uC5D0 \uC124\uCE58\uD55C \uB370\uC774\uD130\uB7A9\uD234\uC988 \uC2A4\uD0AC \uD30C\uC77C ${String(count)}\uAC1C\uB97C \uC9C0\uC6E0\uC5B4\uC694.`,
1303
+ "\uC774\uC81C \uC2A4\uD0AC\uC740 \uC2A4\uD0AC \uCE74\uD0C8\uB85C\uADF8\uC5D0\uC11C \uBC1B\uC544\uC694."
1304
+ ];
1305
+ }
1306
+ var RECLAIM = {
1307
+ retired: ["\uC608\uC804 \uC5F0\uACB0 \uD504\uB85C\uADF8\uB7A8\uC744 \uC815\uB9AC\uD588\uC5B4\uC694."],
1308
+ foreign: [
1309
+ "\uD3EC\uD2B8 8765\uB97C \uB2E4\uB978 \uD504\uB85C\uADF8\uB7A8\uC774 \uC4F0\uACE0 \uC788\uC5B4\uC694.",
1310
+ "\uADF8 \uD504\uB85C\uADF8\uB7A8\uC744 \uB044\uACE0 \uB2E4\uC2DC \uC2E4\uD589\uD574 \uC8FC\uC138\uC694."
1311
+ ],
1312
+ failed: [
1313
+ "\uC608\uC804 \uC5F0\uACB0 \uD504\uB85C\uADF8\uB7A8\uC744 \uC815\uB9AC\uD558\uC9C0 \uBABB\uD588\uC5B4\uC694.",
1314
+ "AI \uD504\uB85C\uADF8\uB7A8\uC744 \uBAA8\uB450 \uC885\uB8CC\uD55C \uB4A4 \uB2E4\uC2DC \uC2E4\uD589\uD574 \uC8FC\uC138\uC694."
1315
+ ]
1316
+ };
1317
+ var DETAIL = {
1318
+ backedUp: "\uC124\uC815 \uD30C\uC77C\uC744 \uBC14\uAFB8\uAE30 \uC804\uC5D0 \uBC31\uC5C5\uD588\uC5B4\uC694.",
1319
+ created: "\uC124\uC815 \uD30C\uC77C\uC774 \uC5C6\uC5B4 \uC0C8\uB85C \uB9CC\uB4E4\uC5C8\uC5B4\uC694.",
1320
+ upToDate: "\uC774\uBBF8 \uCD5C\uC2E0\uC774\uC5D0\uC694.",
1321
+ seeGuide: "(\uC544\uB798 \uC548\uB0B4)",
1322
+ parse: "\uC124\uC815 \uD30C\uC77C \uD615\uC2DD\uC744 \uC77D\uC744 \uC218 \uC5C6\uC5B4 \uAC74\uB4DC\uB9AC\uC9C0 \uC54A\uC558\uC5B4\uC694.",
1323
+ verify: "\uC4F4 \uB0B4\uC6A9\uC744 \uD655\uC778\uD558\uC9C0 \uBABB\uD574 \uBC31\uC5C5\uC73C\uB85C \uB418\uB3CC\uB838\uC5B4\uC694.",
1324
+ commandFailed: "\uACF5\uC2DD \uBA85\uB839\uC774 \uC2E4\uD328\uD588\uC5B4\uC694.",
1325
+ notRegistered: "\uB4F1\uB85D\uB41C \uD56D\uBAA9\uC774 \uC5C6\uC5B4\uC694."
1326
+ };
1327
+ var PERMISSION_DENIED_HINT = "\uD30C\uC77C \uAD8C\uD55C \uB54C\uBB38\uC5D0 \uC124\uC815\uC744 \uC4F8 \uC218 \uC5C6\uC5C8\uC5B4\uC694. \uAD8C\uD55C\uC744 \uD655\uC778\uD558\uACE0 \uB2E4\uC2DC \uC2E4\uD589\uD574 \uC8FC\uC138\uC694.";
1328
+ var UNEXPECTED_ERROR = "\uC608\uC0C1\uD558\uC9C0 \uBABB\uD55C \uBB38\uC81C\uAC00 \uC0DD\uACBC\uC5B4\uC694. \uB2E4\uC2DC \uC2E4\uD589\uD574 \uBCF4\uACE0, \uADF8\uB798\uB3C4 \uC548 \uB418\uBA74 \uC54C\uB824 \uC8FC\uC138\uC694.";
1329
+ function summaryAllConnected(count) {
1330
+ return `${String(count)}\uAC1C \uD504\uB85C\uADF8\uB7A8\uC5D0 \uC5F0\uACB0\uD588\uC5B4\uC694.`;
1331
+ }
1332
+ function summaryWithManual(count, manual) {
1333
+ return `${String(count)}\uAC1C \uD504\uB85C\uADF8\uB7A8\uC5D0 \uC5F0\uACB0\uD588\uC5B4\uC694. ${String(manual)}\uAC74\uC740 \uC9C1\uC811 \uCD94\uAC00\uD574 \uC8FC\uC138\uC694.`;
1334
+ }
1335
+ function summaryWithFailures(count, failed2) {
1336
+ return `${String(count)}\uAC1C \uD504\uB85C\uADF8\uB7A8\uC5D0 \uC5F0\uACB0\uD588\uC5B4\uC694. ${String(failed2)}\uAC1C\uB294 \uC5F0\uACB0\uD558\uC9C0 \uBABB\uD588\uC5B4\uC694.`;
1337
+ }
1338
+ var MUST_DO_TITLE = "\uAF2D \uD574 \uC8FC\uC138\uC694";
1339
+ var RESTART_LINES = [
1340
+ "AI \uD504\uB85C\uADF8\uB7A8\uC744 \uC644\uC804\uD788 \uC885\uB8CC\uD588\uB2E4\uAC00 \uB2E4\uC2DC \uC2E4\uD589\uD574 \uC8FC\uC138\uC694.",
1341
+ " Windows \uB294 \uC791\uC5C5 \uD45C\uC2DC\uC904 \uD2B8\uB808\uC774 \uC544\uC774\uCF58\uC5D0\uC11C \uC885\uB8CC\uD574\uC694."
1342
+ ];
1343
+ var CATALOG_LOGIN_LINES = [
1344
+ "\uC2A4\uD0AC \uCE74\uD0C8\uB85C\uADF8\uB97C \uCC98\uC74C \uC4F8 \uB54C modoo.today \uB85C\uADF8\uC778 \uCC3D\uC774",
1345
+ " \uC5F4\uB824\uC694. \uD55C \uBC88 \uB85C\uADF8\uC778\uD558\uBA74 \uADF8\uB2E4\uC74C\uBD80\uD130\uB294 \uC790\uB3D9\uC774\uC5D0\uC694."
1346
+ ];
1347
+ function catalogGuideTitle(name) {
1348
+ return `${name} \uC5D0 \uC2A4\uD0AC \uCE74\uD0C8\uB85C\uADF8 \uCD94\uAC00\uD558\uAE30`;
1349
+ }
1350
+ function extensionGuideTitle(name) {
1351
+ return `${name} \uC5D0 \uC9C1\uC811 \uCD94\uAC00\uD558\uAE30`;
1352
+ }
1353
+ function foundRemaining(count) {
1354
+ return `\uC5F0\uACB0\uC774 \uB0A8\uC544 \uC788\uB294 \uD504\uB85C\uADF8\uB7A8 ${String(count)}\uAC1C\uB97C \uCC3E\uC558\uC5B4\uC694.`;
1355
+ }
1356
+ var UNINSTALL_SURFACES = {
1357
+ both: "\uD655\uC7A5 \xB7 \uC2A4\uD0AC \uCE74\uD0C8\uB85C\uADF8",
1358
+ extension: "\uD655\uC7A5"
1359
+ };
1360
+ var UNINSTALL_QUESTION = "\uC5F0\uACB0\uC744 \uD574\uC81C\uD560\uAE4C\uC694?";
1361
+ var UNINSTALL_NOTHING_FOUND = "\uC815\uB9AC\uD560 \uC5F0\uACB0\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC5B4\uC694.";
1362
+ var UNINSTALL_ROW = {
1363
+ extension: "\uB370\uC774\uD130\uB7A9\uD234\uC988 \uD655\uC7A5 \uD574\uC81C",
1364
+ catalog: "\uC2A4\uD0AC \uCE74\uD0C8\uB85C\uADF8 \uD574\uC81C"
1365
+ };
1366
+ var GLOBAL_UNINSTALLED = "\uC774 \uCEF4\uD4E8\uD130\uC5D0 \uC124\uCE58\uD55C \uC5F0\uACB0 \uD504\uB85C\uADF8\uB7A8\uB3C4 \uC9C0\uC6E0\uC5B4\uC694.";
1367
+ var UNINSTALL_DONE = "\uC815\uB9AC\uAC00 \uB05D\uB0AC\uC5B4\uC694.";
1368
+ var BROWSER_CARD = {
1369
+ title: "\uBE0C\uB77C\uC6B0\uC800 \uCABD \uC5F0\uACB0\uB3C4 \uB044\uB824\uBA74",
1370
+ lines: [
1371
+ "\uB370\uC774\uD130\uB7A9\uD234\uC988 \uD328\uB110 \u203A \uC774 \uBE0C\uB77C\uC6B0\uC800 \uC5F0\uACB0 \uB044\uAE30",
1372
+ "\uC774 \uCEF4\uD4E8\uD130 \uB4F1\uB85D\uC740 \uB4F1\uB85D\uB41C \uBE0C\uB77C\uC6B0\uC800 \uBAA9\uB85D\uC5D0\uC11C \uB0B4\uB9B4 \uC218 \uC788\uC5B4\uC694."
1373
+ ]
1374
+ };
1375
+ var LINE_WIDTH = 56;
1376
+ function terminalCaps(io) {
1377
+ const env = io.env;
1378
+ const forced = env["FORCE_COLOR"] !== void 0 && env["FORCE_COLOR"] !== "0";
1379
+ const tty = io.stdoutIsTTY === true && env["NO_COLOR"] === void 0 && env["TERM"] !== "dumb";
1380
+ const unicode = io.platform !== "win32" || env["WT_SESSION"] !== void 0 || env["TERM_PROGRAM"] !== void 0;
1381
+ return { color: forced || tty, unicode };
1382
+ }
1383
+ function displayWidth(text) {
1384
+ let width = 0;
1385
+ for (const char of text) {
1386
+ width += isWide(char.codePointAt(0) ?? 0) ? 2 : 1;
1387
+ }
1388
+ return width;
1389
+ }
1390
+ function padEnd(text, width) {
1391
+ return text + " ".repeat(Math.max(0, width - displayWidth(text)));
1392
+ }
1393
+ var WIDE_RANGES = [
1394
+ [4352, 4447],
1395
+ [11904, 42191],
1396
+ [44032, 55203],
1397
+ [63744, 64255],
1398
+ [65072, 65103],
1399
+ [65280, 65376],
1400
+ [65504, 65510]
1401
+ ];
1402
+ function isWide(code) {
1403
+ return WIDE_RANGES.some(([from, to]) => code >= from && code <= to);
1404
+ }
1405
+ var SGR = {
1406
+ bold: "1",
1407
+ dim: "2",
1408
+ red: "31",
1409
+ green: "32",
1410
+ yellow: "33",
1411
+ cyan: "36"
1412
+ };
1413
+ var STATUS_STYLE = {
1414
+ \uC644\uB8CC: "green",
1415
+ \uC9C1\uC811: "yellow",
1416
+ \uC548\uB0B4: "yellow",
1417
+ \uC2E4\uD328: "red",
1418
+ \uAC74\uB108\uB700: "dim",
1419
+ \uC815\uB9AC: "dim"
1420
+ };
1421
+ var CARD_STYLE = {
1422
+ attention: "yellow",
1423
+ failure: "red",
1424
+ info: "cyan"
1425
+ };
1426
+ var SUMMARY_STYLE = {
1427
+ ok: "green",
1428
+ partial: "yellow",
1429
+ failed: "red"
1430
+ };
1431
+ var UNICODE_GLYPHS = { heavy: "\u2501", double: "\u2550", bar: "\u2503", dot: "\xB7" };
1432
+ var ASCII_GLYPHS = { heavy: "-", double: "=", bar: "|", dot: "-" };
1433
+ function createUi(out, caps) {
1434
+ const paint = (text, ...styles) => {
1435
+ if (!caps.color || styles.length === 0) return text;
1436
+ return `\x1B[${styles.map((s) => SGR[s]).join(";")}m${text}\x1B[0m`;
1437
+ };
1438
+ const glyphs = caps.unicode ? UNICODE_GLYPHS : ASCII_GLYPHS;
1439
+ const indentAfter = (lead, status) => " ".repeat(lead + displayWidth(status) + 2);
1440
+ return {
1441
+ banner(title, version) {
1442
+ const gap = LINE_WIDTH - 2 - displayWidth(title) - displayWidth(version);
1443
+ out("");
1444
+ out(
1445
+ ` ${paint(title, "bold")}${" ".repeat(Math.max(2, gap))}${paint(version, "dim")}`
1446
+ );
1447
+ out(` ${paint(glyphs.double.repeat(LINE_WIDTH - 2), "dim")}`);
1448
+ },
1449
+ step(index, total, title) {
1450
+ const count = `${String(index)}/${String(total)}`;
1451
+ const lead = `${glyphs.heavy}${glyphs.heavy} ${count} ${title} `;
1452
+ const fill = glyphs.heavy.repeat(
1453
+ Math.max(4, LINE_WIDTH - displayWidth(lead))
1454
+ );
1455
+ out("");
1456
+ out(
1457
+ `${paint(glyphs.heavy.repeat(2), "dim")} ${paint(count, "cyan", "bold")} ${paint(title, "bold")} ${paint(fill, "dim")}`
1458
+ );
1459
+ out("");
1460
+ },
1461
+ blank() {
1462
+ out("");
1463
+ },
1464
+ text(line) {
1465
+ out(` ${line}`);
1466
+ },
1467
+ note(line) {
1468
+ out(` ${paint(line, "dim")}`);
1469
+ },
1470
+ table(rows) {
1471
+ const width = Math.max(...rows.map(([name]) => displayWidth(name)));
1472
+ for (const [name, note] of rows) {
1473
+ out(` ${paint(padEnd(name, width), "bold")} ${note}`);
1474
+ }
1475
+ },
1476
+ bullets(rows) {
1477
+ const width = Math.max(...rows.map(([label]) => displayWidth(label)));
1478
+ for (const [label, note] of rows) {
1479
+ out(
1480
+ ` ${glyphs.dot} ${padEnd(label, width)} ${paint(note, "dim")}`
1481
+ );
1482
+ }
1483
+ },
1484
+ host(name) {
1485
+ out(` ${paint(name, "bold")}`);
1486
+ },
1487
+ status(status, label, detail) {
1488
+ out(` ${paint(status, STATUS_STYLE[status])} ${label}`);
1489
+ if (detail === void 0 || detail === "") return;
1490
+ out(`${indentAfter(4, status)}${paint(detail, "dim")}`);
1491
+ },
1492
+ notice(status, lines) {
1493
+ lines.forEach((line, i) => {
1494
+ if (i === 0) {
1495
+ out(` ${paint(status, STATUS_STYLE[status])} ${line}`);
1496
+ return;
1497
+ }
1498
+ out(`${indentAfter(2, status)}${line}`);
1499
+ });
1500
+ },
1501
+ card(tone, title, lines) {
1502
+ const style = CARD_STYLE[tone];
1503
+ const side = paint(glyphs.bar, style);
1504
+ out("");
1505
+ out(` ${side} ${paint(title, style, "bold")}`);
1506
+ out(` ${side}`);
1507
+ for (const line of lines) {
1508
+ out(line === "" ? ` ${side}` : ` ${side} ${line}`);
1509
+ }
1510
+ },
1511
+ summary(tone, line) {
1512
+ out(` ${paint(line, SUMMARY_STYLE[tone])}`);
1513
+ },
1514
+ question(line) {
1515
+ return ` ${paint(line, "bold")}`;
1516
+ },
1517
+ link(text) {
1518
+ return paint(text, "cyan");
1519
+ }
1520
+ };
1521
+ }
1522
+ function answeredNo(answer) {
1523
+ const normalized = answer.trim().toLowerCase();
1524
+ return normalized === "n" || normalized === "no";
1525
+ }
1526
+ async function installCatalog(ctx, host) {
1527
+ const command = catalogCommand(host.id);
1528
+ if (command === null) {
1529
+ const lines = catalogGuide(host.id).map(
1530
+ (line) => line.replace(/https:\/\/\S+/u, (url2) => ctx.link(url2))
1440
1531
  );
1441
- } catch {
1442
- return { ok: false, reason: "not-found" };
1443
- }
1444
- if (installed?.version !== version) {
1445
- return { ok: false, reason: "not-found" };
1532
+ return {
1533
+ row: { status: "\uC9C1\uC811", label: SURFACE.catalog, detail: DETAIL.seeGuide },
1534
+ card: {
1535
+ tone: "attention",
1536
+ title: catalogGuideTitle(host.displayName),
1537
+ lines
1538
+ }
1539
+ };
1446
1540
  }
1447
- const cli = joinPath(io, dir, "dist", "cli.js");
1448
- if (!await io.exists(cli)) return { ok: false, reason: "not-found" };
1449
- if (!isLaunchPath(io.execPath) || !isLaunchPath(cli)) {
1450
- return { ok: false, reason: "path" };
1541
+ const shell = ctx.io.platform === "win32";
1542
+ await ctx.io.spawn(command.bin, command.remove(), { shell });
1543
+ const result = await ctx.io.spawn(command.bin, command.add(), { shell });
1544
+ if (result.code === 0) {
1545
+ return { row: { status: "\uC644\uB8CC", label: SURFACE.catalog } };
1451
1546
  }
1452
- return { ok: true, launch: { node: io.execPath, cli } };
1547
+ const code = ctx.verbose ? ` (\uC885\uB8CC \uCF54\uB4DC ${String(result.code)})` : "";
1548
+ return {
1549
+ row: {
1550
+ status: "\uC2E4\uD328",
1551
+ label: SURFACE.catalog,
1552
+ detail: `${DETAIL.commandFailed}${code}`
1553
+ }
1554
+ };
1453
1555
  }
1454
- async function installGlobally(io, version, opts) {
1455
- if (!VERSION_RE.test(version)) return { ok: false, reason: "install-failed" };
1456
- if (io.execPath === void 0 || io.npmRootGlobal === void 0) {
1457
- return { ok: false, reason: "unsupported" };
1458
- }
1459
- let code = -1;
1460
- try {
1461
- const result = await io.spawn(
1462
- "npm",
1463
- ["install", "-g", packageSpec(version)],
1464
- { shell: io.platform === "win32", inheritStdio: opts.inheritStdio }
1465
- );
1466
- code = result.code;
1467
- } catch {
1468
- code = -1;
1556
+ async function removeCatalog(io, host) {
1557
+ const command = catalogCommand(host.id);
1558
+ if (command === null) return null;
1559
+ const result = await io.spawn(command.bin, command.remove(), {
1560
+ shell: io.platform === "win32"
1561
+ });
1562
+ if (result.code !== 0) {
1563
+ return {
1564
+ row: {
1565
+ status: "\uAC74\uB108\uB700",
1566
+ label: UNINSTALL_ROW.catalog,
1567
+ detail: DETAIL.notRegistered
1568
+ }
1569
+ };
1469
1570
  }
1470
- if (code !== 0) return { ok: false, reason: "install-failed" };
1471
- return resolveGlobalLaunch(io, version);
1571
+ return { row: { status: "\uC644\uB8CC", label: UNINSTALL_ROW.catalog } };
1472
1572
  }
1473
- async function uninstallGlobally(io) {
1474
- if (io.npmRootGlobal === void 0) return false;
1475
- const root = await io.npmRootGlobal();
1476
- if (root === "" || !await io.exists(globalPackageDir(io, root))) {
1477
- return false;
1573
+ async function resolveCredentials(opts, io, ui) {
1574
+ if (typeof opts.token === "string" && opts.token !== "") return opts;
1575
+ if (!io.isInteractive()) {
1576
+ ui.notice("\uC2E4\uD328", [TOKEN_REQUIRED]);
1577
+ ui.card("attention", TOKEN_REQUIRED_CARD.title, TOKEN_REQUIRED_CARD.lines);
1578
+ return null;
1478
1579
  }
1479
- try {
1480
- const result = await io.spawn("npm", ["uninstall", "-g", SERVER_PACKAGE], {
1481
- shell: io.platform === "win32",
1482
- inheritStdio: true
1483
- });
1484
- return result.code === 0;
1485
- } catch {
1486
- return false;
1580
+ for (const line of TOKEN_PROMPT_GUIDE) ui.text(line);
1581
+ ui.blank();
1582
+ const extensionId = opts.extensionId ?? DEFAULT_EXTENSION_ID;
1583
+ for (let attempt = 0; attempt < 2; attempt += 1) {
1584
+ const entered = await io.prompt(TOKEN_PROMPT_QUESTION);
1585
+ if (TOKEN_RE.test(entered)) return { ...opts, token: entered, extensionId };
1586
+ if (attempt === 0) ui.notice("\uC548\uB0B4", [TOKEN_PROMPT_RETRY]);
1487
1587
  }
1588
+ return { ...opts, extensionId };
1488
1589
  }
1489
1590
  var BACKUP_KEEP = 3;
1490
1591
  function formatBackupTimestamp(date) {
@@ -1790,729 +1891,657 @@ async function removeTomlServer(io, filePath, server) {
1790
1891
  }
1791
1892
  return { ok: true, changed: true, backupPath };
1792
1893
  }
1793
- async function detectHosts(io) {
1794
- const detected = [];
1795
- const useShell = io.platform === "win32";
1796
- const cliDetected = /* @__PURE__ */ new Set();
1797
- for (const host of CLI_HOSTS) {
1798
- let responded = false;
1799
- try {
1800
- const result = await io.spawn(host.bin, ["--version"], {
1801
- shell: useShell
1802
- });
1803
- responded = result.code === 0;
1804
- } catch {
1805
- responded = false;
1806
- }
1807
- if (responded) {
1808
- cliDetected.add(host.id);
1809
- detected.push({
1810
- tier: 1,
1811
- id: host.id,
1812
- displayName: host.displayName,
1813
- cli: host
1814
- });
1815
- }
1816
- }
1817
- for (const host of FILE_HOSTS) {
1818
- let configPath = null;
1819
- if (host.resolveConfigPath !== void 0) {
1820
- try {
1821
- configPath = await host.resolveConfigPath(io);
1822
- } catch {
1823
- configPath = null;
1824
- }
1825
- }
1826
- configPath ??= host.configPath(io);
1827
- if (configPath === null) {
1828
- continue;
1829
- }
1830
- let present = await io.exists(configPath);
1831
- if (!present) {
1832
- const cut2 = Math.max(
1833
- configPath.lastIndexOf("/"),
1834
- configPath.lastIndexOf("\\")
1835
- );
1836
- if (cut2 > 0) {
1837
- present = await io.exists(configPath.slice(0, cut2));
1838
- }
1839
- }
1840
- if (present) {
1841
- detected.push({
1842
- tier: 2,
1843
- id: host.id,
1844
- displayName: host.displayName,
1845
- file: host,
1846
- configPath
1847
- });
1848
- }
1849
- }
1850
- for (const host of SNIPPET_HOSTS) {
1851
- let present = false;
1852
- try {
1853
- present = await host.detect(io, { cliDetected });
1854
- } catch {
1855
- present = false;
1856
- }
1857
- if (present) {
1858
- detected.push({
1859
- tier: 3,
1860
- id: host.id,
1861
- displayName: host.displayName,
1862
- snippet: host
1863
- });
1894
+ async function installExtension(ctx, host) {
1895
+ try {
1896
+ if (host.cli !== void 0) return await installByCli(ctx, host.cli);
1897
+ if (host.file !== void 0) return await installByFile(ctx, host);
1898
+ if (host.snippet !== void 0) {
1899
+ return await installBySnippet(ctx, host.snippet);
1864
1900
  }
1901
+ return failed(SURFACE.extension, UNEXPECTED_ERROR);
1902
+ } catch (error) {
1903
+ return failed(SURFACE.extension, describeError(error));
1865
1904
  }
1866
- return detected;
1867
1905
  }
1868
- function tierLabel(tier) {
1869
- if (tier === 1) {
1870
- return "\uACF5\uC2DD \uBA85\uB839\uC5B4\uB85C \uC5F0\uACB0\uD574\uC694";
1871
- }
1872
- if (tier === 2) {
1873
- return "\uC124\uC815 \uD30C\uC77C\uC5D0 \uC548\uC804\uD558\uAC8C \uCD94\uAC00\uD574\uC694";
1906
+ async function removeExtension(ctx, host) {
1907
+ try {
1908
+ if (host.cli !== void 0) return await removeByCli(ctx.io, host.cli);
1909
+ if (host.file !== void 0) return await removeByFile(ctx, host);
1910
+ if (host.snippet !== void 0) {
1911
+ return await removeBySnippet(ctx.io, host.snippet);
1912
+ }
1913
+ return failed(UNINSTALL_ROW.extension, UNEXPECTED_ERROR);
1914
+ } catch (error) {
1915
+ return failed(UNINSTALL_ROW.extension, describeError(error));
1874
1916
  }
1875
- return "\uC9C1\uC811 \uBD99\uC5EC\uB123\uB3C4\uB85D \uC548\uB0B4\uB9CC \uD574\uC694";
1876
1917
  }
1877
- function printDetected(io, detected) {
1878
- printBody(
1879
- (line) => io.out(line),
1880
- `${detected.length}\uAC1C \uD504\uB85C\uADF8\uB7A8\uC744 \uCC3E\uC558\uC5B4\uC694.`
1881
- );
1882
- for (const detectedHost of detected) {
1883
- printItem(
1884
- (line) => io.out(line),
1885
- detectedHost.displayName,
1886
- tierLabel(detectedHost.tier)
1887
- );
1888
- }
1918
+ function describeError(error) {
1919
+ if (isPermissionError(error)) return PERMISSION_DENIED_HINT;
1920
+ return UNEXPECTED_ERROR;
1889
1921
  }
1890
- function printSupportedApps(io) {
1891
- io.out(NO_HOSTS_DETECTED);
1892
- io.out(ALREADY_INSTALLED_HINT);
1893
- io.out("");
1894
- io.out(SUPPORTED_APPS_HEADER);
1895
- for (const app of SUPPORTED_APPS) {
1896
- io.out(` - ${app.name}: ${app.url}`);
1897
- }
1898
- io.out(AFTER_INSTALL_RETRY);
1922
+ function failed(label, detail, card) {
1923
+ return card === void 0 ? { row: { status: "\uC2E4\uD328", label, detail } } : { row: { status: "\uC2E4\uD328", label, detail }, card };
1899
1924
  }
1900
- async function offerCliInstall(io) {
1901
- if (!io.isInteractive()) {
1902
- return null;
1903
- }
1904
- io.out(NO_HOSTS_DETECTED);
1905
- io.out("");
1906
- io.out(CLI_OFFER_INTRO);
1907
- INSTALLABLE_CLIS.forEach((cli, i) => {
1908
- printItem((line) => io.out(line), `${i + 1}. ${cli.displayName}`);
1925
+ function isPermissionError(error) {
1926
+ if (typeof error !== "object" || error === null) return false;
1927
+ const code = error.code;
1928
+ return code === "EACCES" || code === "EPERM";
1929
+ }
1930
+ function withBackup(detail, outcome, verbose) {
1931
+ if (outcome.backupPath === void 0) return detail;
1932
+ const backup = verbose ? `${DETAIL.backedUp} ${outcome.backupPath}` : DETAIL.backedUp;
1933
+ return detail === void 0 ? backup : `${detail} ${backup}`;
1934
+ }
1935
+ async function installByCli(ctx, cli) {
1936
+ const shell = ctx.io.platform === "win32";
1937
+ await ctx.io.spawn(cli.bin, cli.buildRemoveArgs(), { shell });
1938
+ const result = await ctx.io.spawn(cli.bin, cli.buildAddArgs(ctx.opts), {
1939
+ shell
1909
1940
  });
1910
- printItem((line) => io.out(line), CLI_OFFER_SKIP_LABEL);
1911
- const answer = await io.prompt(
1912
- `${CLI_OFFER_QUESTION} (0-${INSTALLABLE_CLIS.length}):`
1913
- );
1914
- const n = Number(answer.trim());
1915
- if (!Number.isInteger(n) || n < 1 || n > INSTALLABLE_CLIS.length) {
1916
- return null;
1941
+ if (result.code !== 0) {
1942
+ const code = ctx.verbose ? ` (\uC885\uB8CC \uCF54\uB4DC ${String(result.code)})` : "";
1943
+ return failed(SURFACE.extension, `${DETAIL.commandFailed}${code}`);
1917
1944
  }
1918
- return INSTALLABLE_CLIS[n - 1] ?? null;
1945
+ return {
1946
+ row: {
1947
+ status: "\uC644\uB8CC",
1948
+ label: SURFACE.extension,
1949
+ ...cli.note ? { detail: cli.note } : {}
1950
+ }
1951
+ };
1919
1952
  }
1920
- async function installCli(io, cli) {
1921
- io.out("");
1922
- io.out(cliInstalling(cli.displayName, cli.npmPackage));
1923
- let code = -1;
1924
- try {
1925
- const result = await io.spawn("npm", ["install", "-g", cli.npmPackage], {
1926
- shell: io.platform === "win32",
1927
- inheritStdio: true
1928
- });
1929
- code = result.code;
1930
- } catch {
1931
- code = -1;
1953
+ async function installByFile(ctx, host) {
1954
+ const configPath = host.configPath;
1955
+ if (configPath === void 0 || host.file === void 0) {
1956
+ return failed(SURFACE.extension, UNEXPECTED_ERROR);
1932
1957
  }
1933
- if (code === 0) {
1934
- io.out(cliInstalled(cli.displayName));
1935
- return true;
1958
+ const entry = buildEntryForHost(host.file, ctx.opts, ctx.io.platform);
1959
+ const outcome = await upsertServerKey(ctx.io, configPath, entry);
1960
+ if (outcome.ok) {
1961
+ const detail = withBackup(void 0, outcome, ctx.verbose);
1962
+ return {
1963
+ row: {
1964
+ status: "\uC644\uB8CC",
1965
+ label: SURFACE.extension,
1966
+ ...detail ? { detail } : {}
1967
+ }
1968
+ };
1936
1969
  }
1937
- io.out(cliInstallFailed(cli.displayName));
1938
- return false;
1939
- }
1940
- function printResult(io, result) {
1941
- let label;
1942
- if (result.status === "success") {
1943
- label = "[\uC131\uACF5]";
1944
- } else if (result.status === "failed") {
1945
- label = "[\uC2E4\uD328]";
1946
- } else {
1947
- label = "[\uAC74\uB108\uB700]";
1970
+ if (outcome.reason !== "parse") {
1971
+ return failed(
1972
+ SURFACE.extension,
1973
+ withBackup(DETAIL.verify, outcome, ctx.verbose) ?? DETAIL.verify
1974
+ );
1948
1975
  }
1949
- printItem(
1950
- (line) => io.out(line),
1951
- `${label} ${result.displayName}`,
1952
- result.message
1976
+ const snippet = JSON.stringify(
1977
+ { mcpServers: { [SERVER_NAME]: entry } },
1978
+ null,
1979
+ 2
1953
1980
  );
1954
- if (result.backupPath !== void 0) {
1955
- io.out(` \uBC31\uC5C5: ${result.backupPath}`);
1956
- }
1981
+ return failed(SURFACE.extension, DETAIL.parse, {
1982
+ tone: "failure",
1983
+ title: extensionGuideTitle(host.displayName),
1984
+ lines: [
1985
+ `${configPath} \uC758 mcpServers \uC548\uC5D0 \uC544\uB798\uB97C \uB123\uC5B4 \uC8FC\uC138\uC694.`,
1986
+ "",
1987
+ ...snippet.split("\n").map((line) => ` ${line}`)
1988
+ ]
1989
+ });
1957
1990
  }
1958
- async function mergeSnippetToml(io, host, opts) {
1959
- if (host.tomlServerName === void 0) {
1960
- return null;
1961
- }
1991
+ async function installBySnippet(ctx, host) {
1992
+ const merged = await mergeToml(ctx.io, host, ctx.opts);
1993
+ if (merged !== null) return merged;
1994
+ const created = await bootstrapFile(ctx.io, host, ctx.opts);
1995
+ if (created !== null) return created;
1996
+ return {
1997
+ row: { status: "\uC9C1\uC811", label: SURFACE.extension, detail: DETAIL.seeGuide },
1998
+ card: await snippetCard(ctx.io, host, ctx.opts)
1999
+ };
2000
+ }
2001
+ async function mergeToml(io, host, opts) {
2002
+ if (host.tomlServerName === void 0) return null;
1962
2003
  const path = host.detectedPath(io);
1963
- if (path === null || !await io.exists(path)) {
1964
- return null;
1965
- }
2004
+ if (path === null || !await io.exists(path)) return null;
1966
2005
  const outcome = await upsertTomlServer(
1967
2006
  io,
1968
2007
  path,
1969
2008
  host.buildSnippet(opts, io.platform),
1970
2009
  host.tomlServerName
1971
2010
  );
1972
- if (!outcome.ok) {
1973
- return null;
1974
- }
1975
- return {
1976
- hostId: host.id,
1977
- displayName: host.displayName,
1978
- tier: 3,
1979
- status: "success",
1980
- message: outcome.changed ? `\uC124\uC815 \uD30C\uC77C\uC744 \uACE0\uCCE4\uC5B4\uC694: ${path}` : `\uC124\uC815 \uD30C\uC77C\uC774 \uC774\uBBF8 \uCD5C\uC2E0\uC774\uC5D0\uC694: ${path}`
1981
- };
1982
- }
1983
- async function removeSnippetToml(io, host) {
1984
- if (host.tomlServerName === void 0) {
1985
- return null;
1986
- }
1987
- const path = host.detectedPath(io);
1988
- if (path === null || !await io.exists(path)) {
1989
- return null;
1990
- }
1991
- const outcome = await removeTomlServer(io, path, host.tomlServerName);
1992
- if (!outcome.ok) {
1993
- return null;
1994
- }
2011
+ if (!outcome.ok) return null;
1995
2012
  return {
1996
- hostId: host.id,
1997
- displayName: host.displayName,
1998
- tier: 3,
1999
- status: "success",
2000
- message: outcome.changed ? `\uC124\uC815 \uD30C\uC77C\uC5D0\uC11C \uC9C0\uC6E0\uC5B4\uC694: ${path}` : `\uC124\uC815 \uD30C\uC77C\uC5D0 \uC6B0\uB9AC \uD56D\uBAA9\uC774 \uC5C6\uC5C8\uC5B4\uC694: ${path}`
2013
+ row: {
2014
+ status: "\uC644\uB8CC",
2015
+ label: SURFACE.extension,
2016
+ detail: outcome.changed ? DETAIL.backedUp : DETAIL.upToDate
2017
+ }
2001
2018
  };
2002
2019
  }
2003
- async function bootstrapSnippetFile(io, host, opts) {
2004
- if (host.bootstrapWhenAbsent !== true) {
2005
- return null;
2006
- }
2020
+ async function bootstrapFile(io, host, opts) {
2021
+ if (host.bootstrapWhenAbsent !== true) return null;
2007
2022
  const path = host.detectedPath(io);
2008
- if (path === null || await io.exists(path)) {
2009
- return null;
2010
- }
2023
+ if (path === null || await io.exists(path)) return null;
2011
2024
  const cut2 = Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\"));
2012
- if (cut2 > 0) {
2013
- await io.mkdir(path.slice(0, cut2));
2014
- }
2025
+ if (cut2 > 0) await io.mkdir(path.slice(0, cut2));
2015
2026
  await io.writeFile(path, `${host.buildSnippet(opts, io.platform)}
2016
2027
  `);
2017
2028
  return {
2018
- hostId: host.id,
2019
- displayName: host.displayName,
2020
- tier: 3,
2021
- status: "success",
2022
- message: `\uC124\uC815 \uD30C\uC77C\uC774 \uC5C6\uC5B4\uC11C \uC0C8\uB85C \uB9CC\uB4E4\uC5C8\uC5B4\uC694: ${path}`
2029
+ row: { status: "\uC644\uB8CC", label: SURFACE.extension, detail: DETAIL.created }
2030
+ };
2031
+ }
2032
+ async function snippetCard(io, host, opts) {
2033
+ const snippet = host.buildSnippet(opts, io.platform).split("\n").map((line) => ` ${line}`);
2034
+ return {
2035
+ tone: "attention",
2036
+ title: extensionGuideTitle(host.displayName),
2037
+ lines: [
2038
+ host.reason,
2039
+ ...await whereLines(io, host),
2040
+ host.pasteWhere,
2041
+ "",
2042
+ ...snippet
2043
+ ]
2023
2044
  };
2024
2045
  }
2025
- async function printSnippetBlock(io, host, opts) {
2026
- io.out("");
2046
+ async function whereLines(io, host) {
2027
2047
  const path = host.detectedPath(io);
2028
- if (path === null) {
2029
- io.out(`${host.displayName} \uB97C \uCC3E\uC558\uC5B4\uC694.`);
2030
- } else if (await io.exists(path)) {
2031
- io.out(`${host.displayName} \u2014 \uCC3E\uC740 \uC704\uCE58: ${path}`);
2032
- } else {
2033
- io.out(`${host.displayName} \u2014 \uC124\uC815 \uD30C\uC77C\uC774 \uC544\uC9C1 \uC5C6\uC5B4\uC694: ${path}`);
2034
- if (host.createHint !== void 0) {
2035
- io.out(host.createHint);
2036
- }
2048
+ if (path === null) return [];
2049
+ if (await io.exists(path)) return [`\uC124\uC815 \uD30C\uC77C ${path}`];
2050
+ const lines = [`\uC124\uC815 \uD30C\uC77C(\uC544\uC9C1 \uC5C6\uC74C) ${path}`];
2051
+ if (host.createHint !== void 0) lines.push(host.createHint);
2052
+ return lines;
2053
+ }
2054
+ async function removeByCli(io, cli) {
2055
+ const result = await io.spawn(cli.bin, cli.buildRemoveArgs(), {
2056
+ shell: io.platform === "win32"
2057
+ });
2058
+ if (result.code !== 0) {
2059
+ return {
2060
+ row: {
2061
+ status: "\uAC74\uB108\uB700",
2062
+ label: UNINSTALL_ROW.extension,
2063
+ detail: DETAIL.notRegistered
2064
+ }
2065
+ };
2037
2066
  }
2038
- io.out(host.reason);
2039
- io.out(host.pasteWhere);
2040
- io.out(host.buildSnippet(opts, io.platform));
2067
+ return { row: { status: "\uC644\uB8CC", label: UNINSTALL_ROW.extension } };
2041
2068
  }
2042
- function isPermissionError(error) {
2043
- if (typeof error !== "object" || error === null) {
2044
- return false;
2069
+ async function removeByFile(ctx, host) {
2070
+ const configPath = host.configPath;
2071
+ if (configPath === void 0) {
2072
+ return failed(UNINSTALL_ROW.extension, UNEXPECTED_ERROR);
2045
2073
  }
2046
- const code = error.code;
2047
- if (code === "EACCES" || code === "EPERM") {
2048
- return true;
2074
+ const outcome = await removeServerKey(ctx.io, configPath);
2075
+ if (outcome.ok && outcome.changed) {
2076
+ const detail = withBackup(void 0, outcome, ctx.verbose);
2077
+ return {
2078
+ row: {
2079
+ status: "\uC644\uB8CC",
2080
+ label: UNINSTALL_ROW.extension,
2081
+ ...detail ? { detail } : {}
2082
+ }
2083
+ };
2049
2084
  }
2050
- return false;
2051
- }
2052
- function describeError(error) {
2053
- if (isPermissionError(error)) {
2054
- return PERMISSION_DENIED_HINT;
2085
+ if (outcome.ok) {
2086
+ return {
2087
+ row: {
2088
+ status: "\uAC74\uB108\uB700",
2089
+ label: UNINSTALL_ROW.extension,
2090
+ detail: DETAIL.notRegistered
2091
+ }
2092
+ };
2055
2093
  }
2056
- const next = " \uAC19\uC740 \uBA85\uB839\uC744 \uD55C \uBC88 \uB354 \uC2E4\uD589\uD574 \uBCF4\uC2DC\uACE0, \uADF8\uB798\uB3C4 \uC548 \uB418\uBA74 \uC54C\uB824 \uC8FC\uC138\uC694.";
2057
- if (error instanceof Error && error.message !== "") {
2058
- return `\uC608\uC0C1\uD558\uC9C0 \uBABB\uD55C \uBB38\uC81C\uAC00 \uC0DD\uACBC\uC5B4\uC694.${next} (${error.message})`;
2094
+ if (outcome.reason === "parse") {
2095
+ return failed(
2096
+ UNINSTALL_ROW.extension,
2097
+ `${DETAIL.parse} "${SERVER_NAME}" \uD56D\uBAA9\uC774 \uC788\uC73C\uBA74 \uC9C1\uC811 \uC9C0\uC6CC \uC8FC\uC138\uC694.`
2098
+ );
2059
2099
  }
2060
- return `\uC608\uC0C1\uD558\uC9C0 \uBABB\uD55C \uBB38\uC81C\uAC00 \uC0DD\uACBC\uC5B4\uC694.${next}`;
2100
+ return failed(
2101
+ UNINSTALL_ROW.extension,
2102
+ withBackup(DETAIL.verify, outcome, ctx.verbose) ?? DETAIL.verify
2103
+ );
2061
2104
  }
2062
- function answeredNo(answer) {
2063
- const normalized = answer.trim().toLowerCase();
2064
- if (normalized === "n" || normalized === "no") {
2065
- return true;
2105
+ async function removeBySnippet(io, host) {
2106
+ const path = host.tomlServerName === void 0 ? null : host.detectedPath(io);
2107
+ if (path !== null && host.tomlServerName !== void 0 && await io.exists(path)) {
2108
+ const outcome = await removeTomlServer(io, path, host.tomlServerName);
2109
+ if (outcome.ok && outcome.changed) {
2110
+ return { row: { status: "\uC644\uB8CC", label: UNINSTALL_ROW.extension } };
2111
+ }
2112
+ if (outcome.ok) {
2113
+ return {
2114
+ row: {
2115
+ status: "\uAC74\uB108\uB700",
2116
+ label: UNINSTALL_ROW.extension,
2117
+ detail: DETAIL.notRegistered
2118
+ }
2119
+ };
2120
+ }
2066
2121
  }
2067
- return false;
2122
+ return {
2123
+ row: {
2124
+ status: "\uAC74\uB108\uB700",
2125
+ label: UNINSTALL_ROW.extension,
2126
+ detail: `\uC124\uC815\uC5D0 "${SERVER_NAME}" \uD56D\uBAA9\uC774 \uC788\uC73C\uBA74 \uC9C1\uC811 \uC9C0\uC6CC \uC8FC\uC138\uC694.`
2127
+ }
2128
+ };
2129
+ }
2130
+ var MARKER_NAME = ".datalab-installed.json";
2131
+ var SOURCE = "@modootoday/datalab-extension-mcp";
2132
+ function join(io, ...parts) {
2133
+ return io.platform === "win32" ? parts.join("\\") : parts.join("/");
2068
2134
  }
2069
- function tier2Snippet(host, opts, platform) {
2070
- const entry = buildEntryForHost(host, opts, platform);
2071
- return JSON.stringify({ mcpServers: { [SERVER_NAME]: entry } }, null, 2);
2135
+ function dirOf(rel) {
2136
+ const cut2 = rel.lastIndexOf("/");
2137
+ return cut2 === -1 ? "" : rel.slice(0, cut2);
2072
2138
  }
2073
- async function applyCliInstall(io, host, opts) {
2074
- const useShell = io.platform === "win32";
2075
- await io.spawn(host.bin, host.buildRemoveArgs(), { shell: useShell });
2076
- const result = await io.spawn(host.bin, host.buildAddArgs(opts), {
2077
- shell: useShell
2078
- });
2079
- if (result.code === 0) {
2080
- return {
2081
- hostId: host.id,
2082
- displayName: host.displayName,
2083
- tier: 1,
2084
- status: "success",
2085
- message: "\uC5F0\uACB0\uD588\uC5B4\uC694."
2086
- };
2139
+ async function readMarker(io, dir) {
2140
+ const path = join(io, dir, MARKER_NAME);
2141
+ if (!await io.exists(path)) {
2142
+ return "none";
2143
+ }
2144
+ let raw;
2145
+ try {
2146
+ raw = await io.readFile(path);
2147
+ } catch {
2148
+ return "bad";
2149
+ }
2150
+ try {
2151
+ const parsed = JSON.parse(raw);
2152
+ if (typeof parsed !== "object" || parsed === null || typeof parsed.source !== "string" || !Array.isArray(parsed.files)) {
2153
+ return "bad";
2154
+ }
2155
+ return parsed;
2156
+ } catch {
2157
+ return "bad";
2087
2158
  }
2088
- return {
2089
- hostId: host.id,
2090
- displayName: host.displayName,
2091
- tier: 1,
2092
- status: "failed",
2093
- message: `\uBA85\uB839\uC5B4 \uC2E4\uD589\uC774 \uC2E4\uD328\uD588\uC5B4\uC694. (\uC885\uB8CC \uCF54\uB4DC ${result.code})`
2094
- };
2095
2159
  }
2096
- async function applyFileInstall(io, detected, opts) {
2097
- const host = detected.file;
2098
- const configPath = detected.configPath;
2099
- if (host === void 0 || configPath === void 0) {
2100
- return {
2101
- hostId: detected.id,
2102
- displayName: detected.displayName,
2103
- tier: 2,
2104
- status: "failed",
2105
- message: describeError(null)
2106
- };
2160
+ async function removeSkillDir(io, root, slug) {
2161
+ const dir = join(io, root, slug);
2162
+ const removed = [];
2163
+ if (!await io.exists(dir)) {
2164
+ return { ok: true, path: dir, files: removed };
2107
2165
  }
2108
- const entry = buildEntryForHost(host, opts, io.platform);
2109
- const outcome = await upsertServerKey(io, configPath, entry);
2110
- if (outcome.ok) {
2111
- const result = {
2112
- hostId: host.id,
2113
- displayName: host.displayName,
2114
- tier: 2,
2115
- status: "success",
2116
- message: "\uC124\uC815 \uD30C\uC77C\uC5D0 \uCD94\uAC00\uD588\uC5B4\uC694."
2117
- };
2118
- if (outcome.backupPath !== void 0) {
2119
- result.backupPath = outcome.backupPath;
2166
+ const marker = await readMarker(io, dir);
2167
+ if (marker === "none") {
2168
+ return { ok: false, path: dir, refusal: "unmarked", files: removed };
2169
+ }
2170
+ if (marker === "bad") {
2171
+ return { ok: false, path: dir, refusal: "unreadable", files: removed };
2172
+ }
2173
+ if (marker.source !== SOURCE) {
2174
+ return { ok: false, path: dir, refusal: "foreign", files: removed };
2175
+ }
2176
+ for (const rel of marker.files) {
2177
+ const path = join(io, dir, ...rel.split("/"));
2178
+ try {
2179
+ await io.unlink(path);
2180
+ removed.push(rel);
2181
+ } catch {
2120
2182
  }
2121
- return result;
2122
2183
  }
2123
- if (outcome.reason === "parse") {
2124
- io.out(
2125
- `${host.displayName} \uC124\uC815 \uD30C\uC77C\uC744 \uD574\uC11D\uD560 \uC218 \uC5C6\uC5B4 \uC790\uB3D9 \uC218\uC815\uD558\uC9C0 \uC54A\uC544\uC694: ${configPath}`
2126
- );
2127
- io.out("\uC544\uB798 \uB0B4\uC6A9\uC744 \uC9C1\uC811 \uBD99\uC5EC\uB123\uC5B4 \uC8FC\uC138\uC694.");
2128
- io.out(tier2Snippet(host, opts, io.platform));
2129
- return {
2130
- hostId: host.id,
2131
- displayName: host.displayName,
2132
- tier: 2,
2133
- status: "failed",
2134
- message: "\uC124\uC815 \uD30C\uC77C\uC744 \uD574\uC11D\uD560 \uC218 \uC5C6\uC5B4 \uC218\uC815\uD558\uC9C0 \uC54A\uC558\uC5B4\uC694. \uC704\uC5D0 \uCD9C\uB825\uB41C \uB0B4\uC6A9\uC744 \uC9C1\uC811 \uBD99\uC5EC\uB123\uC5B4 \uC8FC\uC138\uC694."
2135
- };
2184
+ try {
2185
+ await io.unlink(join(io, dir, MARKER_NAME));
2186
+ } catch {
2136
2187
  }
2137
- const failed = {
2138
- hostId: host.id,
2139
- displayName: host.displayName,
2140
- tier: 2,
2141
- status: "failed",
2142
- message: "\uC4F0\uAE30 \uAC80\uC99D\uC5D0 \uC2E4\uD328\uD574\uC11C \uBC31\uC5C5\uC73C\uB85C \uB418\uB3CC\uB838\uC5B4\uC694. \uAC19\uC740 \uBA85\uB839\uC5B4\uB97C \uB2E4\uC2DC \uC2E4\uD589\uD574 \uC8FC\uC138\uC694."
2143
- };
2144
- if (outcome.backupPath !== void 0) {
2145
- failed.backupPath = outcome.backupPath;
2188
+ const subs = [...new Set(marker.files.map(dirOf).filter((d) => d !== ""))];
2189
+ for (const sub of subs.sort((a, b) => b.length - a.length)) {
2190
+ try {
2191
+ await io.rmdir(join(io, dir, ...sub.split("/")));
2192
+ } catch {
2193
+ }
2146
2194
  }
2147
- return failed;
2148
- }
2149
- async function applyCliUninstall(io, host) {
2150
- const useShell = io.platform === "win32";
2151
- const result = await io.spawn(host.bin, host.buildRemoveArgs(), {
2152
- shell: useShell
2153
- });
2154
- if (result.code === 0) {
2155
- return {
2156
- hostId: host.id,
2157
- displayName: host.displayName,
2158
- tier: 1,
2159
- status: "success",
2160
- message: "\uC5F0\uACB0\uC744 \uD574\uC81C\uD588\uC5B4\uC694."
2161
- };
2195
+ try {
2196
+ await io.rmdir(dir);
2197
+ } catch {
2162
2198
  }
2163
- return {
2164
- hostId: host.id,
2165
- displayName: host.displayName,
2166
- tier: 1,
2167
- status: "skipped",
2168
- message: "\uC774\uBBF8 \uD574\uC81C\uB418\uC5B4 \uC788\uAC70\uB098 \uB4F1\uB85D\uB41C \uD56D\uBAA9\uC774 \uC5C6\uC5B4\uC694."
2169
- };
2199
+ return { ok: true, path: dir, files: removed };
2170
2200
  }
2171
- async function applyFileUninstall(io, detected) {
2172
- const host = detected.file;
2173
- const configPath = detected.configPath;
2174
- if (host === void 0 || configPath === void 0) {
2175
- return {
2176
- hostId: detected.id,
2177
- displayName: detected.displayName,
2178
- tier: 2,
2179
- status: "failed",
2180
- message: describeError(null)
2181
- };
2201
+ var LEGACY_PREFIX = "datalab-";
2202
+ async function cleanupLegacySkills(io, detectedIds) {
2203
+ const dirs = /* @__PURE__ */ new Set();
2204
+ for (const host of SKILL_HOSTS) {
2205
+ if (!detectedIds.has(host.id) || host.skills.tier !== 2) {
2206
+ continue;
2207
+ }
2208
+ const dir = host.skills.skillsDir(io);
2209
+ if (dir !== null) {
2210
+ dirs.add(dir);
2211
+ }
2182
2212
  }
2183
- const outcome = await removeServerKey(io, configPath);
2184
- if (outcome.ok && outcome.changed) {
2185
- const result = {
2186
- hostId: host.id,
2187
- displayName: host.displayName,
2188
- tier: 2,
2189
- status: "success",
2190
- message: "\uC124\uC815 \uD30C\uC77C\uC5D0\uC11C \uD56D\uBAA9\uC744 \uC9C0\uC6E0\uC5B4\uC694."
2191
- };
2192
- if (outcome.backupPath !== void 0) {
2193
- result.backupPath = outcome.backupPath;
2213
+ const removed = /* @__PURE__ */ new Set();
2214
+ let kept = 0;
2215
+ for (const dir of dirs) {
2216
+ for (const slug of await io.listDir(dir)) {
2217
+ if (!slug.startsWith(LEGACY_PREFIX)) {
2218
+ continue;
2219
+ }
2220
+ const outcome = await removeSkillDir(io, dir, slug);
2221
+ if (outcome.ok && outcome.files.length > 0) {
2222
+ removed.add(slug);
2223
+ } else if (!outcome.ok) {
2224
+ kept += 1;
2225
+ }
2194
2226
  }
2195
- return result;
2196
2227
  }
2197
- if (outcome.ok) {
2198
- return {
2199
- hostId: host.id,
2200
- displayName: host.displayName,
2201
- tier: 2,
2202
- status: "skipped",
2203
- message: "\uC124\uC815\uC5D0 \uC9C0\uC6B8 \uD56D\uBAA9\uC774 \uC5C6\uC5B4\uC694."
2204
- };
2228
+ return { removed: removed.size, kept };
2229
+ }
2230
+ async function offerCliInstall(io, ui) {
2231
+ if (!io.isInteractive()) return null;
2232
+ ui.text(NO_HOSTS_DETECTED);
2233
+ ui.blank();
2234
+ for (const line of CLI_OFFER_INTRO) ui.text(line);
2235
+ ui.blank();
2236
+ ui.table([
2237
+ ...INSTALLABLE_CLIS.map(
2238
+ (cli, i) => [String(i + 1), cli.displayName]
2239
+ ),
2240
+ ["0", CLI_OFFER_SKIP_LABEL]
2241
+ ]);
2242
+ ui.blank();
2243
+ const answer = await io.prompt(
2244
+ `${CLI_OFFER_QUESTION} (0-${String(INSTALLABLE_CLIS.length)}):`
2245
+ );
2246
+ const n = Number(answer.trim());
2247
+ if (!Number.isInteger(n) || n < 1 || n > INSTALLABLE_CLIS.length) return null;
2248
+ return INSTALLABLE_CLIS[n - 1] ?? null;
2249
+ }
2250
+ async function installCli(io, ui, cli) {
2251
+ ui.blank();
2252
+ ui.text(cliInstalling(cli.displayName));
2253
+ let code = -1;
2254
+ try {
2255
+ const result = await io.spawn("npm", ["install", "-g", cli.npmPackage], {
2256
+ shell: io.platform === "win32",
2257
+ inheritStdio: true
2258
+ });
2259
+ code = result.code;
2260
+ } catch {
2261
+ code = -1;
2205
2262
  }
2206
- if (outcome.reason === "parse") {
2207
- return {
2208
- hostId: host.id,
2209
- displayName: host.displayName,
2210
- tier: 2,
2211
- status: "failed",
2212
- message: `\uC124\uC815 \uD30C\uC77C\uC744 \uD574\uC11D\uD560 \uC218 \uC5C6\uC5B4 \uC218\uC815\uD558\uC9C0 \uC54A\uC558\uC5B4\uC694. "${SERVER_NAME}" \uD56D\uBAA9\uC774 \uC788\uB2E4\uBA74 \uC9C1\uC811 \uC9C0\uC6CC \uC8FC\uC138\uC694: ${configPath}`
2213
- };
2263
+ if (code === 0) {
2264
+ ui.notice("\uC644\uB8CC", [cliInstalled(cli.displayName)]);
2265
+ return true;
2214
2266
  }
2215
- const failed = {
2267
+ ui.notice("\uC2E4\uD328", [cliInstallFailed(cli.displayName)]);
2268
+ return false;
2269
+ }
2270
+ function printSupportedApps(ui) {
2271
+ ui.text(NO_HOSTS_DETECTED);
2272
+ ui.card("info", ALREADY_INSTALLED_CARD.title, ALREADY_INSTALLED_CARD.lines);
2273
+ const width = Math.max(
2274
+ ...SUPPORTED_APPS.map((app) => displayWidth(app.name))
2275
+ );
2276
+ ui.card(
2277
+ "info",
2278
+ SUPPORTED_APPS_TITLE,
2279
+ SUPPORTED_APPS.map((app) => {
2280
+ const pad = " ".repeat(width - displayWidth(app.name) + 3);
2281
+ return `${app.name}${pad}${ui.link(app.url.replace(/^https:\/\//u, "").replace(/\/$/u, ""))}`;
2282
+ })
2283
+ );
2284
+ ui.blank();
2285
+ ui.text(AFTER_INSTALL_RETRY);
2286
+ }
2287
+ function hostReport(host, outcomes) {
2288
+ const cards = [];
2289
+ for (const outcome of outcomes) {
2290
+ if (outcome.card !== void 0) cards.push(outcome.card);
2291
+ }
2292
+ return {
2216
2293
  hostId: host.id,
2217
2294
  displayName: host.displayName,
2218
- tier: 2,
2219
- status: "failed",
2220
- message: "\uC4F0\uAE30 \uAC80\uC99D\uC5D0 \uC2E4\uD328\uD574\uC11C \uBC31\uC5C5\uC73C\uB85C \uB418\uB3CC\uB838\uC5B4\uC694."
2295
+ rows: outcomes.map((outcome) => outcome.row),
2296
+ cards
2221
2297
  };
2222
- if (outcome.backupPath !== void 0) {
2223
- failed.backupPath = outcome.backupPath;
2224
- }
2225
- return failed;
2226
2298
  }
2227
- function filterByRequestedHosts(detected, hosts) {
2228
- if (hosts === void 0 || hosts.length === 0) {
2229
- return detected;
2230
- }
2231
- return detected.filter((d) => hosts.includes(d.id));
2299
+ function printHostReports(ui, reports) {
2300
+ reports.forEach((report, i) => {
2301
+ if (i > 0) ui.blank();
2302
+ ui.host(report.displayName);
2303
+ for (const row of report.rows) {
2304
+ ui.status(row.status, row.label, row.detail);
2305
+ }
2306
+ });
2232
2307
  }
2233
- async function resolveInstallCredentials(opts, io) {
2234
- if (typeof opts.token === "string" && opts.token !== "") {
2235
- return opts;
2236
- }
2237
- if (!io.isInteractive()) {
2238
- io.out(TOKEN_REQUIRED_NON_INTERACTIVE);
2239
- return null;
2240
- }
2241
- io.out(TOKEN_PROMPT_GUIDE);
2242
- for (let attempt = 0; attempt < 2; attempt += 1) {
2243
- const entered = await io.prompt(TOKEN_PROMPT_QUESTION);
2244
- if (TOKEN_RE.test(entered)) {
2245
- return {
2246
- ...opts,
2247
- token: entered,
2248
- extensionId: opts.extensionId ?? DEFAULT_EXTENSION_ID
2249
- };
2308
+ function printCards(ui, reports) {
2309
+ for (const report of reports) {
2310
+ for (const card of report.cards) {
2311
+ ui.card(card.tone, card.title, card.lines);
2250
2312
  }
2251
- if (attempt === 0) io.out(TOKEN_PROMPT_RETRY);
2252
2313
  }
2253
- return { ...opts, extensionId: opts.extensionId ?? DEFAULT_EXTENSION_ID };
2254
2314
  }
2315
+ function tally(reports) {
2316
+ let connected = 0;
2317
+ let manual = 0;
2318
+ let failed2 = 0;
2319
+ for (const report of reports) {
2320
+ if (report.rows.some((row) => row.status === "\uC644\uB8CC")) connected += 1;
2321
+ manual += report.rows.filter((row) => row.status === "\uC9C1\uC811").length;
2322
+ failed2 += report.rows.some((row) => row.status === "\uC2E4\uD328") ? 1 : 0;
2323
+ }
2324
+ return { connected, manual, failed: failed2 };
2325
+ }
2326
+ var STEPS = 4;
2255
2327
  async function runInstall(opts, io) {
2256
- printBanner((line) => io.out(line), INSTALL_SUBTITLE);
2257
- printStep((line) => io.out(line), 1, 5, "\uC5F0\uACB0 \uD0A4 \uD655\uC778");
2258
- const resolved = await resolveInstallCredentials(opts, io);
2259
- if (resolved === null) return 1;
2260
- const validationError = validateInstallOptions(resolved);
2261
- if (validationError !== null) {
2262
- io.out(validationError);
2263
- return 1;
2328
+ const ui = createUi((line) => io.out(line), terminalCaps(io));
2329
+ ui.banner(INSTALL_TITLE, `v${opts.version}`);
2330
+ ui.step(1, STEPS, INSTALL_STEPS.key);
2331
+ const entryOpts = await confirmKey(opts, io, ui);
2332
+ if (entryOpts === null) return 1;
2333
+ ui.step(2, STEPS, INSTALL_STEPS.find);
2334
+ const found = await findPrograms(opts, io, ui);
2335
+ if (typeof found === "number") return found;
2336
+ const withCatalog = opts.skills !== false;
2337
+ presentPlan(ui, found, withCatalog);
2338
+ if (opts.yes !== true && answeredNo(await io.ask(ui.question(INSTALL_QUESTION)))) {
2339
+ ui.blank();
2340
+ ui.text(NOTHING_CHANGED);
2341
+ return 0;
2264
2342
  }
2265
- printBody((line) => io.out(line), "\uC778\uC99D\uD0A4\uB97C \uD655\uC778\uD588\uC5B4\uC694.");
2266
- const entryOpts = {
2343
+ ui.step(3, STEPS, INSTALL_STEPS.connect);
2344
+ const reports = await connect(opts, io, ui, found, entryOpts, withCatalog);
2345
+ printHostReports(ui, reports);
2346
+ ui.step(4, STEPS, INSTALL_STEPS.finish);
2347
+ return finish(ui, reports);
2348
+ }
2349
+ async function confirmKey(opts, io, ui) {
2350
+ const resolved = await resolveCredentials(opts, io, ui);
2351
+ if (resolved === null) return null;
2352
+ const refusal = validateInstallOptions(resolved);
2353
+ if (refusal !== null) {
2354
+ ui.notice("\uC2E4\uD328", [refusal]);
2355
+ return null;
2356
+ }
2357
+ ui.notice("\uC644\uB8CC", [TOKEN_CONFIRMED]);
2358
+ return {
2267
2359
  version: resolved.version,
2268
2360
  token: resolved.token,
2269
- extensionId: resolved.extensionId
2361
+ extensionId: resolved.extensionId,
2362
+ ...resolved.port === void 0 ? {} : { port: resolved.port }
2270
2363
  };
2271
- if (resolved.port !== void 0) {
2272
- entryOpts.port = resolved.port;
2273
- }
2274
- printStep((line) => io.out(line), 2, 5, "\uC5F0\uACB0\uD560 AI \uD504\uB85C\uADF8\uB7A8 \uCC3E\uAE30");
2275
- printBody((line) => io.out(line), "\uC124\uCE58\uB41C \uD504\uB85C\uADF8\uB7A8\uC744 \uD655\uC778\uD558\uB294 \uC911\uC774\uC5D0\uC694\u2026");
2276
- let detected = filterByRequestedHosts(await detectHosts(io), opts.hosts);
2277
- if (detected.length === 0) {
2278
- const chosen = await offerCliInstall(io);
2279
- if (chosen !== null && await installCli(io, chosen)) {
2280
- detected = filterByRequestedHosts(await detectHosts(io), opts.hosts);
2281
- if (detected.length === 0) {
2282
- io.out(cliInstalledRetry(chosen.displayName));
2283
- return 0;
2284
- }
2285
- }
2286
- if (detected.length === 0) {
2287
- printSupportedApps(io);
2288
- return 1;
2289
- }
2290
- }
2291
- printDetected(io, detected);
2292
- printStep((line) => io.out(line), 3, 5, "\uC2A4\uD0AC \uC120\uD0DD");
2293
- const skillRoot = skillsPayloadRoot();
2294
- let skillPlan = null;
2295
- if (opts.skills === false) {
2296
- printBody((line) => io.out(line), "\uC2A4\uD0AC \uC124\uCE58\uB97C \uAC74\uB108\uB701\uB2C8\uB2E4.");
2297
- } else {
2298
- const staged = await readPayloads(io, skillRoot);
2299
- if (staged === null || staged.length === 0) {
2300
- printBody(
2301
- (line) => io.out(line),
2302
- "\uC774 \uC124\uCE58 \uD30C\uC77C\uC5D0\uB294 \uC2A4\uD0AC\uC774 \uC5C6\uC5B4 \uC5F0\uACB0 \uD504\uB85C\uADF8\uB7A8\uB9CC \uC124\uCE58\uD574\uC694."
2303
- );
2304
- } else {
2305
- skillPlan = await chooseSkillSelection(io, staged, {
2306
- all: opts.allSkills === true,
2307
- requested: opts.skillSlugs,
2308
- interactive: opts.yes !== true && io.isInteractive()
2309
- });
2310
- if (skillPlan === null) {
2311
- io.out(NOTHING_CHANGED);
2312
- return 1;
2313
- }
2314
- printBody(
2315
- (line) => io.out(line),
2316
- `\uCD94\uCC9C ${skillPlan.defaultCount}\uAC1C + \uC120\uD0DD ${skillPlan.selected.size}\uAC1C = ${skillPlan.total}\uAC1C\uB97C \uC124\uCE58\uD574\uC694.`
2317
- );
2318
- }
2319
- }
2320
- const actionable = detected.filter((d) => d.tier !== 3);
2321
- if (actionable.length > 0 && opts.yes !== true) {
2322
- const answer = await io.ask(
2323
- installQuestion(actionable.length, skillPlan?.total)
2324
- );
2325
- if (answeredNo(answer)) {
2326
- io.out(NOTHING_CHANGED);
2327
- return 0;
2328
- }
2364
+ }
2365
+ async function findPrograms(opts, io, ui) {
2366
+ const detected = filterByRequestedHosts(await detectHosts(io), opts.hosts);
2367
+ if (detected.length > 0) return detected;
2368
+ const chosen = await offerCliInstall(io, ui);
2369
+ if (chosen === null || !await installCli(io, ui, chosen)) {
2370
+ printSupportedApps(ui);
2371
+ return 1;
2329
2372
  }
2330
- printStep((line) => io.out(line), 4, 5, "\uC5F0\uACB0\uD558\uB294 \uC911");
2331
- printBody(
2332
- (line) => io.out(line),
2333
- "\uC5F0\uACB0 \uD504\uB85C\uADF8\uB7A8\uC744 \uC774 \uCEF4\uD4E8\uD130\uC5D0 \uC124\uCE58\uD558\uB294 \uC911\uC774\uC5D0\uC694\u2026"
2373
+ const rescanned = filterByRequestedHosts(await detectHosts(io), opts.hosts);
2374
+ if (rescanned.length > 0) return rescanned;
2375
+ ui.notice("\uC548\uB0B4", [cliInstalledRetry(chosen.displayName)]);
2376
+ return 0;
2377
+ }
2378
+ function presentPlan(ui, hosts, withCatalog) {
2379
+ ui.text(foundPrograms(hosts.length));
2380
+ ui.blank();
2381
+ ui.table(
2382
+ hosts.map(
2383
+ (host) => [host.displayName, methodOf(host, withCatalog)]
2384
+ )
2334
2385
  );
2386
+ ui.blank();
2387
+ if (!withCatalog) {
2388
+ ui.text(ONE_SURFACE);
2389
+ ui.blank();
2390
+ return;
2391
+ }
2392
+ ui.text(TWO_SURFACES);
2393
+ ui.bullets([
2394
+ [SURFACE.extension, SURFACE_NOTE.extension],
2395
+ [SURFACE.catalog, SURFACE_NOTE.catalog]
2396
+ ]);
2397
+ ui.blank();
2398
+ }
2399
+ function methodOf(host, withCatalog) {
2400
+ const catalogAuto = !withCatalog || catalogCommand(host.id) !== null;
2401
+ return host.tier !== 3 && catalogAuto ? METHOD_AUTO : METHOD_MANUAL;
2402
+ }
2403
+ async function connect(opts, io, ui, hosts, entryOpts, withCatalog) {
2404
+ const notices = [];
2335
2405
  const installed = await installGlobally(io, entryOpts.version, {
2336
2406
  inheritStdio: true
2337
2407
  });
2338
- if (installed.ok) {
2339
- entryOpts.launch = installed.launch;
2340
- printBody((line) => io.out(line), "\uC124\uCE58\uD588\uC5B4\uC694. AI \uC571\uC774 \uBC14\uB85C \uC2E4\uD589\uD574\uC694.");
2341
- } else {
2342
- printBody(
2343
- (line) => io.out(line),
2344
- GLOBAL_INSTALL_FALLBACK[installed.reason]
2345
- );
2408
+ const launchOpts = installed.ok ? { ...entryOpts, launch: installed.launch } : entryOpts;
2409
+ if (!installed.ok) {
2410
+ notices.push({
2411
+ status: "\uC548\uB0B4",
2412
+ lines: GLOBAL_INSTALL_FALLBACK[installed.reason]
2413
+ });
2346
2414
  }
2347
- const results = [];
2348
- for (const d of detected) {
2349
- try {
2350
- if (d.tier === 1 && d.cli !== void 0) {
2351
- results.push(await applyCliInstall(io, d.cli, entryOpts));
2352
- } else if (d.tier === 2) {
2353
- results.push(await applyFileInstall(io, d, entryOpts));
2354
- } else if (d.snippet !== void 0) {
2355
- const merged = await mergeSnippetToml(io, d.snippet, entryOpts);
2356
- const made = merged ?? await bootstrapSnippetFile(io, d.snippet, entryOpts);
2357
- results.push(
2358
- made ?? {
2359
- hostId: d.id,
2360
- displayName: d.displayName,
2361
- tier: 3,
2362
- status: "skipped",
2363
- message: `${d.snippet.reason} \uC544\uB798 \uC548\uB0B4\uB97C \uD655\uC778\uD574 \uC8FC\uC138\uC694.`
2364
- }
2365
- );
2366
- }
2367
- } catch (error) {
2368
- results.push({
2369
- hostId: d.id,
2370
- displayName: d.displayName,
2371
- tier: d.tier,
2372
- status: "failed",
2373
- message: describeError(error)
2374
- });
2415
+ const verbose = opts.verbose === true;
2416
+ const reports = [];
2417
+ for (const host of hosts) {
2418
+ const outcomes = [
2419
+ await installExtension({ io, opts: launchOpts, verbose }, host)
2420
+ ];
2421
+ if (withCatalog) {
2422
+ outcomes.push(await installCatalog({ io, verbose, link: ui.link }, host));
2375
2423
  }
2424
+ reports.push(hostReport(host, outcomes));
2376
2425
  }
2377
2426
  const reclaimed = await reclaimPort(io, entryOpts.token, {
2378
2427
  version: entryOpts.version,
2379
2428
  ...entryOpts.port === void 0 ? {} : { port: entryOpts.port }
2380
2429
  });
2381
- if (reclaimed.kind === "retired" || reclaimed.kind === "forced") {
2382
- io.out(" \uC608\uC804 \uC5F0\uACB0 \uD504\uB85C\uADF8\uB7A8\uC744 \uC815\uB9AC\uD588\uC5B4\uC694.");
2383
- } else if (reclaimed.kind === "foreign") {
2384
- io.out(
2385
- " \uD3EC\uD2B8 8765\uB97C \uB2E4\uB978 \uD504\uB85C\uADF8\uB7A8\uC774 \uC4F0\uACE0 \uC788\uC5B4\uC694. \uADF8 \uD504\uB85C\uADF8\uB7A8\uC744 \uB044\uACE0 \uB2E4\uC2DC \uC2E4\uD589\uD574 \uC8FC\uC138\uC694."
2386
- );
2387
- } else if (reclaimed.kind === "failed") {
2388
- io.out(
2389
- " \uC608\uC804 \uC5F0\uACB0 \uD504\uB85C\uADF8\uB7A8\uC744 \uC815\uB9AC\uD558\uC9C0 \uBABB\uD588\uC5B4\uC694. AI \uC571\uC744 \uBAA8\uB450 \uC885\uB8CC\uD55C \uB4A4 \uB2E4\uC2DC \uC2E4\uD589\uD574 \uC8FC\uC138\uC694."
2430
+ const reclaimNotice = RECLAIM_NOTICE[reclaimed.kind];
2431
+ if (reclaimNotice !== void 0) notices.push(reclaimNotice);
2432
+ if (withCatalog) {
2433
+ const legacy = await cleanupLegacySkills(
2434
+ io,
2435
+ new Set(hosts.map((host) => host.id))
2390
2436
  );
2437
+ if (legacy.removed > 0) {
2438
+ notices.push({
2439
+ status: "\uC815\uB9AC",
2440
+ lines: legacySkillsCleaned(legacy.removed)
2441
+ });
2442
+ }
2391
2443
  }
2392
- if (opts.skills !== false) {
2393
- results.push(
2394
- ...await placeSkills(
2395
- io,
2396
- skillRoot,
2397
- new Set(detected.map((d) => d.id)),
2398
- opts.version,
2399
- skillPlan?.selected ?? false
2444
+ for (const notice of notices) ui.notice(notice.status, notice.lines);
2445
+ if (notices.length > 0) ui.blank();
2446
+ return reports;
2447
+ }
2448
+ var RECLAIM_NOTICE = {
2449
+ retired: { status: "\uC815\uB9AC", lines: RECLAIM.retired },
2450
+ forced: { status: "\uC815\uB9AC", lines: RECLAIM.retired },
2451
+ foreign: { status: "\uC548\uB0B4", lines: RECLAIM.foreign },
2452
+ failed: { status: "\uC2E4\uD328", lines: RECLAIM.failed }
2453
+ };
2454
+ function printSummary(ui, counts) {
2455
+ if (counts.failed > 0) {
2456
+ ui.summary("failed", summaryWithFailures(counts.connected, counts.failed));
2457
+ return;
2458
+ }
2459
+ if (counts.manual > 0) {
2460
+ ui.summary("partial", summaryWithManual(counts.connected, counts.manual));
2461
+ return;
2462
+ }
2463
+ ui.summary("ok", summaryAllConnected(counts.connected));
2464
+ }
2465
+ function finish(ui, reports) {
2466
+ const counts = tally(reports);
2467
+ printSummary(ui, counts);
2468
+ if (counts.connected > 0) {
2469
+ const catalogConnected = reports.some(
2470
+ (report) => report.rows.some(
2471
+ (row) => row.label === SURFACE.catalog && row.status === "\uC644\uB8CC"
2400
2472
  )
2401
2473
  );
2402
- }
2403
- printStep((line) => io.out(line), 5, 5, "\uACB0\uACFC");
2404
- for (const result of results) {
2405
- printResult(io, result);
2406
- if (result.status === "success" && result.tier === 1) {
2407
- const cliHost = CLI_HOSTS.find((h) => h.id === result.hostId);
2408
- if (cliHost !== void 0 && cliHost.note !== void 0) {
2409
- io.out(` ${cliHost.note}`);
2410
- }
2411
- }
2412
- }
2413
- const connected = results.filter(
2414
- (r) => r.status === "success" && r.surface !== "skills"
2415
- ).length;
2416
- const failed = results.filter(
2417
- (r) => r.status === "failed" && r.tier !== 3
2418
- ).length;
2419
- io.out("");
2420
- io.out(
2421
- failed === 0 ? `${String(connected)}\uAC1C \uD504\uB85C\uADF8\uB7A8\uC5D0 \uC5F0\uACB0\uD588\uC5B4\uC694.` : `${String(connected)}\uAC1C \uC5F0\uACB0, ${String(failed)}\uAC1C \uC2E4\uD328.`
2422
- );
2423
- for (const d of detected) {
2424
- if (d.tier === 3 && d.snippet !== void 0) {
2425
- await printSnippetBlock(io, d.snippet, entryOpts);
2474
+ const lines = [`1. ${RESTART_LINES[0] ?? ""}`, ...RESTART_LINES.slice(1)];
2475
+ if (catalogConnected) {
2476
+ lines.push(
2477
+ `2. ${CATALOG_LOGIN_LINES[0] ?? ""}`,
2478
+ ...CATALOG_LOGIN_LINES.slice(1)
2479
+ );
2426
2480
  }
2481
+ ui.card("attention", MUST_DO_TITLE, lines);
2427
2482
  }
2428
- const anyConfigured = results.some((r) => r.status === "success");
2429
- const anyFailed = results.some((r) => r.status === "failed" && r.tier !== 3);
2430
- if (anyConfigured) {
2431
- io.out("");
2432
- io.out(RESTART_NOTICE);
2433
- }
2434
- if (anyFailed) {
2435
- return 1;
2436
- }
2437
- return 0;
2483
+ printCards(ui, reports);
2484
+ return counts.failed > 0 ? 1 : 0;
2438
2485
  }
2439
2486
  async function runUninstall(opts, io) {
2440
- printBanner((line) => io.out(line), UNINSTALL_SUBTITLE);
2441
- const validationError = validateUninstallOptions(opts);
2442
- if (validationError !== null) {
2443
- io.out(validationError);
2487
+ const ui = createUi((line) => io.out(line), terminalCaps(io));
2488
+ ui.banner(UNINSTALL_TITLE, `v${opts.version}`);
2489
+ ui.blank();
2490
+ const refusal = validateUninstallOptions(opts);
2491
+ if (refusal !== null) {
2492
+ ui.notice("\uC2E4\uD328", [refusal]);
2444
2493
  return 1;
2445
2494
  }
2446
- const detected = filterByRequestedHosts(await detectHosts(io), opts.hosts);
2447
- if (detected.length === 0) {
2448
- io.out("\uC815\uB9AC\uD560 \uD56D\uBAA9\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC5B4\uC694.");
2449
- io.out(UNINSTALL_DONE);
2450
- io.out(UNINSTALL_TOKEN_REMINDER);
2495
+ const hosts = filterByRequestedHosts(await detectHosts(io), opts.hosts);
2496
+ if (hosts.length === 0) {
2497
+ ui.text(UNINSTALL_NOTHING_FOUND);
2498
+ closing(ui);
2451
2499
  return 0;
2452
2500
  }
2453
- printDetected(io, detected);
2454
- const actionable = detected.filter((d) => d.tier !== 3);
2455
- if (actionable.length > 0 && opts.yes !== true) {
2456
- const answer = await io.ask(uninstallQuestion(actionable.length));
2457
- if (answeredNo(answer)) {
2458
- io.out(NOTHING_CHANGED);
2459
- return 0;
2460
- }
2461
- }
2462
- const results = [];
2463
- for (const d of detected) {
2464
- try {
2465
- if (d.tier === 1 && d.cli !== void 0) {
2466
- results.push(await applyCliUninstall(io, d.cli));
2467
- } else if (d.tier === 2) {
2468
- results.push(await applyFileUninstall(io, d));
2469
- } else if (d.snippet !== void 0) {
2470
- const removed = await removeSnippetToml(io, d.snippet);
2471
- results.push(
2472
- removed ?? {
2473
- hostId: d.id,
2474
- displayName: d.displayName,
2475
- tier: 3,
2476
- status: "skipped",
2477
- message: `\uC790\uB3D9 \uC218\uC815\uD558\uC9C0 \uC54A\uC544\uC694. \uC124\uC815\uC5D0 "${SERVER_NAME}" \uD56D\uBAA9\uC774 \uC788\uB2E4\uBA74 \uC9C1\uC811 \uC9C0\uC6CC \uC8FC\uC138\uC694. \uC9C0\uC6B0\uC9C0 \uC54A\uC544\uB3C4 \uC544\uBB34 \uC77C\uB3C4 \uD558\uC9C0 \uC54A\uC544\uC694.`
2478
- }
2479
- );
2480
- }
2481
- } catch (error) {
2482
- results.push({
2483
- hostId: d.id,
2484
- displayName: d.displayName,
2485
- tier: d.tier,
2486
- status: "failed",
2487
- message: describeError(error)
2488
- });
2489
- }
2490
- }
2491
- if (opts.skills !== false) {
2492
- const root = skillsPayloadRoot();
2493
- results.push(
2494
- ...await removeSkills(
2495
- io,
2496
- new Set(detected.map((d) => d.id)),
2497
- await stagedSlugs(io, root)
2498
- )
2499
- );
2500
- }
2501
- io.out("");
2502
- for (const result of results) {
2503
- printResult(io, result);
2501
+ ui.text(foundRemaining(hosts.length));
2502
+ ui.blank();
2503
+ ui.table(
2504
+ hosts.map(
2505
+ (host) => [host.displayName, surfacesOf(host.id, opts.skills)]
2506
+ )
2507
+ );
2508
+ ui.blank();
2509
+ if (opts.yes !== true && answeredNo(await io.ask(ui.question(UNINSTALL_QUESTION)))) {
2510
+ ui.blank();
2511
+ ui.text(NOTHING_CHANGED);
2512
+ return 0;
2504
2513
  }
2514
+ ui.blank();
2515
+ const verbose = opts.verbose === true;
2516
+ const reports = [];
2517
+ for (const host of hosts) {
2518
+ const outcomes = [await removeExtension({ io, verbose }, host)];
2519
+ const catalog = opts.skills === false ? null : await removeCatalog(io, host);
2520
+ if (catalog !== null) outcomes.push(catalog);
2521
+ reports.push(hostReport(host, outcomes));
2522
+ }
2523
+ printHostReports(ui, reports);
2524
+ await cleanupLegacySkills(io, new Set(hosts.map((host) => host.id)));
2505
2525
  if (await uninstallGlobally(io)) {
2506
- io.out(" \uC774 \uCEF4\uD4E8\uD130\uC5D0 \uC124\uCE58\uD55C \uC5F0\uACB0 \uD504\uB85C\uADF8\uB7A8\uB3C4 \uC9C0\uC6E0\uC5B4\uC694.");
2526
+ ui.blank();
2527
+ ui.notice("\uC815\uB9AC", [GLOBAL_UNINSTALLED]);
2507
2528
  }
2508
- io.out("");
2509
- io.out(UNINSTALL_DONE);
2510
- io.out(UNINSTALL_TOKEN_REMINDER);
2511
- const anyFailed = results.some((r) => r.status === "failed" && r.tier !== 3);
2512
- if (anyFailed) {
2513
- return 1;
2529
+ ui.blank();
2530
+ closing(ui);
2531
+ const failed2 = reports.some(
2532
+ (report) => report.rows.some((row) => row.status === "\uC2E4\uD328")
2533
+ );
2534
+ return failed2 ? 1 : 0;
2535
+ }
2536
+ function surfacesOf(hostId, skills) {
2537
+ if (skills === false || catalogCommand(hostId) === null) {
2538
+ return UNINSTALL_SURFACES.extension;
2514
2539
  }
2515
- return 0;
2540
+ return UNINSTALL_SURFACES.both;
2541
+ }
2542
+ function closing(ui) {
2543
+ ui.summary("ok", UNINSTALL_DONE);
2544
+ ui.card("info", BROWSER_CARD.title, BROWSER_CARD.lines);
2516
2545
  }
2517
2546
  var RUNNER = /\bnpx(?:\.cmd)?\b/;
2518
2547
  function runsThroughRunner(entry) {
@@ -2601,88 +2630,6 @@ async function relinkInstalledHosts(io, opts) {
2601
2630
  }
2602
2631
  return results;
2603
2632
  }
2604
- function descriptionOf2(skillMd) {
2605
- const fm = /^---\n([\s\S]*?)\n---/.exec(skillMd);
2606
- const line = /^description:\s*(.*)$/m.exec(fm?.[1] ?? "");
2607
- return (line?.[1] ?? "").trim();
2608
- }
2609
- async function listSkills(io, payloadRoot) {
2610
- const payloads = await readPayloads(io, payloadRoot);
2611
- if (payloads === null) return [];
2612
- return payloads.map((p) => ({
2613
- slug: p.slug,
2614
- description: descriptionOf2(p.files.get("SKILL.md") ?? "")
2615
- }));
2616
- }
2617
- async function skillStatus(io, payloadRoot) {
2618
- const shipped = (await listSkills(io, payloadRoot)).map((s) => s.slug);
2619
- const byDir = /* @__PURE__ */ new Map();
2620
- const unsupported = [];
2621
- for (const host of SKILL_HOSTS) {
2622
- if (host.skills.tier === 3) {
2623
- unsupported.push({ host: host.displayName, reason: host.skills.reason });
2624
- continue;
2625
- }
2626
- const dir = host.skills.skillsDir(io);
2627
- if (dir === null) continue;
2628
- byDir.set(dir, [...byDir.get(dir) ?? [], host.displayName]);
2629
- }
2630
- const dirs = [];
2631
- for (const [dir, hosts] of byDir) {
2632
- const ours = [];
2633
- const refused = [];
2634
- const absent = [];
2635
- for (const slug of shipped) {
2636
- const state = await inspectSkillDir(io, dir, slug);
2637
- if (state.kind === "ours") ours.push({ slug, version: state.version });
2638
- else if (state.kind === "refused")
2639
- refused.push({ slug, refusal: state.refusal });
2640
- else absent.push(slug);
2641
- }
2642
- dirs.push({ dir, hosts, ours, refused, absent });
2643
- }
2644
- return { dirs, unsupported };
2645
- }
2646
- async function targetDirs(io) {
2647
- const detected = new Set((await detectHosts(io)).map((d) => d.id));
2648
- const byDir = /* @__PURE__ */ new Map();
2649
- for (const host of SKILL_HOSTS) {
2650
- if (host.skills.tier !== 2 || !detected.has(host.id)) continue;
2651
- const dir = host.skills.skillsDir(io);
2652
- if (dir === null) continue;
2653
- byDir.set(dir, [...byDir.get(dir) ?? [], host.displayName]);
2654
- }
2655
- return byDir;
2656
- }
2657
- async function attachSkill(io, payloadRoot, slug, version) {
2658
- const payloads = await readPayloads(io, payloadRoot) ?? [];
2659
- const payload = payloads.find((p) => p.slug === slug);
2660
- if (payload === void 0) {
2661
- return { kind: "unknown-slug", shipped: payloads.map((p) => p.slug) };
2662
- }
2663
- const outcomes = [];
2664
- for (const [dir, hosts] of await targetDirs(io)) {
2665
- const out = await installSkillDir(io, dir, payload, version);
2666
- outcomes.push(
2667
- out.ok ? { dir, hosts } : { dir, hosts, refusal: out.refusal }
2668
- );
2669
- }
2670
- return { kind: "moved", outcomes };
2671
- }
2672
- async function detachSkill(io, payloadRoot, slug) {
2673
- const shipped = (await listSkills(io, payloadRoot)).map((s) => s.slug);
2674
- if (!shipped.includes(slug)) {
2675
- return { kind: "unknown-slug", shipped };
2676
- }
2677
- const outcomes = [];
2678
- for (const [dir, hosts] of await targetDirs(io)) {
2679
- const out = await removeSkillDir(io, dir, slug);
2680
- outcomes.push(
2681
- out.ok ? { dir, hosts } : { dir, hosts, refusal: out.refusal }
2682
- );
2683
- }
2684
- return { kind: "moved", outcomes };
2685
- }
2686
2633
  function quoteForCmd(arg) {
2687
2634
  return /[ ()]/.test(arg) ? `"${arg}"` : arg;
2688
2635
  }
@@ -2807,6 +2754,7 @@ function createNodeIo() {
2807
2754
  isInteractive() {
2808
2755
  return Boolean(process.stdin.isTTY);
2809
2756
  },
2757
+ stdoutIsTTY: Boolean(process.stdout.isTTY),
2810
2758
  out(line) {
2811
2759
  process.stdout.write(`${line}
2812
2760
  `);
@@ -2819,13 +2767,15 @@ function createNodeIo() {
2819
2767
  var PACKAGE_NAME = "@modootoday/datalab-extension-app-mcp-installer";
2820
2768
  export {
2821
2769
  BACKUP_KEEP,
2770
+ CATALOG_SERVER_NAME,
2771
+ CATALOG_URL,
2822
2772
  CLI_HOSTS,
2823
2773
  CODEX_CHATGPT_NOTE,
2824
2774
  DEFAULT_PORT,
2825
2775
  EXTENSION_ID_RE,
2826
2776
  FILE_HOSTS,
2827
2777
  INSTALLABLE_CLIS,
2828
- INSTALL_SUBTITLE,
2778
+ INSTALL_QUESTION,
2829
2779
  INVALID_EXTENSION_ID_MESSAGE,
2830
2780
  INVALID_PORT_MESSAGE,
2831
2781
  INVALID_TOKEN_MESSAGE,
@@ -2835,7 +2785,6 @@ export {
2835
2785
  PACKAGE_NAME,
2836
2786
  PERMISSION_DENIED_HINT,
2837
2787
  PORT_RE,
2838
- RESTART_NOTICE,
2839
2788
  SERVER_NAME,
2840
2789
  SERVER_PACKAGE,
2841
2790
  SNIPPET_HOSTS,
@@ -2843,32 +2792,27 @@ export {
2843
2792
  TOKEN_PROMPT_GUIDE,
2844
2793
  TOKEN_PROMPT_QUESTION,
2845
2794
  TOKEN_RE,
2846
- TOKEN_REQUIRED_NON_INTERACTIVE,
2795
+ TOKEN_REQUIRED,
2847
2796
  UNINSTALL_DONE,
2848
- UNINSTALL_SUBTITLE,
2849
- UNINSTALL_TOKEN_REMINDER,
2797
+ UNINSTALL_QUESTION,
2850
2798
  VERSION_RE,
2851
- attachSkill,
2852
2799
  buildEnv,
2853
2800
  buildFileEntry,
2801
+ cleanupLegacySkills,
2854
2802
  createNodeIo,
2855
- detachSkill,
2803
+ createUi,
2856
2804
  detectHosts,
2805
+ displayWidth,
2857
2806
  formatBackupTimestamp,
2858
2807
  installGlobally,
2859
- installQuestion,
2860
- listSkills,
2861
2808
  packageSpec,
2862
- printBanner,
2863
2809
  relinkInstalledHosts,
2864
2810
  removeServerKey,
2865
2811
  resolveGlobalLaunch,
2866
2812
  runInstall,
2867
2813
  runUninstall,
2868
- skillStatus,
2869
- skillsPayloadRoot,
2814
+ terminalCaps,
2870
2815
  uninstallGlobally,
2871
- uninstallQuestion,
2872
2816
  upsertServerKey,
2873
2817
  validateInstallOptions,
2874
2818
  validateUninstallOptions