connectbase-client 6.22.0 → 6.24.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.
- package/CHANGELOG.md +28 -1
- package/dist/cli.js +942 -287
- package/dist/connect-base.umd.js +1 -1
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -68,29 +68,381 @@ __export(cli_exports, {
|
|
|
68
68
|
});
|
|
69
69
|
module.exports = __toCommonJS(cli_exports);
|
|
70
70
|
var crypto = __toESM(require("crypto"));
|
|
71
|
-
var
|
|
71
|
+
var fs5 = __toESM(require("fs"));
|
|
72
72
|
var http2 = __toESM(require("http"));
|
|
73
73
|
var https = __toESM(require("https"));
|
|
74
74
|
var os4 = __toESM(require("os"));
|
|
75
|
-
var
|
|
75
|
+
var path5 = __toESM(require("path"));
|
|
76
76
|
var readline = __toESM(require("readline"));
|
|
77
77
|
|
|
78
78
|
// src/local-command.ts
|
|
79
79
|
var import_node_crypto = require("crypto");
|
|
80
|
-
var
|
|
80
|
+
var fs3 = __toESM(require("fs"));
|
|
81
81
|
var os2 = __toESM(require("os"));
|
|
82
|
-
var
|
|
82
|
+
var path3 = __toESM(require("path"));
|
|
83
83
|
|
|
84
|
-
// src/local-
|
|
84
|
+
// src/local-mcp-hub.ts
|
|
85
85
|
var import_node_child_process = require("child_process");
|
|
86
86
|
var fs = __toESM(require("fs"));
|
|
87
|
+
var path = __toESM(require("path"));
|
|
88
|
+
var LOCAL_CONFIG_FILE = "connectbase-local.json";
|
|
89
|
+
var CALL_TIMEOUT_MS = 1e5;
|
|
90
|
+
var START_TIMEOUT_MS = 6e4;
|
|
91
|
+
function loadLocalConfig(dir) {
|
|
92
|
+
const p = path.join(dir, LOCAL_CONFIG_FILE);
|
|
93
|
+
if (!fs.existsSync(p)) return { mcpServers: {} };
|
|
94
|
+
const raw = JSON.parse(fs.readFileSync(p, "utf-8"));
|
|
95
|
+
return { mcpServers: raw.mcpServers ?? {} };
|
|
96
|
+
}
|
|
97
|
+
function saveLocalConfig(dir, cfg) {
|
|
98
|
+
const p = path.join(dir, LOCAL_CONFIG_FILE);
|
|
99
|
+
let prev = {};
|
|
100
|
+
try {
|
|
101
|
+
prev = JSON.parse(fs.readFileSync(p, "utf-8"));
|
|
102
|
+
} catch {
|
|
103
|
+
}
|
|
104
|
+
fs.writeFileSync(
|
|
105
|
+
p,
|
|
106
|
+
`${JSON.stringify({ ...prev, mcpServers: cfg.mcpServers }, null, 2)}
|
|
107
|
+
`
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
function parseMcpFlag(flag) {
|
|
111
|
+
const eq = flag.indexOf("=");
|
|
112
|
+
if (eq <= 0)
|
|
113
|
+
throw new Error(
|
|
114
|
+
`--mcp \uB294 \uC774\uB984=\uBA85\uB839 \uAF34\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4 (\uC608: --mcp blender="uvx blender-mcp"): ${flag}`
|
|
115
|
+
);
|
|
116
|
+
const name = flag.slice(0, eq).trim();
|
|
117
|
+
const rest = flag.slice(eq + 1).trim();
|
|
118
|
+
if (!/^[\w.-]+$/.test(name))
|
|
119
|
+
throw new Error(`MCP \uC774\uB984\uC740 \uC601\uBB38, \uC22B\uC790, - _ . \uB9CC \uC501\uB2C8\uB2E4: ${name}`);
|
|
120
|
+
if (/^https?:\/\//.test(rest)) return { name, def: { url: rest } };
|
|
121
|
+
const parts = rest.match(/"[^"]*"|'[^']*'|\S+/g)?.map((p) => p.replace(/^["']|["']$/g, "")) ?? [];
|
|
122
|
+
if (!parts.length) throw new Error(`--mcp ${name} \uC758 \uBA85\uB839\uC774 \uBE44\uC5C8\uC2B5\uB2C8\uB2E4`);
|
|
123
|
+
return { name, def: { command: parts[0], args: parts.slice(1) } };
|
|
124
|
+
}
|
|
125
|
+
var StdioClient = class {
|
|
126
|
+
constructor(name, def, baseEnv, cwd) {
|
|
127
|
+
this.name = name;
|
|
128
|
+
this.def = def;
|
|
129
|
+
this.baseEnv = baseEnv;
|
|
130
|
+
this.cwd = cwd;
|
|
131
|
+
this.buf = "";
|
|
132
|
+
this.seq = 0;
|
|
133
|
+
this.pending = /* @__PURE__ */ new Map();
|
|
134
|
+
this.stderrTail = "";
|
|
135
|
+
}
|
|
136
|
+
alive() {
|
|
137
|
+
return !!this.proc && this.proc.exitCode === null && !this.proc.killed;
|
|
138
|
+
}
|
|
139
|
+
async start() {
|
|
140
|
+
const proc = (0, import_node_child_process.spawn)(this.def.command, this.def.args ?? [], {
|
|
141
|
+
cwd: this.def.cwd ? path.resolve(this.cwd, this.def.cwd) : this.cwd,
|
|
142
|
+
env: { ...this.baseEnv, ...this.def.env ?? {} },
|
|
143
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
144
|
+
// Windows 의 npx, uvx 는 .cmd 라 셸로 띄워야 한다
|
|
145
|
+
shell: process.platform === "win32",
|
|
146
|
+
windowsHide: true
|
|
147
|
+
});
|
|
148
|
+
this.proc = proc;
|
|
149
|
+
proc.stdout?.on("data", (d) => {
|
|
150
|
+
this.buf += d.toString();
|
|
151
|
+
let i = this.buf.indexOf("\n");
|
|
152
|
+
while (i >= 0) {
|
|
153
|
+
const line = this.buf.slice(0, i).trim();
|
|
154
|
+
this.buf = this.buf.slice(i + 1);
|
|
155
|
+
if (line) this.onLine(line);
|
|
156
|
+
i = this.buf.indexOf("\n");
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
proc.stderr?.on("data", (d) => {
|
|
160
|
+
this.stderrTail = (this.stderrTail + d.toString()).slice(-2e3);
|
|
161
|
+
});
|
|
162
|
+
const fail = (why) => {
|
|
163
|
+
for (const [, p] of this.pending) {
|
|
164
|
+
clearTimeout(p.timer);
|
|
165
|
+
p.reject(
|
|
166
|
+
new Error(
|
|
167
|
+
`${this.name}: ${why}${this.stderrTail ? `
|
|
168
|
+
${this.stderrTail.slice(-600)}` : ""}`
|
|
169
|
+
)
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
this.pending.clear();
|
|
173
|
+
};
|
|
174
|
+
proc.on("exit", (code) => fail(`MCP \uC11C\uBC84\uAC00 \uB05D\uB0AC\uC2B5\uB2C8\uB2E4 (\uCF54\uB4DC ${code})`));
|
|
175
|
+
proc.on("error", (e) => fail(`\uB744\uC6B0\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4: ${e.message}`));
|
|
176
|
+
}
|
|
177
|
+
onLine(line) {
|
|
178
|
+
let msg;
|
|
179
|
+
try {
|
|
180
|
+
msg = JSON.parse(line);
|
|
181
|
+
} catch {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const id = msg.id;
|
|
185
|
+
if (id === void 0 || !this.pending.has(id)) return;
|
|
186
|
+
const p = this.pending.get(id);
|
|
187
|
+
this.pending.delete(id);
|
|
188
|
+
if (!p) return;
|
|
189
|
+
clearTimeout(p.timer);
|
|
190
|
+
if (msg.error)
|
|
191
|
+
p.reject(
|
|
192
|
+
new Error(`${this.name}: ${JSON.stringify(msg.error).slice(0, 500)}`)
|
|
193
|
+
);
|
|
194
|
+
else p.resolve(msg.result ?? {});
|
|
195
|
+
}
|
|
196
|
+
request(method, params, timeoutMs = CALL_TIMEOUT_MS) {
|
|
197
|
+
return new Promise((resolve5, reject) => {
|
|
198
|
+
if (!this.alive())
|
|
199
|
+
return reject(new Error(`${this.name}: MCP \uC11C\uBC84\uAC00 \uAEBC\uC838 \uC788\uC2B5\uB2C8\uB2E4`));
|
|
200
|
+
const id = ++this.seq;
|
|
201
|
+
const timer = setTimeout(() => {
|
|
202
|
+
this.pending.delete(id);
|
|
203
|
+
reject(
|
|
204
|
+
new Error(
|
|
205
|
+
`${this.name}: ${Math.round(timeoutMs / 1e3)}\uCD08 \uC548\uC5D0 \uB2F5\uD558\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4`
|
|
206
|
+
)
|
|
207
|
+
);
|
|
208
|
+
}, timeoutMs);
|
|
209
|
+
this.pending.set(id, { resolve: resolve5, reject, timer });
|
|
210
|
+
this.proc?.stdin?.write(
|
|
211
|
+
`${JSON.stringify({ jsonrpc: "2.0", id, method, params })}
|
|
212
|
+
`
|
|
213
|
+
);
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
notify(method) {
|
|
217
|
+
this.proc?.stdin?.write(`${JSON.stringify({ jsonrpc: "2.0", method })}
|
|
218
|
+
`);
|
|
219
|
+
}
|
|
220
|
+
close() {
|
|
221
|
+
try {
|
|
222
|
+
this.proc?.kill();
|
|
223
|
+
} catch {
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
var HttpClient = class {
|
|
228
|
+
constructor(name, def) {
|
|
229
|
+
this.name = name;
|
|
230
|
+
this.def = def;
|
|
231
|
+
this.seq = 0;
|
|
232
|
+
this.ok = false;
|
|
233
|
+
}
|
|
234
|
+
alive() {
|
|
235
|
+
return this.ok;
|
|
236
|
+
}
|
|
237
|
+
async start() {
|
|
238
|
+
this.ok = true;
|
|
239
|
+
}
|
|
240
|
+
async request(method, params, timeoutMs = CALL_TIMEOUT_MS) {
|
|
241
|
+
const headers = {
|
|
242
|
+
"Content-Type": "application/json",
|
|
243
|
+
Accept: "application/json, text/event-stream",
|
|
244
|
+
...this.def.headers ?? {}
|
|
245
|
+
};
|
|
246
|
+
if (this.session) headers["Mcp-Session-Id"] = this.session;
|
|
247
|
+
const ctrl = new AbortController();
|
|
248
|
+
const t = setTimeout(() => ctrl.abort(), timeoutMs);
|
|
249
|
+
try {
|
|
250
|
+
const id = ++this.seq;
|
|
251
|
+
const r = await fetch(this.def.url, {
|
|
252
|
+
method: "POST",
|
|
253
|
+
headers,
|
|
254
|
+
body: JSON.stringify({ jsonrpc: "2.0", id, method, params }),
|
|
255
|
+
signal: ctrl.signal
|
|
256
|
+
});
|
|
257
|
+
const sid = r.headers.get("mcp-session-id");
|
|
258
|
+
if (sid) this.session = sid;
|
|
259
|
+
const raw = await r.text();
|
|
260
|
+
if (!r.ok)
|
|
261
|
+
throw new Error(`${this.name}: HTTP ${r.status} ${raw.slice(0, 300)}`);
|
|
262
|
+
const body = raw.trimStart().startsWith("{") ? raw : raw.split("\n").filter((l) => l.startsWith("data:")).map((l) => l.slice(5).trim()).filter(
|
|
263
|
+
(l) => l.includes(`"id":${id}`) || l.includes(`"id": ${id}`)
|
|
264
|
+
).pop() ?? "{}";
|
|
265
|
+
const msg = JSON.parse(body);
|
|
266
|
+
if (msg.error)
|
|
267
|
+
throw new Error(
|
|
268
|
+
`${this.name}: ${JSON.stringify(msg.error).slice(0, 500)}`
|
|
269
|
+
);
|
|
270
|
+
return msg.result ?? {};
|
|
271
|
+
} catch (e) {
|
|
272
|
+
this.ok = !(e instanceof TypeError);
|
|
273
|
+
throw e instanceof Error && e.name === "AbortError" ? new Error(
|
|
274
|
+
`${this.name}: ${Math.round(timeoutMs / 1e3)}\uCD08 \uC548\uC5D0 \uB2F5\uD558\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4`
|
|
275
|
+
) : e;
|
|
276
|
+
} finally {
|
|
277
|
+
clearTimeout(t);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
notifyInitialized() {
|
|
281
|
+
const headers = {
|
|
282
|
+
"Content-Type": "application/json",
|
|
283
|
+
...this.def.headers ?? {}
|
|
284
|
+
};
|
|
285
|
+
if (this.session) headers["Mcp-Session-Id"] = this.session;
|
|
286
|
+
void fetch(this.def.url, {
|
|
287
|
+
method: "POST",
|
|
288
|
+
headers,
|
|
289
|
+
body: JSON.stringify({
|
|
290
|
+
jsonrpc: "2.0",
|
|
291
|
+
method: "notifications/initialized"
|
|
292
|
+
})
|
|
293
|
+
}).catch(() => {
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
close() {
|
|
297
|
+
this.ok = false;
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
var LocalMcpHub = class {
|
|
301
|
+
constructor(dir, env, log2, reserved, onChange) {
|
|
302
|
+
this.dir = dir;
|
|
303
|
+
this.env = env;
|
|
304
|
+
this.log = log2;
|
|
305
|
+
this.reserved = reserved;
|
|
306
|
+
this.onChange = onChange;
|
|
307
|
+
this.entries = /* @__PURE__ */ new Map();
|
|
308
|
+
this.exposed = [];
|
|
309
|
+
}
|
|
310
|
+
/** 정의 파일을 읽어 모두 (다시) 띄운다. */
|
|
311
|
+
async reload() {
|
|
312
|
+
for (const e of this.entries.values()) e.client?.close();
|
|
313
|
+
this.entries.clear();
|
|
314
|
+
let cfg;
|
|
315
|
+
try {
|
|
316
|
+
cfg = loadLocalConfig(this.dir);
|
|
317
|
+
} catch (e) {
|
|
318
|
+
this.log(
|
|
319
|
+
`${LOCAL_CONFIG_FILE} \uB97C \uC77D\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4: ${e instanceof Error ? e.message : e}`
|
|
320
|
+
);
|
|
321
|
+
cfg = { mcpServers: {} };
|
|
322
|
+
}
|
|
323
|
+
await Promise.all(
|
|
324
|
+
Object.entries(cfg.mcpServers).filter(([, d]) => d.enabled !== false).map(([name, def]) => this.startOne(name, def))
|
|
325
|
+
);
|
|
326
|
+
this.rebuild();
|
|
327
|
+
this.onChange();
|
|
328
|
+
}
|
|
329
|
+
async startOne(name, def) {
|
|
330
|
+
const e = { name, def, tools: [] };
|
|
331
|
+
this.entries.set(name, e);
|
|
332
|
+
if (!def.command && !def.url) {
|
|
333
|
+
e.error = "command \uB098 url \uC774 \uC5C6\uC2B5\uB2C8\uB2E4";
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
const client = def.url ? new HttpClient(name, def) : new StdioClient(name, def, this.env(), this.dir);
|
|
337
|
+
e.client = client;
|
|
338
|
+
try {
|
|
339
|
+
await client.start();
|
|
340
|
+
await client.request(
|
|
341
|
+
"initialize",
|
|
342
|
+
{
|
|
343
|
+
protocolVersion: "2025-06-18",
|
|
344
|
+
capabilities: {},
|
|
345
|
+
clientInfo: { name: "connectbase-local", version: "1.0.0" }
|
|
346
|
+
},
|
|
347
|
+
START_TIMEOUT_MS
|
|
348
|
+
);
|
|
349
|
+
if (client instanceof StdioClient)
|
|
350
|
+
client.notify("notifications/initialized");
|
|
351
|
+
else client.notifyInitialized();
|
|
352
|
+
const tools = [];
|
|
353
|
+
let cursor;
|
|
354
|
+
do {
|
|
355
|
+
const r = await client.request(
|
|
356
|
+
"tools/list",
|
|
357
|
+
cursor ? { cursor } : {},
|
|
358
|
+
START_TIMEOUT_MS
|
|
359
|
+
);
|
|
360
|
+
for (const t of r.tools ?? [])
|
|
361
|
+
tools.push({
|
|
362
|
+
name: String(t.name),
|
|
363
|
+
description: String(t.description ?? ""),
|
|
364
|
+
inputSchema: t.inputSchema ?? { type: "object" }
|
|
365
|
+
});
|
|
366
|
+
cursor = r.nextCursor;
|
|
367
|
+
} while (cursor);
|
|
368
|
+
e.tools = tools;
|
|
369
|
+
this.log(`MCP ${name}: \uB3C4\uAD6C ${tools.length}\uAC1C`);
|
|
370
|
+
} catch (err) {
|
|
371
|
+
e.error = err instanceof Error ? err.message : String(err);
|
|
372
|
+
this.log(`MCP ${name} \uC5F0\uACB0 \uC2E4\uD328: ${e.error.split("\n")[0]}`);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
rebuild() {
|
|
376
|
+
const reserved = this.reserved();
|
|
377
|
+
const count = /* @__PURE__ */ new Map();
|
|
378
|
+
for (const e of this.entries.values())
|
|
379
|
+
for (const t of e.tools) count.set(t.name, (count.get(t.name) ?? 0) + 1);
|
|
380
|
+
this.exposed = [];
|
|
381
|
+
for (const e of this.entries.values())
|
|
382
|
+
for (const t of e.tools) {
|
|
383
|
+
const clash = reserved.has(t.name) || (count.get(t.name) ?? 0) > 1;
|
|
384
|
+
this.exposed.push({
|
|
385
|
+
server: e.name,
|
|
386
|
+
name: t.name,
|
|
387
|
+
exposed: clash ? `${e.name}__${t.name}` : t.name,
|
|
388
|
+
description: `[\uB0B4 PC MCP: ${e.name}] ${t.description}`,
|
|
389
|
+
inputSchema: t.inputSchema
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
tools() {
|
|
394
|
+
return this.exposed;
|
|
395
|
+
}
|
|
396
|
+
has(exposed) {
|
|
397
|
+
return this.exposed.some((t) => t.exposed === exposed);
|
|
398
|
+
}
|
|
399
|
+
/** 원래 이름으로 이 서버들 중 누가 그 도구를 갖고 있는가 (내장 BlenderMCP 대신 쓸지 정할 때). */
|
|
400
|
+
providesOriginal(name) {
|
|
401
|
+
return this.exposed.some((t) => t.name === name);
|
|
402
|
+
}
|
|
403
|
+
status() {
|
|
404
|
+
return [...this.entries.values()].map((e) => ({
|
|
405
|
+
name: e.name,
|
|
406
|
+
kind: e.def.url ? `http ${e.def.url}` : `${e.def.command} ${(e.def.args ?? []).join(" ")}`.trim(),
|
|
407
|
+
ok: !e.error && !!e.client?.alive(),
|
|
408
|
+
tools: e.tools.length,
|
|
409
|
+
...e.error ? { error: e.error.slice(0, 400) } : {}
|
|
410
|
+
}));
|
|
411
|
+
}
|
|
412
|
+
async call(exposed, args) {
|
|
413
|
+
const t = this.exposed.find((x) => x.exposed === exposed);
|
|
414
|
+
if (!t) throw new Error(`\uC5C6\uB294 \uB3C4\uAD6C: ${exposed}`);
|
|
415
|
+
const e = this.entries.get(t.server);
|
|
416
|
+
if (!e?.client) throw new Error(`${t.server}: \uC5F0\uACB0\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4`);
|
|
417
|
+
if (!e.client.alive()) {
|
|
418
|
+
await this.startOne(e.name, e.def);
|
|
419
|
+
this.rebuild();
|
|
420
|
+
}
|
|
421
|
+
const c = this.entries.get(t.server)?.client;
|
|
422
|
+
if (!c) throw new Error(`${t.server}: \uC5F0\uACB0\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4`);
|
|
423
|
+
return c.request("tools/call", { name: t.name, arguments: args });
|
|
424
|
+
}
|
|
425
|
+
close() {
|
|
426
|
+
for (const e of this.entries.values()) e.client?.close();
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
// src/local-runner.ts
|
|
431
|
+
var import_node_child_process2 = require("child_process");
|
|
432
|
+
var fs2 = __toESM(require("fs"));
|
|
87
433
|
var http = __toESM(require("http"));
|
|
88
434
|
var net = __toESM(require("net"));
|
|
89
435
|
var os = __toESM(require("os"));
|
|
90
|
-
var
|
|
436
|
+
var path2 = __toESM(require("path"));
|
|
91
437
|
var MAX_OUT = 24e3;
|
|
92
438
|
var MAX_READ = 2e5;
|
|
93
439
|
var MAX_IMAGE = 8 * 1024 * 1024;
|
|
440
|
+
var BLENDER_MCP_TOOLS = /* @__PURE__ */ new Set([
|
|
441
|
+
"execute_blender_code",
|
|
442
|
+
"get_scene_info",
|
|
443
|
+
"get_object_info",
|
|
444
|
+
"get_viewport_screenshot"
|
|
445
|
+
]);
|
|
94
446
|
var PROTOCOL_VERSIONS = ["2025-06-18", "2025-03-26", "2024-11-05"];
|
|
95
447
|
var text = (t, isError = false) => ({
|
|
96
448
|
content: [{ type: "text", text: t }],
|
|
@@ -101,7 +453,7 @@ ${s.slice(-n)}` : s;
|
|
|
101
453
|
var str = (v, d = "") => typeof v === "string" ? v : d;
|
|
102
454
|
var num = (v, d) => typeof v === "number" && Number.isFinite(v) ? v : d;
|
|
103
455
|
function imageMime(p) {
|
|
104
|
-
const ext =
|
|
456
|
+
const ext = path2.extname(p).toLowerCase();
|
|
105
457
|
return {
|
|
106
458
|
".png": "image/png",
|
|
107
459
|
".jpg": "image/jpeg",
|
|
@@ -112,22 +464,22 @@ function imageMime(p) {
|
|
|
112
464
|
}
|
|
113
465
|
function findPrograms() {
|
|
114
466
|
const which = (names, extra = []) => {
|
|
115
|
-
const dirs = (process.env.PATH ?? "").split(
|
|
467
|
+
const dirs = (process.env.PATH ?? "").split(path2.delimiter).filter(Boolean);
|
|
116
468
|
const exts = process.platform === "win32" ? ["", ".exe", ".cmd", ".bat"] : [""];
|
|
117
469
|
for (const n of names) {
|
|
118
|
-
if (
|
|
470
|
+
if (path2.isAbsolute(n) && fs2.existsSync(n)) return n;
|
|
119
471
|
for (const d of dirs)
|
|
120
472
|
for (const e of exts) {
|
|
121
|
-
const p =
|
|
122
|
-
if (
|
|
473
|
+
const p = path2.join(d, n + e);
|
|
474
|
+
if (fs2.existsSync(p)) return p;
|
|
123
475
|
}
|
|
124
476
|
}
|
|
125
|
-
for (const p of extra) if (
|
|
477
|
+
for (const p of extra) if (fs2.existsSync(p)) return p;
|
|
126
478
|
return null;
|
|
127
479
|
};
|
|
128
480
|
const globDirs = (root, pattern, sub) => {
|
|
129
481
|
try {
|
|
130
|
-
return
|
|
482
|
+
return fs2.readdirSync(root).filter((n) => pattern.test(n)).sort().reverse().map((n) => path2.join(root, n, sub));
|
|
131
483
|
} catch {
|
|
132
484
|
return [];
|
|
133
485
|
}
|
|
@@ -147,7 +499,7 @@ function findPrograms() {
|
|
|
147
499
|
"ZBrush.app/Contents/MacOS/ZBrush"
|
|
148
500
|
) : process.platform === "win32" ? globDirs("C:\\Program Files", /^Maxon ZBrush/, "ZBrush.exe") : [];
|
|
149
501
|
return {
|
|
150
|
-
blender: process.env.BLENDER_BIN &&
|
|
502
|
+
blender: process.env.BLENDER_BIN && fs2.existsSync(process.env.BLENDER_BIN) ? process.env.BLENDER_BIN : which(["blender"], blenderExtra),
|
|
151
503
|
zbrush: which([], zbrushExtra),
|
|
152
504
|
python: which(
|
|
153
505
|
process.platform === "win32" ? ["python", "py"] : ["python3", "python"]
|
|
@@ -155,13 +507,13 @@ function findPrograms() {
|
|
|
155
507
|
uv: which(
|
|
156
508
|
["uv"],
|
|
157
509
|
[
|
|
158
|
-
|
|
510
|
+
path2.join(
|
|
159
511
|
os.homedir(),
|
|
160
512
|
".local",
|
|
161
513
|
"bin",
|
|
162
514
|
process.platform === "win32" ? "uv.exe" : "uv"
|
|
163
515
|
),
|
|
164
|
-
|
|
516
|
+
path2.join(os.homedir(), ".cargo", "bin", "uv")
|
|
165
517
|
]
|
|
166
518
|
),
|
|
167
519
|
node: process.execPath,
|
|
@@ -176,23 +528,53 @@ var LocalRunner = class {
|
|
|
176
528
|
this.jobs = /* @__PURE__ */ new Map();
|
|
177
529
|
this.jobSeq = 0;
|
|
178
530
|
this.opts = opts;
|
|
179
|
-
this.dir =
|
|
180
|
-
this.skillsDir =
|
|
181
|
-
|
|
531
|
+
this.dir = path2.resolve(opts.dir);
|
|
532
|
+
this.skillsDir = path2.join(this.dir, "skills");
|
|
533
|
+
fs2.mkdirSync(this.skillsDir, { recursive: true });
|
|
182
534
|
this.programs = findPrograms();
|
|
183
535
|
this.tools = this.defineTools();
|
|
536
|
+
this.hub = new LocalMcpHub(
|
|
537
|
+
this.dir,
|
|
538
|
+
() => this.env(),
|
|
539
|
+
(l) => this.log(l),
|
|
540
|
+
() => new Set(
|
|
541
|
+
this.tools.map((t) => t.name).filter((n) => !BLENDER_MCP_TOOLS.has(n))
|
|
542
|
+
),
|
|
543
|
+
() => this.opts.onSkillsChanged?.()
|
|
544
|
+
);
|
|
545
|
+
}
|
|
546
|
+
/** connectbase-local.json 의 MCP 서버를 띄운다. */
|
|
547
|
+
startMcp() {
|
|
548
|
+
return this.hub.reload();
|
|
549
|
+
}
|
|
550
|
+
/** AI 에게 보이는 도구: 내장 + PC 의 MCP. PC 에 BlenderMCP 를 정의했으면 내장 대신 그것을 쓴다. */
|
|
551
|
+
visibleTools() {
|
|
552
|
+
const own = this.tools.filter(
|
|
553
|
+
(t) => !(BLENDER_MCP_TOOLS.has(t.name) && this.hub.providesOriginal(t.name))
|
|
554
|
+
).map(({ name, description, inputSchema, annotations }) => ({
|
|
555
|
+
name,
|
|
556
|
+
description: name === "read_skill" ? this.skillIndexText() : description,
|
|
557
|
+
inputSchema,
|
|
558
|
+
...annotations ? { annotations } : {}
|
|
559
|
+
}));
|
|
560
|
+
const fromHub = this.hub.tools().map((t) => ({
|
|
561
|
+
name: t.exposed,
|
|
562
|
+
description: t.description,
|
|
563
|
+
inputSchema: t.inputSchema
|
|
564
|
+
}));
|
|
565
|
+
return [...own, ...fromHub];
|
|
184
566
|
}
|
|
185
567
|
log(line) {
|
|
186
568
|
(this.opts.log ?? console.log)(line);
|
|
187
569
|
}
|
|
188
570
|
/** 작업 폴더 안의 경로로 푼다. 절대 경로도 작업 폴더 안이어야 한다. */
|
|
189
571
|
inDir(p) {
|
|
190
|
-
const abs =
|
|
572
|
+
const abs = path2.resolve(
|
|
191
573
|
this.dir,
|
|
192
574
|
p.replace(/^~(?=$|[\\/])/, os.homedir())
|
|
193
575
|
);
|
|
194
|
-
const rel =
|
|
195
|
-
if (rel.startsWith("..") ||
|
|
576
|
+
const rel = path2.relative(this.dir, abs);
|
|
577
|
+
if (rel.startsWith("..") || path2.isAbsolute(rel))
|
|
196
578
|
throw new Error(
|
|
197
579
|
`\uC791\uC5C5 \uD3F4\uB354(${this.dir}) \uBC16\uC758 \uACBD\uB85C\uB294 \uC4F8 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ${p}`
|
|
198
580
|
);
|
|
@@ -220,7 +602,6 @@ var LocalRunner = class {
|
|
|
220
602
|
annotations: ro,
|
|
221
603
|
run: async () => {
|
|
222
604
|
this.programs = findPrograms();
|
|
223
|
-
const skills = fs.existsSync(this.skillsDir) ? fs.readdirSync(this.skillsDir) : [];
|
|
224
605
|
const blenderLive = await this.blenderPing();
|
|
225
606
|
return text(
|
|
226
607
|
JSON.stringify(
|
|
@@ -228,7 +609,9 @@ var LocalRunner = class {
|
|
|
228
609
|
os: `${process.platform} ${os.release()} ${process.arch}`,
|
|
229
610
|
work_dir: this.dir,
|
|
230
611
|
skills_dir: this.skillsDir,
|
|
231
|
-
installed_skills:
|
|
612
|
+
installed_skills: this.listSkills().map((k) => k.name),
|
|
613
|
+
mcp_config: path2.join(this.dir, LOCAL_CONFIG_FILE),
|
|
614
|
+
mcp_servers: this.hub.status(),
|
|
232
615
|
programs: this.programs,
|
|
233
616
|
blender_mcp: blenderLive ? `\uC5F0\uACB0\uB428 (localhost:${this.blenderPort})` : `\uC5C6\uC74C (Blender \uC5D0\uC11C BlenderMCP \uC560\uB4DC\uC628 > Start \uB97C \uB204\uB974\uBA74 execute_blender_code \uB4F1\uC744 \uC4F8 \uC218 \uC788\uB2E4)`,
|
|
234
617
|
notes: [
|
|
@@ -242,13 +625,46 @@ var LocalRunner = class {
|
|
|
242
625
|
);
|
|
243
626
|
}
|
|
244
627
|
},
|
|
628
|
+
{
|
|
629
|
+
name: "read_skill",
|
|
630
|
+
// 설명은 tools/list 때 설치된 스킬 목록으로 채운다 (toolList)
|
|
631
|
+
description: "",
|
|
632
|
+
inputSchema: {
|
|
633
|
+
type: "object",
|
|
634
|
+
properties: {
|
|
635
|
+
name: { type: "string", description: "\uC2A4\uD0AC \uC774\uB984 (\uBAA9\uB85D\uC758 \uC774\uB984)" }
|
|
636
|
+
},
|
|
637
|
+
required: ["name"]
|
|
638
|
+
},
|
|
639
|
+
annotations: ro,
|
|
640
|
+
run: async (a) => {
|
|
641
|
+
const k = this.listSkills().find((x) => x.name === str(a.name));
|
|
642
|
+
if (!k)
|
|
643
|
+
return text(
|
|
644
|
+
`\uC124\uCE58\uB41C \uC2A4\uD0AC\uC774 \uC544\uB2D9\uB2C8\uB2E4: ${str(a.name)}
|
|
645
|
+
${this.skillIndexText()}`,
|
|
646
|
+
true
|
|
647
|
+
);
|
|
648
|
+
const body = fs2.readFileSync(path2.join(k.dir, "SKILL.md"), "utf-8").split("{{SKILL_DIR}}").join(k.dir);
|
|
649
|
+
const head = `> \uC2A4\uD0AC \uD3F4\uB354(skill_dir): ${k.dir}
|
|
650
|
+
> \uC774 \uC2A4\uD0AC\uC740 \uC0AC\uC6A9\uC790 \uCEF4\uD4E8\uD130\uC5D0\uC11C \uB3C8\uB2E4. \uBCF8\uBB38\uC758 {{SKILL_DIR}}, ~/.claude/skills/<\uC774\uB984>, ~/.codex/skills/<\uC774\uB984> \uC740 \uC704 skill_dir(\uB2E4\uB978 \uC2A4\uD0AC\uC774\uBA74 \uADF8 \uC2A4\uD0AC \uD3F4\uB354)\uB85C \uBC14\uAFD4 \uC77D\uB294\uB2E4.
|
|
651
|
+
> \uC178 \uBA85\uB839\uC740 run(90\uCD08 \uB118\uC73C\uBA74 background=true \uB4A4 job_status), \uD30C\uC77C\uC740 read_file, write_file, list_files, \uADF8\uB9BC \uD655\uC778\uC740 view_image, \uADF8\uB9BC \uC0DD\uC131\uC740 image_generate, \uB0B4\uB824\uBC1B\uAE30\uB294 download, \uACB0\uACFC \uAC74\uB124\uAE30\uB294 upload_to_storage, \uC2E4\uD589 \uC911\uC778 Blender \uB294 execute_blender_code \uB4F1\uC73C\uB85C \uD55C\uB2E4. \uC2A4\uD0AC\uC774 \uC5B4\uB5A4 MCP \uC758 \uB3C4\uAD6C\uB97C \uC4F0\uB77C\uACE0 \uD558\uBA74 \uC774 PC \uC5D0 \uC815\uC758\uB41C MCP \uB3C4\uAD6C([\uB0B4 PC MCP: \uC774\uB984])\uB97C \uADF8 \uC774\uB984\uC73C\uB85C \uBD80\uB974\uACE0, \uC5C6\uC73C\uBA74 local_info \uB85C \uD655\uC778\uD55C \uB4A4 \uC0AC\uC6A9\uC790\uC5D0\uAC8C \uADF8 MCP \uB97C connectbase-local.json \uC5D0 \uB123\uC790\uACE0 \uC548\uB0B4\uD55C\uB2E4(mcp_reload).
|
|
652
|
+
> \uD544\uC694\uD55C \uD504\uB85C\uADF8\uB7A8\uC774 \uC5C6\uC73C\uBA74(local_info \uB85C \uD655\uC778) \uC124\uCE58 \uBC29\uBC95\uC744 \uC54C\uB824 \uC8FC\uACE0 \uAE30\uB2E4\uB9B0\uB2E4. \uD558\uC704 \uC5D0\uC774\uC804\uD2B8\uB85C \uAC80\uD1A0\uD558\uB77C\uB294 \uACF3\uC740 \uC2A4\uC2A4\uB85C \uC0C8 \uB208\uC73C\uB85C \uB2E4\uC2DC \uBCF8\uB2E4.
|
|
653
|
+
|
|
654
|
+
`;
|
|
655
|
+
return text(head + body);
|
|
656
|
+
}
|
|
657
|
+
},
|
|
245
658
|
{
|
|
246
659
|
name: "skill_install",
|
|
247
|
-
description: "
|
|
660
|
+
description: "\uC0AC\uC6A9\uC790\uAC00 \uC6D0\uD560 \uB54C \uC2A4\uD0AC\uC744 \uC774 \uCEF4\uD4E8\uD130\uC5D0 \uC124\uCE58\uD55C\uB2E4 (SKILL.md \uC640 references/, scripts/ \uB97C \uD1B5\uC9F8\uB85C). source: GitHub 'owner/repo' (\uC800\uC7A5\uC18C\uC758 \uC2A4\uD0AC \uBAA8\uB450), 'owner/repo/\uD3F4\uB354[@ref]' (\uADF8 \uD3F4\uB354\uC758 \uC2A4\uD0AC), github.com \uC8FC\uC18C, \uB610\uB294 \uC774 \uCEF4\uD4E8\uD130\uC758 \uD3F4\uB354 \uACBD\uB85C. update=true \uBA74 \uC774\uBBF8 \uC788\uB294 \uAC83\uB3C4 \uB2E4\uC2DC \uBC1B\uB294\uB2E4.",
|
|
248
661
|
inputSchema: {
|
|
249
662
|
type: "object",
|
|
250
663
|
properties: {
|
|
251
|
-
source: {
|
|
664
|
+
source: {
|
|
665
|
+
type: "string",
|
|
666
|
+
description: "owner/repo[/\uD3F4\uB354][@ref], GitHub \uC8FC\uC18C, \uB610\uB294 \uD3F4\uB354 \uACBD\uB85C"
|
|
667
|
+
},
|
|
252
668
|
update: { type: "boolean" }
|
|
253
669
|
},
|
|
254
670
|
required: ["source"]
|
|
@@ -268,15 +684,15 @@ var LocalRunner = class {
|
|
|
268
684
|
const depth = Math.min(num(a.depth, 1), 4);
|
|
269
685
|
const lines = [];
|
|
270
686
|
const walk = (d, lvl) => {
|
|
271
|
-
for (const n of
|
|
687
|
+
for (const n of fs2.readdirSync(d, { withFileTypes: true }).sort((x, y) => x.name.localeCompare(y.name))) {
|
|
272
688
|
if (n.name === "node_modules" || n.name === ".git" || n.name === "__pycache__")
|
|
273
689
|
continue;
|
|
274
|
-
const p =
|
|
275
|
-
const rel =
|
|
690
|
+
const p = path2.join(d, n.name);
|
|
691
|
+
const rel = path2.relative(this.dir, p);
|
|
276
692
|
if (n.isDirectory()) {
|
|
277
693
|
lines.push(`${rel}/`);
|
|
278
694
|
if (lvl < depth) walk(p, lvl + 1);
|
|
279
|
-
} else lines.push(`${rel} ${
|
|
695
|
+
} else lines.push(`${rel} ${fs2.statSync(p).size}B`);
|
|
280
696
|
if (lines.length > 2e3) return;
|
|
281
697
|
}
|
|
282
698
|
};
|
|
@@ -298,7 +714,7 @@ var LocalRunner = class {
|
|
|
298
714
|
annotations: ro,
|
|
299
715
|
run: async (a) => {
|
|
300
716
|
const p = this.inDir(str(a.path));
|
|
301
|
-
const all =
|
|
717
|
+
const all = fs2.readFileSync(p, "utf-8").split("{{SKILL_DIR}}").join(this.skillDirOf(p) ?? "{{SKILL_DIR}}");
|
|
302
718
|
const off = Math.max(0, num(a.offset, 0));
|
|
303
719
|
const part = all.slice(off, off + MAX_READ);
|
|
304
720
|
const more = off + MAX_READ < all.length ? `
|
|
@@ -317,8 +733,8 @@ var LocalRunner = class {
|
|
|
317
733
|
},
|
|
318
734
|
run: async (a) => {
|
|
319
735
|
const p = this.inDir(str(a.path));
|
|
320
|
-
|
|
321
|
-
|
|
736
|
+
fs2.mkdirSync(path2.dirname(p), { recursive: true });
|
|
737
|
+
fs2.writeFileSync(p, str(a.content));
|
|
322
738
|
return text(`\uC37C\uC2B5\uB2C8\uB2E4: ${p} (${Buffer.byteLength(str(a.content))}B)`);
|
|
323
739
|
}
|
|
324
740
|
},
|
|
@@ -361,6 +777,24 @@ var LocalRunner = class {
|
|
|
361
777
|
annotations: ro,
|
|
362
778
|
run: async (a) => this.jobStatus(str(a.id), num(a.wait, 0))
|
|
363
779
|
},
|
|
780
|
+
{
|
|
781
|
+
name: "mcp_reload",
|
|
782
|
+
description: "\uC774 PC \uC758 MCP \uC11C\uBC84 \uC815\uC758(\uC791\uC5C5 \uD3F4\uB354\uC758 connectbase-local.json, mcpServers \uD615\uC2DD \u2014 Claude Desktop/Claude Code \uC640 \uAC19\uB2E4)\uB97C \uB2E4\uC2DC \uC77D\uACE0 \uB744\uC6B4\uB2E4. \uC2A4\uD0AC\uC774 \uC5B4\uB5A4 MCP \uC758 \uB3C4\uAD6C\uB97C \uC4F0\uB77C\uACE0 \uD558\uB294\uB370 \uADF8 \uB3C4\uAD6C\uAC00 \uC5C6\uC73C\uBA74, \uC0AC\uC6A9\uC790 \uD5C8\uB77D\uC744 \uBC1B\uC544 \uADF8 MCP \uC124\uC815\uC744 \uC774 \uD30C\uC77C\uC5D0 write_file \uB85C \uB123\uACE0 \uC774\uAC78 \uBD80\uB978\uB2E4. \uACB0\uACFC\uB85C \uC11C\uBC84\uBCC4 \uC0C1\uD0DC\uC640 \uB3C4\uAD6C \uC218\uB97C \uB3CC\uB824\uC900\uB2E4.",
|
|
783
|
+
inputSchema: { type: "object", properties: {} },
|
|
784
|
+
run: async () => {
|
|
785
|
+
await this.hub.reload();
|
|
786
|
+
return text(
|
|
787
|
+
JSON.stringify(
|
|
788
|
+
{
|
|
789
|
+
config: path2.join(this.dir, LOCAL_CONFIG_FILE),
|
|
790
|
+
servers: this.hub.status()
|
|
791
|
+
},
|
|
792
|
+
null,
|
|
793
|
+
2
|
|
794
|
+
)
|
|
795
|
+
);
|
|
796
|
+
}
|
|
797
|
+
},
|
|
364
798
|
{
|
|
365
799
|
name: "job_stop",
|
|
366
800
|
description: "background \uC791\uC5C5\uC744 \uBA48\uCD98\uB2E4.",
|
|
@@ -393,7 +827,7 @@ var LocalRunner = class {
|
|
|
393
827
|
"\uADF8\uB9BC \uD30C\uC77C(png, jpg, webp, gif)\uB9CC \uBCFC \uC218 \uC788\uC2B5\uB2C8\uB2E4",
|
|
394
828
|
true
|
|
395
829
|
);
|
|
396
|
-
const buf =
|
|
830
|
+
const buf = fs2.readFileSync(p);
|
|
397
831
|
if (buf.length > MAX_IMAGE)
|
|
398
832
|
return text(
|
|
399
833
|
`\uADF8\uB9BC\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4 (${buf.length}B). \uB354 \uC791\uAC8C \uB80C\uB354\uD574 \uC8FC\uC138\uC694`,
|
|
@@ -423,8 +857,8 @@ var LocalRunner = class {
|
|
|
423
857
|
const r = await fetch(url, { redirect: "follow" });
|
|
424
858
|
if (!r.ok) return text(`\uBC1B\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4: HTTP ${r.status}`, true);
|
|
425
859
|
const buf = Buffer.from(await r.arrayBuffer());
|
|
426
|
-
|
|
427
|
-
|
|
860
|
+
fs2.mkdirSync(path2.dirname(p), { recursive: true });
|
|
861
|
+
fs2.writeFileSync(p, buf);
|
|
428
862
|
return text(`\uBC1B\uC558\uC2B5\uB2C8\uB2E4: ${p} (${buf.length}B)`);
|
|
429
863
|
}
|
|
430
864
|
},
|
|
@@ -505,7 +939,7 @@ var LocalRunner = class {
|
|
|
505
939
|
},
|
|
506
940
|
annotations: ro,
|
|
507
941
|
run: async (a) => {
|
|
508
|
-
const tmp =
|
|
942
|
+
const tmp = path2.join(
|
|
509
943
|
os.tmpdir(),
|
|
510
944
|
`cb_blender_shot_${process.pid}_${Date.now()}.png`
|
|
511
945
|
);
|
|
@@ -515,75 +949,213 @@ var LocalRunner = class {
|
|
|
515
949
|
format: "png"
|
|
516
950
|
});
|
|
517
951
|
if (r.isError) return r;
|
|
518
|
-
if (!
|
|
952
|
+
if (!fs2.existsSync(tmp))
|
|
519
953
|
return text("Blender \uAC00 \uD654\uBA74\uC744 \uC800\uC7A5\uD558\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4", true);
|
|
520
|
-
const data =
|
|
521
|
-
|
|
954
|
+
const data = fs2.readFileSync(tmp).toString("base64");
|
|
955
|
+
fs2.rmSync(tmp, { force: true });
|
|
522
956
|
return { content: [{ type: "image", data, mimeType: "image/png" }] };
|
|
523
957
|
}
|
|
524
958
|
}
|
|
525
959
|
];
|
|
526
960
|
}
|
|
527
961
|
skillDirOf(p) {
|
|
528
|
-
const rel =
|
|
529
|
-
if (rel.startsWith("..") ||
|
|
530
|
-
return
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
962
|
+
const rel = path2.relative(this.skillsDir, p);
|
|
963
|
+
if (rel.startsWith("..") || path2.isAbsolute(rel)) return null;
|
|
964
|
+
return path2.join(this.skillsDir, rel.split(path2.sep)[0]);
|
|
965
|
+
}
|
|
966
|
+
/** 설치된 스킬 (skills/<이름>/SKILL.md 의 머리말 name, description). */
|
|
967
|
+
listSkills() {
|
|
968
|
+
if (!fs2.existsSync(this.skillsDir)) return [];
|
|
969
|
+
const out = [];
|
|
970
|
+
for (const d of fs2.readdirSync(this.skillsDir, { withFileTypes: true })) {
|
|
971
|
+
if (!d.isDirectory()) continue;
|
|
972
|
+
const dir = path2.join(this.skillsDir, d.name);
|
|
973
|
+
const md = path2.join(dir, "SKILL.md");
|
|
974
|
+
if (!fs2.existsSync(md)) continue;
|
|
975
|
+
const head = /^---\r?\n([\s\S]*?)\r?\n---/.exec(
|
|
976
|
+
fs2.readFileSync(md, "utf-8")
|
|
977
|
+
);
|
|
978
|
+
const field = (k) => {
|
|
979
|
+
if (!head) return "";
|
|
980
|
+
const lines = head[1].split(/\r?\n/);
|
|
981
|
+
const at = lines.findIndex((l) => l.startsWith(`${k}:`));
|
|
982
|
+
if (at < 0) return "";
|
|
983
|
+
let v = lines[at].slice(k.length + 1).trim();
|
|
984
|
+
if (/^[>|][-+]?$/.test(v) || v === "") {
|
|
985
|
+
const more = [];
|
|
986
|
+
for (const l of lines.slice(at + 1)) {
|
|
987
|
+
if (/^\s+\S/.test(l)) more.push(l.trim());
|
|
988
|
+
else break;
|
|
989
|
+
}
|
|
990
|
+
v = more.join(" ");
|
|
991
|
+
}
|
|
992
|
+
return v.replace(/^["']|["']$/g, "");
|
|
993
|
+
};
|
|
994
|
+
out.push({ name: d.name, description: field("description"), dir });
|
|
995
|
+
}
|
|
996
|
+
return out.sort((a, b) => a.name.localeCompare(b.name));
|
|
997
|
+
}
|
|
998
|
+
/** read_skill 도구 설명: 설치된 스킬 목록이 곧 AI 가 보는 "스킬 표지" 다. */
|
|
999
|
+
skillIndexText() {
|
|
1000
|
+
const skills = this.listSkills();
|
|
1001
|
+
if (!skills.length)
|
|
1002
|
+
return "\uC774 \uCEF4\uD4E8\uD130\uC5D0 \uC124\uCE58\uB41C \uC2A4\uD0AC\uC774 \uC544\uC9C1 \uC5C6\uC2B5\uB2C8\uB2E4. \uC0AC\uC6A9\uC790\uAC00 `npx connectbase-client local --add <GitHub \uC8FC\uC18C>` \uB85C \uC124\uCE58\uD558\uAC70\uB098, \uC0AC\uC6A9\uC790\uAC00 \uC6D0\uD558\uBA74 skill_install \uB85C \uBC1B\uB294\uB2E4.";
|
|
1003
|
+
let t = "\uC774 \uCEF4\uD4E8\uD130\uC5D0 \uC124\uCE58\uB41C \uC2A4\uD0AC (\uC77C\uC774 \uB9DE\uC73C\uBA74 read_skill \uB85C \uBCF8\uBB38\uC744 \uC77D\uACE0 \uADF8\uB300\uB85C \uB530\uB978\uB2E4):\n";
|
|
1004
|
+
for (const k of skills) {
|
|
1005
|
+
const line = `- ${k.name}: ${k.description.slice(0, 220)}
|
|
1006
|
+
`;
|
|
1007
|
+
if (t.length + line.length > 7e3) {
|
|
1008
|
+
t += `- \u2026 \uC678 ${skills.length - t.split("\n- ").length + 1}\uAC1C (list_files skills \uB85C \uBCF8\uB2E4)
|
|
1009
|
+
`;
|
|
1010
|
+
break;
|
|
1011
|
+
}
|
|
1012
|
+
t += line;
|
|
1013
|
+
}
|
|
1014
|
+
return t;
|
|
1015
|
+
}
|
|
1016
|
+
/**
|
|
1017
|
+
* 스킬 설치. source:
|
|
1018
|
+
* - GitHub: owner/repo[/폴더][@ref] 또는 https://github.com/owner/repo[/tree/ref/폴더]
|
|
1019
|
+
* 폴더에 SKILL.md 가 있으면 그 스킬 하나, 없으면 그 아래 SKILL.md 가 있는 폴더를 모두 받는다 (저장소 통째로).
|
|
1020
|
+
* - 이 컴퓨터의 폴더 경로 (./my-skill, ~/skills/x): 그대로 복사한다.
|
|
1021
|
+
*/
|
|
1022
|
+
async installSkills(source, update2 = false) {
|
|
1023
|
+
const src0 = source.trim();
|
|
1024
|
+
const localPath = path2.resolve(src0.replace(/^~(?=$|[\\/])/, os.homedir()));
|
|
1025
|
+
if (/^[.~/\\]|^[A-Za-z]:[\\/]/.test(src0) && fs2.existsSync(localPath)) {
|
|
1026
|
+
return this.copySkills(localPath, `${localPath}`, update2);
|
|
1027
|
+
}
|
|
1028
|
+
let s = src0.replace(/^https:\/\/github\.com\//, "").replace(/\.git$/, "");
|
|
1029
|
+
let ref = "HEAD";
|
|
1030
|
+
const tree = /^([^/]+\/[^/]+)\/(?:tree|blob)\/([^/]+)\/?(.*)$/.exec(s);
|
|
1031
|
+
if (tree) {
|
|
1032
|
+
ref = tree[2];
|
|
1033
|
+
s = `${tree[1]}/${tree[3]}`.replace(/\/SKILL\.md$/i, "").replace(/\/+$/, "");
|
|
1034
|
+
}
|
|
1035
|
+
const at = s.lastIndexOf("@");
|
|
1036
|
+
if (at > 0) {
|
|
1037
|
+
ref = s.slice(at + 1);
|
|
1038
|
+
s = s.slice(0, at);
|
|
1039
|
+
}
|
|
1040
|
+
const m = /^([\w.-]+)\/([\w.-]+)(?:\/(.+))?$/.exec(s);
|
|
536
1041
|
if (!m)
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
const
|
|
541
|
-
if (fs.existsSync(path.join(dest, "SKILL.md")) && !update2)
|
|
542
|
-
return text(this.describeSkill(dest, "\uC774\uBBF8 \uC788\uC2B5\uB2C8\uB2E4"));
|
|
1042
|
+
throw new Error(
|
|
1043
|
+
"GitHub \uC8FC\uC18C(owner/repo[/\uD3F4\uB354][@ref]) \uB098 \uC774 \uCEF4\uD4E8\uD130\uC758 \uD3F4\uB354 \uACBD\uB85C\uB97C \uC8FC\uC138\uC694"
|
|
1044
|
+
);
|
|
1045
|
+
const [, owner, repo, sub = ""] = m;
|
|
543
1046
|
const tarBin = this.programs.tar ?? findPrograms().tar;
|
|
544
1047
|
if (!tarBin)
|
|
545
|
-
|
|
546
|
-
"tar \uBA85\uB839\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4 (Windows 10 \uC774\uC0C1, macOS, Linux \uC5D0\uB294 \uAE30\uBCF8\uC73C\uB85C \uC788\uC2B5\uB2C8\uB2E4)"
|
|
547
|
-
true
|
|
1048
|
+
throw new Error(
|
|
1049
|
+
"tar \uBA85\uB839\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4 (Windows 10 \uC774\uC0C1, macOS, Linux \uC5D0\uB294 \uAE30\uBCF8\uC73C\uB85C \uC788\uC2B5\uB2C8\uB2E4)"
|
|
548
1050
|
);
|
|
549
1051
|
const r = await fetch(
|
|
550
1052
|
`https://codeload.github.com/${owner}/${repo}/tar.gz/${ref}`
|
|
551
1053
|
);
|
|
552
1054
|
if (!r.ok)
|
|
553
|
-
|
|
554
|
-
`GitHub \uC5D0\uC11C \uBC1B\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4: HTTP ${r.status} (${owner}/${repo}@${ref})
|
|
555
|
-
true
|
|
1055
|
+
throw new Error(
|
|
1056
|
+
`GitHub \uC5D0\uC11C \uBC1B\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4: HTTP ${r.status} (${owner}/${repo}@${ref})`
|
|
556
1057
|
);
|
|
557
|
-
const tmp =
|
|
1058
|
+
const tmp = fs2.mkdtempSync(path2.join(os.tmpdir(), "cb_skill_"));
|
|
558
1059
|
try {
|
|
559
|
-
|
|
560
|
-
|
|
1060
|
+
fs2.writeFileSync(
|
|
1061
|
+
path2.join(tmp, "src.tgz"),
|
|
1062
|
+
Buffer.from(await r.arrayBuffer())
|
|
1063
|
+
);
|
|
561
1064
|
const x = await this.exec(`"${tarBin}" -xzf src.tgz`, tmp, 120);
|
|
562
|
-
if (x.code !== 0)
|
|
563
|
-
const top =
|
|
564
|
-
const
|
|
565
|
-
if (!
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
`${owner}/${repo}/${sub}@${ref}
|
|
572
|
-
`
|
|
1065
|
+
if (x.code !== 0) throw new Error(`\uC555\uCD95\uC744 \uD480\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4: ${x.out}`);
|
|
1066
|
+
const top = fs2.readdirSync(tmp).find((n) => n !== "src.tgz");
|
|
1067
|
+
const root = top ? path2.join(tmp, top, ...sub.split("/").filter(Boolean)) : "";
|
|
1068
|
+
if (!root || !fs2.existsSync(root))
|
|
1069
|
+
throw new Error(`\uADF8 \uACBD\uB85C\uAC00 \uC800\uC7A5\uC18C\uC5D0 \uC5C6\uC2B5\uB2C8\uB2E4: ${sub || "(\uB9E8 \uC704)"}`);
|
|
1070
|
+
return this.copySkills(
|
|
1071
|
+
root,
|
|
1072
|
+
`${owner}/${repo}${sub ? `/${sub}` : ""}@${ref}`,
|
|
1073
|
+
update2
|
|
573
1074
|
);
|
|
574
1075
|
} finally {
|
|
575
|
-
|
|
1076
|
+
fs2.rmSync(tmp, { recursive: true, force: true });
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
copySkills(root, origin, update2) {
|
|
1080
|
+
const found = [];
|
|
1081
|
+
const walk = (d, depth) => {
|
|
1082
|
+
if (fs2.existsSync(path2.join(d, "SKILL.md"))) {
|
|
1083
|
+
found.push(d);
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
if (depth >= 4) return;
|
|
1087
|
+
for (const n of fs2.readdirSync(d, { withFileTypes: true }))
|
|
1088
|
+
if (n.isDirectory() && !n.name.startsWith(".") && n.name !== "node_modules")
|
|
1089
|
+
walk(path2.join(d, n.name), depth + 1);
|
|
1090
|
+
};
|
|
1091
|
+
walk(root, 0);
|
|
1092
|
+
if (!found.length)
|
|
1093
|
+
throw new Error("SKILL.md \uAC00 \uC788\uB294 \uD3F4\uB354\uB97C \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4");
|
|
1094
|
+
const installed = [];
|
|
1095
|
+
const skipped = [];
|
|
1096
|
+
for (const dir of found) {
|
|
1097
|
+
const name = path2.basename(dir);
|
|
1098
|
+
const dest = path2.join(this.skillsDir, name);
|
|
1099
|
+
if (fs2.existsSync(path2.join(dest, "SKILL.md")) && !update2) {
|
|
1100
|
+
skipped.push(name);
|
|
1101
|
+
continue;
|
|
1102
|
+
}
|
|
1103
|
+
fs2.rmSync(dest, { recursive: true, force: true });
|
|
1104
|
+
fs2.cpSync(dir, dest, { recursive: true });
|
|
1105
|
+
const rel = path2.relative(root, dir).split(path2.sep).join("/");
|
|
1106
|
+
fs2.writeFileSync(
|
|
1107
|
+
path2.join(dest, ".source"),
|
|
1108
|
+
`${origin}${rel ? ` (${rel})` : ""}
|
|
1109
|
+
`
|
|
1110
|
+
);
|
|
1111
|
+
installed.push(name);
|
|
1112
|
+
}
|
|
1113
|
+
if (installed.length)
|
|
1114
|
+
this.log(`\uC2A4\uD0AC \uC124\uCE58: ${installed.join(", ")} \u2190 ${origin}`);
|
|
1115
|
+
if (installed.length) this.opts.onSkillsChanged?.();
|
|
1116
|
+
return { installed, skipped };
|
|
1117
|
+
}
|
|
1118
|
+
/** 설치된 스킬을 원래 주소에서 다시 받는다. */
|
|
1119
|
+
async updateSkills() {
|
|
1120
|
+
const sources = /* @__PURE__ */ new Set();
|
|
1121
|
+
for (const k of this.listSkills()) {
|
|
1122
|
+
const f = path2.join(k.dir, ".source");
|
|
1123
|
+
if (!fs2.existsSync(f)) continue;
|
|
1124
|
+
const line = fs2.readFileSync(f, "utf-8").trim();
|
|
1125
|
+
const origin = line.replace(/ \(.*\)$/, "");
|
|
1126
|
+
const rel = /\((.*)\)$/.exec(line)?.[1];
|
|
1127
|
+
const [base, ref] = origin.split("@");
|
|
1128
|
+
if (ref && /^[0-9a-f]{40}$/.test(ref)) continue;
|
|
1129
|
+
sources.add(
|
|
1130
|
+
rel && !path2.isAbsolute(base) ? `${base}/${rel}@${ref ?? "HEAD"}` : origin
|
|
1131
|
+
);
|
|
1132
|
+
}
|
|
1133
|
+
const done = [];
|
|
1134
|
+
for (const s of sources)
|
|
1135
|
+
done.push(...(await this.installSkills(s, true)).installed);
|
|
1136
|
+
return done;
|
|
1137
|
+
}
|
|
1138
|
+
async skillInstall(source, update2) {
|
|
1139
|
+
try {
|
|
1140
|
+
const r = await this.installSkills(source, update2);
|
|
1141
|
+
const names = [...r.installed, ...r.skipped];
|
|
1142
|
+
const dirs = names.map((n) => path2.join(this.skillsDir, n));
|
|
1143
|
+
return text(
|
|
1144
|
+
`${r.installed.length ? `\uC124\uCE58: ${r.installed.join(", ")}` : ""}${r.skipped.length ? `${r.installed.length ? "\n" : ""}\uC774\uBBF8 \uC788\uC74C(update=true \uBA74 \uB2E4\uC2DC \uBC1B\uC74C): ${r.skipped.join(", ")}` : ""}
|
|
1145
|
+
|
|
1146
|
+
` + (dirs.length === 1 ? this.describeSkill(dirs[0], "\uC900\uBE44\uB428") : "read_skill(name) \uC73C\uB85C \uBCF8\uBB38\uC744 \uC77D\uB294\uB2E4.")
|
|
1147
|
+
);
|
|
1148
|
+
} catch (e) {
|
|
1149
|
+
return text(e instanceof Error ? e.message : String(e), true);
|
|
576
1150
|
}
|
|
577
|
-
this.log(`\uC2A4\uD0AC \uBC1B\uC74C: ${name} \u2190 ${source}`);
|
|
578
|
-
return text(this.describeSkill(dest, "\uBC1B\uC558\uC2B5\uB2C8\uB2E4"));
|
|
579
1151
|
}
|
|
580
1152
|
describeSkill(dest, head) {
|
|
581
1153
|
const files = [];
|
|
582
1154
|
const walk = (d) => {
|
|
583
|
-
for (const n of
|
|
584
|
-
const p =
|
|
1155
|
+
for (const n of fs2.readdirSync(d, { withFileTypes: true })) {
|
|
1156
|
+
const p = path2.join(d, n.name);
|
|
585
1157
|
if (n.isDirectory()) walk(p);
|
|
586
|
-
else files.push(
|
|
1158
|
+
else files.push(path2.relative(dest, p));
|
|
587
1159
|
}
|
|
588
1160
|
};
|
|
589
1161
|
walk(dest);
|
|
@@ -591,7 +1163,7 @@ var LocalRunner = class {
|
|
|
591
1163
|
"requirements.txt",
|
|
592
1164
|
"tools/package.json",
|
|
593
1165
|
"package.json"
|
|
594
|
-
].filter((f) =>
|
|
1166
|
+
].filter((f) => fs2.existsSync(path2.join(dest, f)));
|
|
595
1167
|
return JSON.stringify(
|
|
596
1168
|
{
|
|
597
1169
|
result: head,
|
|
@@ -605,8 +1177,8 @@ var LocalRunner = class {
|
|
|
605
1177
|
);
|
|
606
1178
|
}
|
|
607
1179
|
exec(command, cwd, timeoutSec) {
|
|
608
|
-
return new Promise((
|
|
609
|
-
const child = (0,
|
|
1180
|
+
return new Promise((resolve5) => {
|
|
1181
|
+
const child = (0, import_node_child_process2.spawn)(command, {
|
|
610
1182
|
cwd,
|
|
611
1183
|
shell: true,
|
|
612
1184
|
env: this.env(),
|
|
@@ -626,24 +1198,24 @@ var LocalRunner = class {
|
|
|
626
1198
|
}, timeoutSec * 1e3);
|
|
627
1199
|
child.on("close", (code) => {
|
|
628
1200
|
clearTimeout(t);
|
|
629
|
-
|
|
1201
|
+
resolve5({ code, out, timedOut });
|
|
630
1202
|
});
|
|
631
1203
|
child.on("error", (e) => {
|
|
632
1204
|
clearTimeout(t);
|
|
633
|
-
|
|
1205
|
+
resolve5({ code: -1, out: out + String(e), timedOut });
|
|
634
1206
|
});
|
|
635
1207
|
});
|
|
636
1208
|
}
|
|
637
1209
|
async run(command, cwd, timeout, background) {
|
|
638
1210
|
if (!command.trim()) return text("command \uAC00 \uBE44\uC5C8\uC2B5\uB2C8\uB2E4", true);
|
|
639
1211
|
const dir = this.inDir(cwd || ".");
|
|
640
|
-
|
|
1212
|
+
fs2.mkdirSync(dir, { recursive: true });
|
|
641
1213
|
this.log(
|
|
642
|
-
`\uC2E4\uD589${background ? " (\uBC31\uADF8\uB77C\uC6B4\uB4DC)" : ""}: ${command} [${
|
|
1214
|
+
`\uC2E4\uD589${background ? " (\uBC31\uADF8\uB77C\uC6B4\uB4DC)" : ""}: ${command} [${path2.relative(this.dir, dir) || "."}]`
|
|
643
1215
|
);
|
|
644
1216
|
if (background) {
|
|
645
1217
|
const id = `job${++this.jobSeq}`;
|
|
646
|
-
const child = (0,
|
|
1218
|
+
const child = (0, import_node_child_process2.spawn)(command, {
|
|
647
1219
|
cwd: dir,
|
|
648
1220
|
shell: true,
|
|
649
1221
|
env: this.env(),
|
|
@@ -713,7 +1285,7 @@ ${tail(j.out)}`,
|
|
|
713
1285
|
return this.opts.blenderMcpPort ?? (Number(process.env.BLENDER_MCP_PORT) || 9876);
|
|
714
1286
|
}
|
|
715
1287
|
blenderSend(type, params, timeoutMs = 18e4) {
|
|
716
|
-
return new Promise((
|
|
1288
|
+
return new Promise((resolve5, reject) => {
|
|
717
1289
|
const sock = net.createConnection({
|
|
718
1290
|
host: "127.0.0.1",
|
|
719
1291
|
port: this.blenderPort
|
|
@@ -734,7 +1306,7 @@ ${tail(j.out)}`,
|
|
|
734
1306
|
const obj = JSON.parse(buf.toString("utf-8"));
|
|
735
1307
|
clearTimeout(timer);
|
|
736
1308
|
sock.end();
|
|
737
|
-
|
|
1309
|
+
resolve5(obj);
|
|
738
1310
|
} catch {
|
|
739
1311
|
}
|
|
740
1312
|
});
|
|
@@ -769,12 +1341,12 @@ Blender \uC5D0 BlenderMCP \uC560\uB4DC\uC628(github.com/ahujasid/blender-mcp \uC
|
|
|
769
1341
|
}
|
|
770
1342
|
async uploadToStorage(p, folder) {
|
|
771
1343
|
const abs = this.inDir(p);
|
|
772
|
-
if (!
|
|
1344
|
+
if (!fs2.existsSync(abs)) return text(`\uD30C\uC77C\uC774 \uC5C6\uC2B5\uB2C8\uB2E4: ${p}`, true);
|
|
773
1345
|
try {
|
|
774
1346
|
const url = await uploadFile(this.opts, abs, folder);
|
|
775
|
-
this.log(`\uC62C\uB9BC: ${
|
|
1347
|
+
this.log(`\uC62C\uB9BC: ${path2.basename(abs)} \u2192 ${url}`);
|
|
776
1348
|
return text(
|
|
777
|
-
JSON.stringify({ uploaded:
|
|
1349
|
+
JSON.stringify({ uploaded: path2.basename(abs), url }, null, 2)
|
|
778
1350
|
);
|
|
779
1351
|
} catch (e) {
|
|
780
1352
|
return text(e instanceof Error ? e.message : String(e), true);
|
|
@@ -789,7 +1361,7 @@ Blender \uC5D0 BlenderMCP \uC560\uB4DC\uC628(github.com/ahujasid/blender-mcp \uC
|
|
|
789
1361
|
parts.push({
|
|
790
1362
|
type: "image_url",
|
|
791
1363
|
image_url: {
|
|
792
|
-
url: `data:${mime};base64,${
|
|
1364
|
+
url: `data:${mime};base64,${fs2.readFileSync(abs).toString("base64")}`
|
|
793
1365
|
}
|
|
794
1366
|
});
|
|
795
1367
|
}
|
|
@@ -828,8 +1400,8 @@ Blender \uC5D0 BlenderMCP \uC560\uB4DC\uC628(github.com/ahujasid/blender-mcp \uC
|
|
|
828
1400
|
);
|
|
829
1401
|
const src = str(images[0].url);
|
|
830
1402
|
const buf = src.startsWith("data:") ? Buffer.from(src.split(",", 2)[1], "base64") : Buffer.from(await (await fetch(src)).arrayBuffer());
|
|
831
|
-
|
|
832
|
-
|
|
1403
|
+
fs2.mkdirSync(path2.dirname(out), { recursive: true });
|
|
1404
|
+
fs2.writeFileSync(out, buf);
|
|
833
1405
|
return text(
|
|
834
1406
|
`\uC800\uC7A5\uD588\uC2B5\uB2C8\uB2E4: ${out} (${buf.length}B). view_image \uB85C \uD655\uC778\uD558\uC138\uC694.`
|
|
835
1407
|
);
|
|
@@ -855,24 +1427,33 @@ Blender \uC5D0 BlenderMCP \uC560\uB4DC\uC628(github.com/ahujasid/blender-mcp \uC
|
|
|
855
1427
|
protocolVersion: PROTOCOL_VERSIONS.includes(want) ? want : PROTOCOL_VERSIONS[0],
|
|
856
1428
|
capabilities: { tools: { listChanged: false } },
|
|
857
1429
|
serverInfo: { name: "connectbase-local", version: "1.0.0" },
|
|
858
|
-
instructions: "\uC0AC\uC6A9\uC790 \uCEF4\uD4E8\uD130\uC758 \uB85C\uCEEC \uC2E4\uD589\uAE30. \
|
|
1430
|
+
instructions: "\uC0AC\uC6A9\uC790 \uCEF4\uD4E8\uD130\uC758 \uB85C\uCEEC \uC2E4\uD589\uAE30. \uC774 \uCEF4\uD4E8\uD130\uC5D0 \uC124\uCE58\uB41C \uC2A4\uD0AC(read_skill \uC124\uBA85\uC758 \uBAA9\uB85D)\uC744 \uC77D\uACE0, \uADF8 \uC2A4\uD0AC\uC774 \uC694\uAD6C\uD558\uB294 \uC2A4\uD06C\uB9BD\uD2B8 \uC2E4\uD589, \uC774 PC \uC5D0 \uC815\uC758\uB41C MCP \uC11C\uBC84\uC758 \uB3C4\uAD6C(\uC124\uBA85\uC774 [\uB0B4 PC MCP: \uC774\uB984] \uC73C\uB85C \uC2DC\uC791), \uADF8\uB9BC \uBCF4\uAE30\uB97C \uC5EC\uAE30\uC11C \uD55C\uB2E4. \uD504\uB85C\uADF8\uB7A8\uACFC MCP \uC0C1\uD0DC \uD655\uC778\uC740 local_info."
|
|
859
1431
|
});
|
|
860
1432
|
}
|
|
861
1433
|
case "ping":
|
|
862
1434
|
return ok({});
|
|
863
1435
|
case "tools/list":
|
|
864
|
-
return ok({
|
|
865
|
-
tools: this.tools.map(
|
|
866
|
-
({ name, description, inputSchema, annotations }) => ({
|
|
867
|
-
name,
|
|
868
|
-
description,
|
|
869
|
-
inputSchema,
|
|
870
|
-
...annotations ? { annotations } : {}
|
|
871
|
-
})
|
|
872
|
-
)
|
|
873
|
-
});
|
|
1436
|
+
return ok({ tools: this.visibleTools() });
|
|
874
1437
|
case "tools/call": {
|
|
875
1438
|
const p = msg.params ?? {};
|
|
1439
|
+
if (this.hub.has(str(p.name))) {
|
|
1440
|
+
this.log(`MCP \uB3C4\uAD6C: ${str(p.name)}`);
|
|
1441
|
+
try {
|
|
1442
|
+
const r = await this.hub.call(
|
|
1443
|
+
str(p.name),
|
|
1444
|
+
p.arguments ?? {}
|
|
1445
|
+
);
|
|
1446
|
+
const content = (r.content ?? []).map(
|
|
1447
|
+
(c) => c.type === "text" || c.type === "image" ? c : { type: "text", text: JSON.stringify(c).slice(0, 2e4) }
|
|
1448
|
+
);
|
|
1449
|
+
return ok({
|
|
1450
|
+
content: content.length ? content : [{ type: "text", text: "(\uBE48 \uACB0\uACFC)" }],
|
|
1451
|
+
...r.isError ? { isError: true } : {}
|
|
1452
|
+
});
|
|
1453
|
+
} catch (e) {
|
|
1454
|
+
return ok(text(e instanceof Error ? e.message : String(e), true));
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
876
1457
|
const tool = this.tools.find((t) => t.name === p.name);
|
|
877
1458
|
if (!tool) return fail(-32602, `\uC5C6\uB294 \uB3C4\uAD6C: ${str(p.name)}`);
|
|
878
1459
|
try {
|
|
@@ -923,9 +1504,9 @@ Blender \uC5D0 BlenderMCP \uC560\uB4DC\uC628(github.com/ahujasid/blender-mcp \uC
|
|
|
923
1504
|
"Mcp-Session-Id": "local"
|
|
924
1505
|
}).end(out);
|
|
925
1506
|
});
|
|
926
|
-
return new Promise((
|
|
1507
|
+
return new Promise((resolve5, reject) => {
|
|
927
1508
|
server.once("error", reject);
|
|
928
|
-
server.listen(this.opts.port, "127.0.0.1", () =>
|
|
1509
|
+
server.listen(this.opts.port, "127.0.0.1", () => resolve5(server));
|
|
929
1510
|
});
|
|
930
1511
|
}
|
|
931
1512
|
};
|
|
@@ -933,7 +1514,7 @@ function killTree(pid) {
|
|
|
933
1514
|
if (!pid) return;
|
|
934
1515
|
try {
|
|
935
1516
|
if (process.platform === "win32")
|
|
936
|
-
(0,
|
|
1517
|
+
(0, import_node_child_process2.spawn)("taskkill", ["/pid", String(pid), "/T", "/F"], {
|
|
937
1518
|
windowsHide: true
|
|
938
1519
|
});
|
|
939
1520
|
else process.kill(pid, "SIGTERM");
|
|
@@ -949,18 +1530,18 @@ function setUploader(fn) {
|
|
|
949
1530
|
|
|
950
1531
|
// src/local-command.ts
|
|
951
1532
|
var LOCAL_SERVER_NAME = "\uB0B4 \uCEF4\uD4E8\uD130 (\uB85C\uCEEC \uC2E4\uD589\uAE30)";
|
|
952
|
-
var STATE_PATH =
|
|
1533
|
+
var STATE_PATH = path3.join(os2.homedir(), ".connectbase", "local-runner.json");
|
|
953
1534
|
function loadState() {
|
|
954
1535
|
try {
|
|
955
|
-
const s = JSON.parse(
|
|
1536
|
+
const s = JSON.parse(fs3.readFileSync(STATE_PATH, "utf-8"));
|
|
956
1537
|
return { apps: s.apps ?? {}, token: s.token };
|
|
957
1538
|
} catch {
|
|
958
1539
|
return { apps: {} };
|
|
959
1540
|
}
|
|
960
1541
|
}
|
|
961
1542
|
function saveState(s) {
|
|
962
|
-
|
|
963
|
-
|
|
1543
|
+
fs3.mkdirSync(path3.dirname(STATE_PATH), { recursive: true });
|
|
1544
|
+
fs3.writeFileSync(STATE_PATH, `${JSON.stringify(s, null, 2)}
|
|
964
1545
|
`, {
|
|
965
1546
|
mode: 384
|
|
966
1547
|
});
|
|
@@ -1129,8 +1710,8 @@ function makeUploader(mcpUrl, getSt, save) {
|
|
|
1129
1710
|
}
|
|
1130
1711
|
save();
|
|
1131
1712
|
}
|
|
1132
|
-
const buf =
|
|
1133
|
-
const name =
|
|
1713
|
+
const buf = fs3.readFileSync(abs);
|
|
1714
|
+
const name = path3.basename(abs);
|
|
1134
1715
|
const mime = {
|
|
1135
1716
|
".glb": "model/gltf-binary",
|
|
1136
1717
|
".gltf": "model/gltf+json",
|
|
@@ -1142,7 +1723,7 @@ function makeUploader(mcpUrl, getSt, save) {
|
|
|
1142
1723
|
".fbx": "application/octet-stream",
|
|
1143
1724
|
".obj": "text/plain",
|
|
1144
1725
|
".json": "application/json"
|
|
1145
|
-
}[
|
|
1726
|
+
}[path3.extname(name).toLowerCase()] ?? "application/octet-stream";
|
|
1146
1727
|
const base = `${o.baseUrl}/v1/public/storages/files/${st.storageId}`;
|
|
1147
1728
|
const presign = () => fetch(
|
|
1148
1729
|
`${base}/presigned-url/path/${encodeURIComponent(folder)}/${encodeURIComponent(name)}`,
|
|
@@ -1190,17 +1771,60 @@ function makeUploader(mcpUrl, getSt, save) {
|
|
|
1190
1771
|
};
|
|
1191
1772
|
}
|
|
1192
1773
|
async function runLocal(config, opts, startTunnel2, out) {
|
|
1193
|
-
const dir =
|
|
1194
|
-
opts.dir ||
|
|
1774
|
+
const dir = path3.resolve(
|
|
1775
|
+
opts.dir || path3.join(os2.homedir(), "ConnectBaseLocal")
|
|
1195
1776
|
);
|
|
1196
1777
|
const port = opts.port || 47800;
|
|
1778
|
+
let syncTools = () => {
|
|
1779
|
+
};
|
|
1197
1780
|
const runner = new LocalRunner({
|
|
1198
1781
|
dir,
|
|
1199
1782
|
port,
|
|
1200
1783
|
baseUrl: config.baseUrl,
|
|
1201
|
-
log: (l) => out.info(l)
|
|
1784
|
+
log: (l) => out.info(l),
|
|
1785
|
+
onSkillsChanged: () => syncTools()
|
|
1202
1786
|
});
|
|
1787
|
+
for (const src of (opts.add ?? "").split(",").map((x) => x.trim()).filter(Boolean)) {
|
|
1788
|
+
try {
|
|
1789
|
+
const r = await runner.installSkills(src, opts.update === true);
|
|
1790
|
+
out.success(
|
|
1791
|
+
`\uC2A4\uD0AC \uC124\uCE58 ${src}: ${r.installed.length ? r.installed.join(", ") : "(\uC0C8\uB85C \uBC1B\uC740 \uAC83 \uC5C6\uC74C)"}${r.skipped.length ? ` / \uC774\uBBF8 \uC788\uC74C: ${r.skipped.join(", ")} (--update \uB85C \uB2E4\uC2DC \uBC1B\uAE30)` : ""}`
|
|
1792
|
+
);
|
|
1793
|
+
} catch (e) {
|
|
1794
|
+
out.warn(`\uC2A4\uD0AC \uC124\uCE58 \uC2E4\uD328 ${src}: ${e instanceof Error ? e.message : e}`);
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1797
|
+
if (opts.update && !opts.add) {
|
|
1798
|
+
try {
|
|
1799
|
+
const done = await runner.updateSkills();
|
|
1800
|
+
out.success(
|
|
1801
|
+
`\uC2A4\uD0AC \uAC31\uC2E0: ${done.length ? done.join(", ") : "(\uAC31\uC2E0\uD560 \uAC83 \uC5C6\uC74C \u2014 \uACE0\uC815 \uCEE4\uBC0B\uC73C\uB85C \uBC1B\uC740 \uC2A4\uD0AC\uC740 \uADF8\uB300\uB85C)"}`
|
|
1802
|
+
);
|
|
1803
|
+
} catch (e) {
|
|
1804
|
+
out.warn(`\uC2A4\uD0AC \uAC31\uC2E0 \uC2E4\uD328: ${e instanceof Error ? e.message : e}`);
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
for (const flag of (opts.mcp ?? "").split("\0").filter(Boolean)) {
|
|
1808
|
+
try {
|
|
1809
|
+
const { name, def } = parseMcpFlag(flag);
|
|
1810
|
+
const cfg = loadLocalConfig(dir);
|
|
1811
|
+
cfg.mcpServers[name] = def;
|
|
1812
|
+
saveLocalConfig(dir, cfg);
|
|
1813
|
+
out.success(`MCP ${name} \uB97C ${LOCAL_CONFIG_FILE} \uC5D0 \uB123\uC5C8\uC2B5\uB2C8\uB2E4`);
|
|
1814
|
+
} catch (e) {
|
|
1815
|
+
out.warn(e instanceof Error ? e.message : String(e));
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
await runner.startMcp();
|
|
1819
|
+
const mcp = runner.hub.status();
|
|
1820
|
+
out.info(
|
|
1821
|
+
mcp.length ? `\uC774 PC \uC758 MCP ${mcp.length}\uAC1C: ${mcp.map((m) => `${m.name}(${m.ok ? `\uB3C4\uAD6C ${m.tools}\uAC1C` : "\uC5F0\uACB0 \uC2E4\uD328"})`).join(", ")}` : `\uC774 PC \uC758 MCP \uC5C6\uC74C (\uC2A4\uD0AC\uC774 MCP \uB97C \uC4F0\uBA74: --mcp \uC774\uB984="\uBA85\uB839" \uB610\uB294 ${path3.join(dir, LOCAL_CONFIG_FILE)} \uC5D0 mcpServers)`
|
|
1822
|
+
);
|
|
1203
1823
|
await runner.listen();
|
|
1824
|
+
const skills = runner.listSkills().map((k) => k.name);
|
|
1825
|
+
out.info(
|
|
1826
|
+
skills.length ? `\uC124\uCE58\uB41C \uC2A4\uD0AC ${skills.length}\uAC1C: ${skills.join(", ")}` : "\uC124\uCE58\uB41C \uC2A4\uD0AC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4. \uC608: npx connectbase-client local --add yorusd1/yoruskills"
|
|
1827
|
+
);
|
|
1204
1828
|
const programs = Object.entries(findPrograms()).map(([k, v]) => v ? k : `${k}(\uC5C6\uC74C)`).join(", ");
|
|
1205
1829
|
out.success(`\uB85C\uCEEC \uC2E4\uD589\uAE30: http://127.0.0.1:${port}/mcp \uC791\uC5C5 \uD3F4\uB354: ${dir}`);
|
|
1206
1830
|
out.info(`\uCC3E\uC740 \uD504\uB85C\uADF8\uB7A8: ${programs}`);
|
|
@@ -1245,6 +1869,23 @@ async function runLocal(config, opts, startTunnel2, out) {
|
|
|
1245
1869
|
current
|
|
1246
1870
|
);
|
|
1247
1871
|
saveState(state);
|
|
1872
|
+
const serverId = current.serverId;
|
|
1873
|
+
let timer;
|
|
1874
|
+
syncTools = () => {
|
|
1875
|
+
clearTimeout(timer);
|
|
1876
|
+
timer = setTimeout(() => {
|
|
1877
|
+
if (serverId)
|
|
1878
|
+
mcpTool(mcpUrl, info2.secretKey, "sync_external_mcp_tools", {
|
|
1879
|
+
app_id: info2.appId,
|
|
1880
|
+
server_id: serverId
|
|
1881
|
+
}).catch(
|
|
1882
|
+
(e) => out.warn(
|
|
1883
|
+
`\uB3C4\uAD6C \uBAA9\uB85D \uAC31\uC2E0 \uC2E4\uD328: ${e instanceof Error ? e.message : e}`
|
|
1884
|
+
)
|
|
1885
|
+
);
|
|
1886
|
+
}, 1500);
|
|
1887
|
+
};
|
|
1888
|
+
syncTools();
|
|
1248
1889
|
out.success(
|
|
1249
1890
|
`\uC571\uC758 \uC678\uBD80 MCP \uC11C\uBC84 "${LOCAL_SERVER_NAME}" ${how}. \uCF58\uC194 > AI \uB3C4\uAD6C > MCP \uC11C\uBC84\uC5D0\uC11C \uBCFC \uC218 \uC788\uC2B5\uB2C8\uB2E4.`
|
|
1250
1891
|
);
|
|
@@ -1264,13 +1905,13 @@ async function runLocal(config, opts, startTunnel2, out) {
|
|
|
1264
1905
|
}
|
|
1265
1906
|
|
|
1266
1907
|
// src/tunnel-utils.ts
|
|
1267
|
-
var
|
|
1908
|
+
var fs4 = __toESM(require("fs"));
|
|
1268
1909
|
var os3 = __toESM(require("os"));
|
|
1269
|
-
var
|
|
1910
|
+
var path4 = __toESM(require("path"));
|
|
1270
1911
|
function getTunnelLockDir() {
|
|
1271
1912
|
const platform2 = os3.platform();
|
|
1272
1913
|
if (platform2 === "darwin") {
|
|
1273
|
-
return
|
|
1914
|
+
return path4.join(
|
|
1274
1915
|
os3.homedir(),
|
|
1275
1916
|
"Library",
|
|
1276
1917
|
"Application Support",
|
|
@@ -1278,14 +1919,14 @@ function getTunnelLockDir() {
|
|
|
1278
1919
|
"tunnel-locks"
|
|
1279
1920
|
);
|
|
1280
1921
|
} else if (platform2 === "win32") {
|
|
1281
|
-
return
|
|
1282
|
-
process.env.LOCALAPPDATA ||
|
|
1922
|
+
return path4.join(
|
|
1923
|
+
process.env.LOCALAPPDATA || path4.join(os3.homedir(), "AppData", "Local"),
|
|
1283
1924
|
"connectbase",
|
|
1284
1925
|
"tunnel-locks"
|
|
1285
1926
|
);
|
|
1286
1927
|
}
|
|
1287
|
-
const stateHome = process.env.XDG_STATE_HOME ||
|
|
1288
|
-
return
|
|
1928
|
+
const stateHome = process.env.XDG_STATE_HOME || path4.join(os3.homedir(), ".local", "state");
|
|
1929
|
+
return path4.join(stateHome, "connectbase", "tunnel-locks");
|
|
1289
1930
|
}
|
|
1290
1931
|
function isProcessAlive(pid) {
|
|
1291
1932
|
try {
|
|
@@ -1297,8 +1938,8 @@ function isProcessAlive(pid) {
|
|
|
1297
1938
|
}
|
|
1298
1939
|
function acquireTunnelLock(appID, port, force, version) {
|
|
1299
1940
|
const lockDir = getTunnelLockDir();
|
|
1300
|
-
|
|
1301
|
-
const lockPath =
|
|
1941
|
+
fs4.mkdirSync(lockDir, { recursive: true });
|
|
1942
|
+
const lockPath = path4.join(lockDir, `${appID}-${port}.lock`);
|
|
1302
1943
|
const lockData = {
|
|
1303
1944
|
pid: process.pid,
|
|
1304
1945
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -1309,9 +1950,9 @@ function acquireTunnelLock(appID, port, force, version) {
|
|
|
1309
1950
|
};
|
|
1310
1951
|
if (!force) {
|
|
1311
1952
|
try {
|
|
1312
|
-
const fd =
|
|
1313
|
-
|
|
1314
|
-
|
|
1953
|
+
const fd = fs4.openSync(lockPath, "wx");
|
|
1954
|
+
fs4.writeSync(fd, JSON.stringify(lockData, null, 2));
|
|
1955
|
+
fs4.closeSync(fd);
|
|
1315
1956
|
return lockPath;
|
|
1316
1957
|
} catch (e) {
|
|
1317
1958
|
if (e.code !== "EEXIST") {
|
|
@@ -1320,7 +1961,7 @@ function acquireTunnelLock(appID, port, force, version) {
|
|
|
1320
1961
|
}
|
|
1321
1962
|
try {
|
|
1322
1963
|
const existing = JSON.parse(
|
|
1323
|
-
|
|
1964
|
+
fs4.readFileSync(lockPath, "utf-8")
|
|
1324
1965
|
);
|
|
1325
1966
|
if (isProcessAlive(existing.pid)) {
|
|
1326
1967
|
return `LOCKED:${existing.pid}:${existing.startedAt}:${existing.host}`;
|
|
@@ -1328,12 +1969,12 @@ function acquireTunnelLock(appID, port, force, version) {
|
|
|
1328
1969
|
} catch {
|
|
1329
1970
|
}
|
|
1330
1971
|
}
|
|
1331
|
-
|
|
1972
|
+
fs4.writeFileSync(lockPath, JSON.stringify(lockData, null, 2));
|
|
1332
1973
|
return lockPath;
|
|
1333
1974
|
}
|
|
1334
1975
|
function releaseTunnelLock(lockPath) {
|
|
1335
1976
|
try {
|
|
1336
|
-
|
|
1977
|
+
fs4.unlinkSync(lockPath);
|
|
1337
1978
|
} catch {
|
|
1338
1979
|
}
|
|
1339
1980
|
}
|
|
@@ -1364,7 +2005,7 @@ function handleTunnelError(msg, appId, localPort) {
|
|
|
1364
2005
|
}
|
|
1365
2006
|
|
|
1366
2007
|
// src/cli.ts
|
|
1367
|
-
var VERSION = "6.
|
|
2008
|
+
var VERSION = "6.24.0" ? "6.24.0" : getPackageVersion();
|
|
1368
2009
|
var DEFAULT_BASE_URL = "https://api.connectbase.world";
|
|
1369
2010
|
var colors = {
|
|
1370
2011
|
reset: "\x1B[0m",
|
|
@@ -1503,23 +2144,23 @@ var MIME_BY_EXT = {
|
|
|
1503
2144
|
".safetensors": "application/octet-stream"
|
|
1504
2145
|
};
|
|
1505
2146
|
function guessMimeType(filePath) {
|
|
1506
|
-
if (ALLOWED_EXTENSIONLESS_FILES.has(
|
|
2147
|
+
if (ALLOWED_EXTENSIONLESS_FILES.has(path5.basename(filePath))) {
|
|
1507
2148
|
return "text/plain; charset=utf-8";
|
|
1508
2149
|
}
|
|
1509
|
-
return MIME_BY_EXT[
|
|
2150
|
+
return MIME_BY_EXT[path5.extname(filePath).toLowerCase()] || "application/octet-stream";
|
|
1510
2151
|
}
|
|
1511
2152
|
function isAllowedDeployExt(filePath) {
|
|
1512
|
-
if (ALLOWED_EXTENSIONLESS_FILES.has(
|
|
2153
|
+
if (ALLOWED_EXTENSIONLESS_FILES.has(path5.basename(filePath))) {
|
|
1513
2154
|
return true;
|
|
1514
2155
|
}
|
|
1515
|
-
return ALLOWED_EXTENSIONS.has(
|
|
2156
|
+
return ALLOWED_EXTENSIONS.has(path5.extname(filePath).toLowerCase());
|
|
1516
2157
|
}
|
|
1517
2158
|
function isBinaryDeployExt(filePath) {
|
|
1518
|
-
return BINARY_EXTENSIONS.has(
|
|
2159
|
+
return BINARY_EXTENSIONS.has(path5.extname(filePath).toLowerCase());
|
|
1519
2160
|
}
|
|
1520
2161
|
function isExtensionlessDataFile(filePath) {
|
|
1521
|
-
const base =
|
|
1522
|
-
return
|
|
2162
|
+
const base = path5.basename(filePath);
|
|
2163
|
+
return path5.extname(base) === "" && !ALLOWED_EXTENSIONLESS_FILES.has(base);
|
|
1523
2164
|
}
|
|
1524
2165
|
var WEB_FILE_MAX_STORED_BYTES = 6 * 1024 * 1024 - 64 * 1024;
|
|
1525
2166
|
var DEPLOY_REQUEST_BUDGET_BYTES = 96 * 1024 * 1024;
|
|
@@ -1600,10 +2241,10 @@ function loadConfig() {
|
|
|
1600
2241
|
baseUrl: envBaseUrl || DEFAULT_BASE_URL,
|
|
1601
2242
|
baseUrlFromRepo: false
|
|
1602
2243
|
};
|
|
1603
|
-
const rcPath =
|
|
1604
|
-
if (
|
|
2244
|
+
const rcPath = path5.join(process.cwd(), ".connectbaserc");
|
|
2245
|
+
if (fs5.existsSync(rcPath)) {
|
|
1605
2246
|
try {
|
|
1606
|
-
const rcContent = JSON.parse(
|
|
2247
|
+
const rcContent = JSON.parse(fs5.readFileSync(rcPath, "utf-8"));
|
|
1607
2248
|
if (rcContent.publicKey) config.publicKey = rcContent.publicKey;
|
|
1608
2249
|
if (rcContent.secretKey) config.secretKey = rcContent.secretKey;
|
|
1609
2250
|
if (rcContent.storageId) config.storageId = rcContent.storageId;
|
|
@@ -1628,16 +2269,16 @@ function collectDeployFiles(dir, options = {}) {
|
|
|
1628
2269
|
}
|
|
1629
2270
|
function collectFiles(dir, baseDir, skipped, options) {
|
|
1630
2271
|
const files = [];
|
|
1631
|
-
const entries =
|
|
2272
|
+
const entries = fs5.readdirSync(dir, { withFileTypes: true });
|
|
1632
2273
|
for (const entry of entries) {
|
|
1633
|
-
const fullPath =
|
|
1634
|
-
const relativePath =
|
|
2274
|
+
const fullPath = path5.join(dir, entry.name);
|
|
2275
|
+
const relativePath = path5.relative(baseDir, fullPath);
|
|
1635
2276
|
if (entry.isDirectory()) {
|
|
1636
2277
|
if (!entry.name.startsWith(".")) {
|
|
1637
2278
|
files.push(...collectFiles(fullPath, baseDir, skipped, options));
|
|
1638
2279
|
}
|
|
1639
2280
|
} else if (entry.isFile()) {
|
|
1640
|
-
const ext =
|
|
2281
|
+
const ext = path5.extname(entry.name).toLowerCase();
|
|
1641
2282
|
if (entry.name.startsWith(".")) {
|
|
1642
2283
|
continue;
|
|
1643
2284
|
}
|
|
@@ -1649,9 +2290,9 @@ function collectFiles(dir, baseDir, skipped, options) {
|
|
|
1649
2290
|
const isBinary = extensionlessData || BINARY_EXTENSIONS.has(ext);
|
|
1650
2291
|
let content;
|
|
1651
2292
|
if (isBinary) {
|
|
1652
|
-
content =
|
|
2293
|
+
content = fs5.readFileSync(fullPath).toString("base64");
|
|
1653
2294
|
} else {
|
|
1654
|
-
content =
|
|
2295
|
+
content = fs5.readFileSync(fullPath, "utf-8");
|
|
1655
2296
|
}
|
|
1656
2297
|
const normalized = normalizeRelativePath(relativePath);
|
|
1657
2298
|
files.push({
|
|
@@ -1677,7 +2318,7 @@ function formatSkippedFilesReport(skipped, limit = SKIPPED_FILES_LIST_LIMIT) {
|
|
|
1677
2318
|
}
|
|
1678
2319
|
const byExt = /* @__PURE__ */ new Map();
|
|
1679
2320
|
for (const p of skipped) {
|
|
1680
|
-
const ext =
|
|
2321
|
+
const ext = path5.extname(p).toLowerCase() || "(\uD655\uC7A5\uC790 \uC5C6\uC74C)";
|
|
1681
2322
|
byExt.set(ext, (byExt.get(ext) ?? 0) + 1);
|
|
1682
2323
|
}
|
|
1683
2324
|
const extSummary = [...byExt.entries()].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).map(([ext, n]) => `${ext} ${n}\uAC1C`).join(", ");
|
|
@@ -1757,7 +2398,7 @@ async function requestDeployPresign(baseStorageUrl, headers, files, timeoutMs) {
|
|
|
1757
2398
|
return parsed?.urls ?? [];
|
|
1758
2399
|
}
|
|
1759
2400
|
function putToPresignedUrl(uploadUrl, body, contentType, timeoutMs) {
|
|
1760
|
-
return new Promise((
|
|
2401
|
+
return new Promise((resolve5, reject) => {
|
|
1761
2402
|
let parsed;
|
|
1762
2403
|
try {
|
|
1763
2404
|
parsed = new URL(uploadUrl);
|
|
@@ -1788,7 +2429,7 @@ function putToPresignedUrl(uploadUrl, body, contentType, timeoutMs) {
|
|
|
1788
2429
|
res.on("end", () => {
|
|
1789
2430
|
const status = res.statusCode || 0;
|
|
1790
2431
|
if (status >= 200 && status < 300) {
|
|
1791
|
-
|
|
2432
|
+
resolve5();
|
|
1792
2433
|
return;
|
|
1793
2434
|
}
|
|
1794
2435
|
reject(
|
|
@@ -1940,7 +2581,7 @@ function apiErrorMessage(data, status) {
|
|
|
1940
2581
|
return suggestion ? `${message} (${suggestion})` : message;
|
|
1941
2582
|
}
|
|
1942
2583
|
async function makeRequest(url, method, headers, body, reqOpts = {}) {
|
|
1943
|
-
return new Promise((
|
|
2584
|
+
return new Promise((resolve5, reject) => {
|
|
1944
2585
|
const parsedUrl = new URL(url);
|
|
1945
2586
|
const isHttps = parsedUrl.protocol === "https:";
|
|
1946
2587
|
const lib = isHttps ? https : http2;
|
|
@@ -1966,12 +2607,12 @@ async function makeRequest(url, method, headers, body, reqOpts = {}) {
|
|
|
1966
2607
|
res.on("end", () => {
|
|
1967
2608
|
const data = Buffer.concat(chunks).toString("utf8");
|
|
1968
2609
|
try {
|
|
1969
|
-
|
|
2610
|
+
resolve5({
|
|
1970
2611
|
status: res.statusCode || 0,
|
|
1971
2612
|
data: data ? JSON.parse(data) : null
|
|
1972
2613
|
});
|
|
1973
2614
|
} catch {
|
|
1974
|
-
|
|
2615
|
+
resolve5({ status: res.statusCode || 0, data });
|
|
1975
2616
|
}
|
|
1976
2617
|
});
|
|
1977
2618
|
});
|
|
@@ -2004,27 +2645,27 @@ function computeDeployTimeout(totalBytes, override) {
|
|
|
2004
2645
|
return Math.max(DEPLOY_TIMEOUT_MIN_MS, DEPLOY_TIMEOUT_BASE_MS + sizeBased);
|
|
2005
2646
|
}
|
|
2006
2647
|
async function deploy(directory, config, isDev = false, deployOpts = {}) {
|
|
2007
|
-
const dir =
|
|
2008
|
-
if (!
|
|
2648
|
+
const dir = path5.resolve(directory);
|
|
2649
|
+
if (!fs5.existsSync(dir)) {
|
|
2009
2650
|
error(`\uB514\uB809\uD1A0\uB9AC\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ${dir}`);
|
|
2010
2651
|
process.exit(1);
|
|
2011
2652
|
}
|
|
2012
|
-
const pkgPath =
|
|
2013
|
-
if (
|
|
2653
|
+
const pkgPath = path5.join(process.cwd(), "package.json");
|
|
2654
|
+
if (fs5.existsSync(pkgPath)) {
|
|
2014
2655
|
try {
|
|
2015
|
-
const pkg = JSON.parse(
|
|
2656
|
+
const pkg = JSON.parse(fs5.readFileSync(pkgPath, "utf-8"));
|
|
2016
2657
|
const pm = packageManagerCommands(detectPackageManager(process.cwd()));
|
|
2017
2658
|
const inside = runningInsidePackageScript(pkg.scripts ?? {});
|
|
2018
2659
|
for (const line of buildFirstHint(pkg, pm, inside)) warn(line);
|
|
2019
2660
|
} catch {
|
|
2020
2661
|
}
|
|
2021
2662
|
}
|
|
2022
|
-
if (!
|
|
2663
|
+
if (!fs5.statSync(dir).isDirectory()) {
|
|
2023
2664
|
error(`${dir}\uB294 \uB514\uB809\uD1A0\uB9AC\uAC00 \uC544\uB2D9\uB2C8\uB2E4`);
|
|
2024
2665
|
process.exit(1);
|
|
2025
2666
|
}
|
|
2026
|
-
const indexPath =
|
|
2027
|
-
if (!
|
|
2667
|
+
const indexPath = path5.join(dir, "index.html");
|
|
2668
|
+
if (!fs5.existsSync(indexPath)) {
|
|
2028
2669
|
error("index.html \uD30C\uC77C\uC774 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
2029
2670
|
process.exit(1);
|
|
2030
2671
|
}
|
|
@@ -2383,15 +3024,15 @@ function prompt(question) {
|
|
|
2383
3024
|
input: process.stdin,
|
|
2384
3025
|
output: process.stdout
|
|
2385
3026
|
});
|
|
2386
|
-
return new Promise((
|
|
3027
|
+
return new Promise((resolve5) => {
|
|
2387
3028
|
rl.question(question, (answer) => {
|
|
2388
3029
|
rl.close();
|
|
2389
|
-
|
|
3030
|
+
resolve5(answer.trim());
|
|
2390
3031
|
});
|
|
2391
3032
|
});
|
|
2392
3033
|
}
|
|
2393
3034
|
function promptSecret(question) {
|
|
2394
|
-
return new Promise((
|
|
3035
|
+
return new Promise((resolve5) => {
|
|
2395
3036
|
process.stdout.write(question);
|
|
2396
3037
|
const input = [];
|
|
2397
3038
|
if (!process.stdin.isTTY) {
|
|
@@ -2401,7 +3042,7 @@ function promptSecret(question) {
|
|
|
2401
3042
|
});
|
|
2402
3043
|
rl.question("", (answer) => {
|
|
2403
3044
|
rl.close();
|
|
2404
|
-
|
|
3045
|
+
resolve5(answer.trim());
|
|
2405
3046
|
});
|
|
2406
3047
|
return;
|
|
2407
3048
|
}
|
|
@@ -2416,7 +3057,7 @@ function promptSecret(question) {
|
|
|
2416
3057
|
process.stdin.pause();
|
|
2417
3058
|
process.stdin.removeListener("data", onData);
|
|
2418
3059
|
process.stdout.write("\n");
|
|
2419
|
-
|
|
3060
|
+
resolve5(input.join("").trim());
|
|
2420
3061
|
return;
|
|
2421
3062
|
} else if (code === 3) {
|
|
2422
3063
|
process.stdin.setRawMode(false);
|
|
@@ -2467,8 +3108,8 @@ function browserOpenCommand(url, platform2 = process.platform) {
|
|
|
2467
3108
|
function openBrowser(url) {
|
|
2468
3109
|
const opener = browserOpenCommand(url);
|
|
2469
3110
|
if (!opener) return;
|
|
2470
|
-
const { spawn:
|
|
2471
|
-
const child =
|
|
3111
|
+
const { spawn: spawn3 } = require("child_process");
|
|
3112
|
+
const child = spawn3(opener.command, opener.args, {
|
|
2472
3113
|
stdio: "ignore",
|
|
2473
3114
|
detached: true
|
|
2474
3115
|
});
|
|
@@ -2535,7 +3176,7 @@ ${colors.cyan}\uBE0C\uB77C\uC6B0\uC800\uC5D0\uC11C \uB85C\uADF8\uC778\uD558\uC13
|
|
|
2535
3176
|
process.stdout.write(
|
|
2536
3177
|
`\r${colors.blue}${frame}${colors.reset} \uBE0C\uB77C\uC6B0\uC800\uC5D0\uC11C \uC2B9\uC778 \uB300\uAE30 \uC911...`
|
|
2537
3178
|
);
|
|
2538
|
-
await new Promise((
|
|
3179
|
+
await new Promise((resolve5) => setTimeout(resolve5, pollInterval));
|
|
2539
3180
|
try {
|
|
2540
3181
|
const pollRes = await makeRequest(
|
|
2541
3182
|
`${baseUrl}/v1/public/cli-auth/poll/${session_id}`,
|
|
@@ -2630,11 +3271,11 @@ ${colors.dim}\uC778\uC99D \uBC29\uC2DD\uC744 \uC120\uD0DD\uD558\uC138\uC694:${co
|
|
|
2630
3271
|
return entered;
|
|
2631
3272
|
}
|
|
2632
3273
|
function saveSecretKeyToRc(secretKey, dir = process.cwd()) {
|
|
2633
|
-
const rcPath =
|
|
3274
|
+
const rcPath = path5.join(dir, ".connectbaserc");
|
|
2634
3275
|
let rcData = {};
|
|
2635
|
-
if (
|
|
3276
|
+
if (fs5.existsSync(rcPath)) {
|
|
2636
3277
|
try {
|
|
2637
|
-
rcData = JSON.parse(
|
|
3278
|
+
rcData = JSON.parse(fs5.readFileSync(rcPath, "utf-8"));
|
|
2638
3279
|
} catch {
|
|
2639
3280
|
}
|
|
2640
3281
|
}
|
|
@@ -2672,11 +3313,11 @@ ${colors.cyan}Connect Base \uD504\uB85C\uC81D\uD2B8 \uCD08\uAE30\uD654${colors.r
|
|
|
2672
3313
|
);
|
|
2673
3314
|
process.exit(1);
|
|
2674
3315
|
}
|
|
2675
|
-
const rcPath =
|
|
3316
|
+
const rcPath = path5.join(cwd, ".connectbaserc");
|
|
2676
3317
|
let existingRc = {};
|
|
2677
|
-
if (
|
|
3318
|
+
if (fs5.existsSync(rcPath)) {
|
|
2678
3319
|
try {
|
|
2679
|
-
existingRc = JSON.parse(
|
|
3320
|
+
existingRc = JSON.parse(fs5.readFileSync(rcPath, "utf-8"));
|
|
2680
3321
|
} catch {
|
|
2681
3322
|
}
|
|
2682
3323
|
if (nonInteractive) {
|
|
@@ -2719,7 +3360,7 @@ ${colors.cyan}Connect Base \uD504\uB85C\uC81D\uD2B8 \uCD08\uAE30\uD654${colors.r
|
|
|
2719
3360
|
}
|
|
2720
3361
|
let appId = "";
|
|
2721
3362
|
let publicKey = "";
|
|
2722
|
-
const projectName =
|
|
3363
|
+
const projectName = path5.basename(cwd);
|
|
2723
3364
|
const reuseKeyIfSameApp = (selectedAppId) => {
|
|
2724
3365
|
if (existingRc.appId === selectedAppId && existingRc.publicKey?.startsWith("cb_pk_")) {
|
|
2725
3366
|
publicKey = existingRc.publicKey;
|
|
@@ -2994,17 +3635,17 @@ ${colors.dim}Claude Code\uC5D0\uC11C MCP\uAC00 \uC790\uB3D9 \uC5F0\uACB0\uB429\u
|
|
|
2994
3635
|
`);
|
|
2995
3636
|
}
|
|
2996
3637
|
function detectBuildDir() {
|
|
2997
|
-
if (
|
|
2998
|
-
if (
|
|
2999
|
-
if (
|
|
3000
|
-
const nextConfig = ["next.config.js", "next.config.mjs", "next.config.ts"].map((f) =>
|
|
3001
|
-
if (nextConfig ||
|
|
3638
|
+
if (fs5.existsSync(path5.join(process.cwd(), "dist"))) return "./dist";
|
|
3639
|
+
if (fs5.existsSync(path5.join(process.cwd(), "build"))) return "./build";
|
|
3640
|
+
if (fs5.existsSync(path5.join(process.cwd(), "out"))) return "./out";
|
|
3641
|
+
const nextConfig = ["next.config.js", "next.config.mjs", "next.config.ts"].map((f) => path5.join(process.cwd(), f)).find((f) => fs5.existsSync(f));
|
|
3642
|
+
if (nextConfig || fs5.existsSync(path5.join(process.cwd(), ".next"))) {
|
|
3002
3643
|
if (nextConfig) {
|
|
3003
3644
|
try {
|
|
3004
|
-
const src =
|
|
3645
|
+
const src = fs5.readFileSync(nextConfig, "utf-8");
|
|
3005
3646
|
if (!/output\s*:\s*['"]export['"]/.test(src)) {
|
|
3006
3647
|
warn(
|
|
3007
|
-
`Next.js \uAC10\uC9C0: \uC815\uC801 \uBC30\uD3EC\uD558\uB824\uBA74 ${
|
|
3648
|
+
`Next.js \uAC10\uC9C0: \uC815\uC801 \uBC30\uD3EC\uD558\uB824\uBA74 ${path5.basename(nextConfig)}\uC5D0 output: 'export' \uC124\uC815\uC774 \uD544\uC694\uD569\uB2C8\uB2E4`
|
|
3008
3649
|
);
|
|
3009
3650
|
}
|
|
3010
3651
|
} catch {
|
|
@@ -3012,25 +3653,25 @@ function detectBuildDir() {
|
|
|
3012
3653
|
}
|
|
3013
3654
|
return "./out";
|
|
3014
3655
|
}
|
|
3015
|
-
if (
|
|
3656
|
+
if (fs5.existsSync(path5.join(process.cwd(), "vite.config.ts")) || fs5.existsSync(path5.join(process.cwd(), "vite.config.js")))
|
|
3016
3657
|
return "./dist";
|
|
3017
3658
|
return "./dist";
|
|
3018
3659
|
}
|
|
3019
3660
|
function writeSecretFile(filePath, content) {
|
|
3020
3661
|
try {
|
|
3021
|
-
if (
|
|
3662
|
+
if (fs5.existsSync(filePath)) fs5.chmodSync(filePath, 384);
|
|
3022
3663
|
} catch {
|
|
3023
3664
|
}
|
|
3024
|
-
|
|
3665
|
+
fs5.writeFileSync(filePath, content, { mode: 384 });
|
|
3025
3666
|
}
|
|
3026
3667
|
function addToGitignore(entry, basePath) {
|
|
3027
3668
|
const dir = basePath || process.cwd();
|
|
3028
|
-
const gitignorePath =
|
|
3029
|
-
if (
|
|
3030
|
-
const content =
|
|
3669
|
+
const gitignorePath = path5.join(dir, ".gitignore");
|
|
3670
|
+
if (fs5.existsSync(gitignorePath)) {
|
|
3671
|
+
const content = fs5.readFileSync(gitignorePath, "utf-8");
|
|
3031
3672
|
const lines = content.split(/\r?\n/).map((l) => l.trim());
|
|
3032
3673
|
if (!lines.includes(entry)) {
|
|
3033
|
-
|
|
3674
|
+
fs5.appendFileSync(gitignorePath, `
|
|
3034
3675
|
# Connect Base
|
|
3035
3676
|
${entry}
|
|
3036
3677
|
`);
|
|
@@ -3039,7 +3680,7 @@ ${entry}
|
|
|
3039
3680
|
info(`.gitignore\uC5D0 \uC774\uBBF8 ${entry}\uAC00 \uD3EC\uD568\uB418\uC5B4 \uC788\uC2B5\uB2C8\uB2E4`);
|
|
3040
3681
|
}
|
|
3041
3682
|
} else {
|
|
3042
|
-
|
|
3683
|
+
fs5.writeFileSync(gitignorePath, `# Connect Base
|
|
3043
3684
|
${entry}
|
|
3044
3685
|
`);
|
|
3045
3686
|
success(".gitignore \uC0DD\uC131 \uC644\uB8CC");
|
|
@@ -3070,8 +3711,8 @@ function ancestorCommandLines(maxDepth = 8) {
|
|
|
3070
3711
|
let ppid = 0;
|
|
3071
3712
|
try {
|
|
3072
3713
|
if (process.platform === "linux") {
|
|
3073
|
-
cmd =
|
|
3074
|
-
const stat =
|
|
3714
|
+
cmd = fs5.readFileSync(`/proc/${pid}/cmdline`).toString("utf8").replace(/\0/g, " ").trim();
|
|
3715
|
+
const stat = fs5.readFileSync(`/proc/${pid}/stat`, "utf8");
|
|
3075
3716
|
ppid = parseInt(
|
|
3076
3717
|
stat.slice(stat.lastIndexOf(")") + 2).split(" ")[1],
|
|
3077
3718
|
10
|
|
@@ -3115,7 +3756,7 @@ function buildFirstHint(pkg, pm, insideScript) {
|
|
|
3115
3756
|
function detectPackageManager(startDir = process.cwd()) {
|
|
3116
3757
|
try {
|
|
3117
3758
|
const pkg = JSON.parse(
|
|
3118
|
-
|
|
3759
|
+
fs5.readFileSync(path5.join(startDir, "package.json"), "utf-8")
|
|
3119
3760
|
);
|
|
3120
3761
|
const declared = typeof pkg.packageManager === "string" ? pkg.packageManager.split("@")[0] : "";
|
|
3121
3762
|
if (declared === "npm" || declared === "pnpm" || declared === "yarn" || declared === "bun") {
|
|
@@ -3131,13 +3772,13 @@ function detectPackageManager(startDir = process.cwd()) {
|
|
|
3131
3772
|
["package-lock.json", "npm"],
|
|
3132
3773
|
["npm-shrinkwrap.json", "npm"]
|
|
3133
3774
|
];
|
|
3134
|
-
let dir =
|
|
3775
|
+
let dir = path5.resolve(startDir);
|
|
3135
3776
|
for (; ; ) {
|
|
3136
3777
|
for (const [file, pm] of lockfiles) {
|
|
3137
|
-
if (
|
|
3778
|
+
if (fs5.existsSync(path5.join(dir, file))) return pm;
|
|
3138
3779
|
}
|
|
3139
|
-
if (
|
|
3140
|
-
const parent =
|
|
3780
|
+
if (fs5.existsSync(path5.join(dir, ".git"))) break;
|
|
3781
|
+
const parent = path5.dirname(dir);
|
|
3141
3782
|
if (parent === dir) break;
|
|
3142
3783
|
dir = parent;
|
|
3143
3784
|
}
|
|
@@ -3151,13 +3792,13 @@ function packageManagerCommands(pm) {
|
|
|
3151
3792
|
};
|
|
3152
3793
|
}
|
|
3153
3794
|
function addDeployScript(deployDir, pm) {
|
|
3154
|
-
const pkgPath =
|
|
3155
|
-
if (!
|
|
3795
|
+
const pkgPath = path5.join(process.cwd(), "package.json");
|
|
3796
|
+
if (!fs5.existsSync(pkgPath)) {
|
|
3156
3797
|
warn("package.json\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC5B4 deploy \uC2A4\uD06C\uB9BD\uD2B8\uB97C \uCD94\uAC00\uD558\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4");
|
|
3157
3798
|
return { needsInstall: false };
|
|
3158
3799
|
}
|
|
3159
3800
|
try {
|
|
3160
|
-
const pkg = JSON.parse(
|
|
3801
|
+
const pkg = JSON.parse(fs5.readFileSync(pkgPath, "utf-8"));
|
|
3161
3802
|
if (!pkg.scripts) pkg.scripts = {};
|
|
3162
3803
|
const declared = (name) => Boolean(pkg.dependencies?.[name] || pkg.devDependencies?.[name]);
|
|
3163
3804
|
let needsInstall = false;
|
|
@@ -3175,7 +3816,7 @@ function addDeployScript(deployDir, pm) {
|
|
|
3175
3816
|
pkg.scripts.deploy = pkg.scripts.build ? `${pm.run("build")} && ${deployCmd}` : deployCmd;
|
|
3176
3817
|
success("package.json\uC5D0 deploy \uC2A4\uD06C\uB9BD\uD2B8 \uCD94\uAC00 \uC644\uB8CC");
|
|
3177
3818
|
}
|
|
3178
|
-
|
|
3819
|
+
fs5.writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}
|
|
3179
3820
|
`);
|
|
3180
3821
|
if (needsInstall) {
|
|
3181
3822
|
success(
|
|
@@ -3206,32 +3847,32 @@ function detectMonorepo(gitRoot) {
|
|
|
3206
3847
|
root: gitRoot,
|
|
3207
3848
|
isSubPackage: false
|
|
3208
3849
|
};
|
|
3209
|
-
if (
|
|
3850
|
+
if (fs5.existsSync(path5.join(gitRoot, "pnpm-workspace.yaml"))) {
|
|
3210
3851
|
result.type = "pnpm";
|
|
3211
|
-
} else if (
|
|
3852
|
+
} else if (fs5.existsSync(path5.join(gitRoot, "turbo.json"))) {
|
|
3212
3853
|
result.type = "turborepo";
|
|
3213
|
-
} else if (
|
|
3854
|
+
} else if (fs5.existsSync(path5.join(gitRoot, "nx.json"))) {
|
|
3214
3855
|
result.type = "nx";
|
|
3215
|
-
} else if (
|
|
3856
|
+
} else if (fs5.existsSync(path5.join(gitRoot, "lerna.json"))) {
|
|
3216
3857
|
result.type = "lerna";
|
|
3217
3858
|
} else {
|
|
3218
|
-
const rootPkgPath =
|
|
3219
|
-
if (
|
|
3859
|
+
const rootPkgPath = path5.join(gitRoot, "package.json");
|
|
3860
|
+
if (fs5.existsSync(rootPkgPath)) {
|
|
3220
3861
|
try {
|
|
3221
|
-
const pkg = JSON.parse(
|
|
3862
|
+
const pkg = JSON.parse(fs5.readFileSync(rootPkgPath, "utf-8"));
|
|
3222
3863
|
if (pkg.workspaces) {
|
|
3223
|
-
result.type =
|
|
3864
|
+
result.type = fs5.existsSync(path5.join(gitRoot, "yarn.lock")) ? "yarn" : "npm";
|
|
3224
3865
|
}
|
|
3225
3866
|
} catch {
|
|
3226
3867
|
}
|
|
3227
3868
|
}
|
|
3228
3869
|
}
|
|
3229
3870
|
if (result.type !== "none" && cwd !== gitRoot) {
|
|
3230
|
-
const cwdPkgPath =
|
|
3231
|
-
if (
|
|
3871
|
+
const cwdPkgPath = path5.join(cwd, "package.json");
|
|
3872
|
+
if (fs5.existsSync(cwdPkgPath)) {
|
|
3232
3873
|
result.isSubPackage = true;
|
|
3233
3874
|
try {
|
|
3234
|
-
const pkg = JSON.parse(
|
|
3875
|
+
const pkg = JSON.parse(fs5.readFileSync(cwdPkgPath, "utf-8"));
|
|
3235
3876
|
result.subPackageName = pkg.name;
|
|
3236
3877
|
} catch {
|
|
3237
3878
|
}
|
|
@@ -3243,7 +3884,7 @@ var DOCS_MANIFEST_FILE = ".connectbase-manifest.json";
|
|
|
3243
3884
|
function readDocsManifest(docsDir) {
|
|
3244
3885
|
try {
|
|
3245
3886
|
const parsed = JSON.parse(
|
|
3246
|
-
|
|
3887
|
+
fs5.readFileSync(path5.join(docsDir, DOCS_MANIFEST_FILE), "utf-8")
|
|
3247
3888
|
);
|
|
3248
3889
|
if (parsed && Array.isArray(parsed.files)) return parsed;
|
|
3249
3890
|
} catch {
|
|
@@ -3305,14 +3946,14 @@ async function downloadDocs(baseDir, opts = {}) {
|
|
|
3305
3946
|
info(`\uBAA8\uB178\uB808\uD3EC \uAC10\uC9C0: ${monorepo.type} (\uB8E8\uD2B8: ${gitRoot})`);
|
|
3306
3947
|
if (monorepo.isSubPackage) {
|
|
3307
3948
|
info(
|
|
3308
|
-
`\uD604\uC7AC \uC11C\uBE0C \uD328\uD0A4\uC9C0: ${monorepo.subPackageName ||
|
|
3949
|
+
`\uD604\uC7AC \uC11C\uBE0C \uD328\uD0A4\uC9C0: ${monorepo.subPackageName || path5.basename(process.cwd())}`
|
|
3309
3950
|
);
|
|
3310
3951
|
}
|
|
3311
3952
|
}
|
|
3312
|
-
const docsDir =
|
|
3313
|
-
const rootClaudeMd =
|
|
3314
|
-
if (!
|
|
3315
|
-
|
|
3953
|
+
const docsDir = path5.join(gitRoot, ".claude", "docs");
|
|
3954
|
+
const rootClaudeMd = path5.join(gitRoot, "CLAUDE.md");
|
|
3955
|
+
if (!fs5.existsSync(docsDir)) {
|
|
3956
|
+
fs5.mkdirSync(docsDir, { recursive: true });
|
|
3316
3957
|
}
|
|
3317
3958
|
if (!quiet) info("SDK \uAC1C\uBC1C \uAC00\uC774\uB4DC \uB2E4\uC6B4\uB85C\uB4DC \uC911...");
|
|
3318
3959
|
try {
|
|
@@ -3329,21 +3970,21 @@ async function downloadDocs(baseDir, opts = {}) {
|
|
|
3329
3970
|
const hasher = crypto.createHash("sha256");
|
|
3330
3971
|
const newFiles = [];
|
|
3331
3972
|
for (const section of sections) {
|
|
3332
|
-
const safeName =
|
|
3973
|
+
const safeName = path5.basename(section.filename);
|
|
3333
3974
|
newFiles.push(safeName);
|
|
3334
3975
|
hasher.update(safeName).update("\0").update(section.content).update("\0");
|
|
3335
3976
|
}
|
|
3336
3977
|
const contentHash = hasher.digest("hex");
|
|
3337
3978
|
const prevManifest = readDocsManifest(docsDir);
|
|
3338
3979
|
const allPresent = newFiles.every(
|
|
3339
|
-
(f) =>
|
|
3980
|
+
(f) => fs5.existsSync(path5.join(docsDir, f))
|
|
3340
3981
|
);
|
|
3341
3982
|
if (prevManifest && prevManifest.contentHash === contentHash && allPresent) {
|
|
3342
3983
|
if (!quiet) success("SDK \uBB38\uC11C\uAC00 \uC774\uBBF8 \uCD5C\uC2E0\uC785\uB2C8\uB2E4");
|
|
3343
3984
|
updateRootClaudeMd(rootClaudeMd, quiet);
|
|
3344
3985
|
if (monorepo.isSubPackage) {
|
|
3345
3986
|
createSubPackageClaudeMd(
|
|
3346
|
-
|
|
3987
|
+
path5.join(process.cwd(), "CLAUDE.md"),
|
|
3347
3988
|
gitRoot,
|
|
3348
3989
|
quiet
|
|
3349
3990
|
);
|
|
@@ -3354,16 +3995,16 @@ async function downloadDocs(baseDir, opts = {}) {
|
|
|
3354
3995
|
|
|
3355
3996
|
`;
|
|
3356
3997
|
for (const section of sections) {
|
|
3357
|
-
const safeName =
|
|
3358
|
-
|
|
3998
|
+
const safeName = path5.basename(section.filename);
|
|
3999
|
+
fs5.writeFileSync(path5.join(docsDir, safeName), stamp + section.content);
|
|
3359
4000
|
}
|
|
3360
|
-
const staleCandidates = prevManifest ? prevManifest.files.map((f) =>
|
|
4001
|
+
const staleCandidates = prevManifest ? prevManifest.files.map((f) => path5.basename(f)) : LEGACY_DOC_FILES;
|
|
3361
4002
|
for (const old of staleCandidates) {
|
|
3362
4003
|
if (newFiles.includes(old)) continue;
|
|
3363
|
-
const oldPath =
|
|
3364
|
-
if (
|
|
4004
|
+
const oldPath = path5.join(docsDir, old);
|
|
4005
|
+
if (fs5.existsSync(oldPath)) {
|
|
3365
4006
|
try {
|
|
3366
|
-
|
|
4007
|
+
fs5.unlinkSync(oldPath);
|
|
3367
4008
|
if (!quiet) info(`\uC2A4\uD14C\uC77C \uBB38\uC11C \uC0AD\uC81C: ${old}`);
|
|
3368
4009
|
} catch {
|
|
3369
4010
|
}
|
|
@@ -3375,8 +4016,8 @@ async function downloadDocs(baseDir, opts = {}) {
|
|
|
3375
4016
|
contentHash,
|
|
3376
4017
|
files: newFiles
|
|
3377
4018
|
};
|
|
3378
|
-
|
|
3379
|
-
|
|
4019
|
+
fs5.writeFileSync(
|
|
4020
|
+
path5.join(docsDir, DOCS_MANIFEST_FILE),
|
|
3380
4021
|
`${JSON.stringify(manifest, null, 2)}
|
|
3381
4022
|
`
|
|
3382
4023
|
);
|
|
@@ -3387,7 +4028,7 @@ async function downloadDocs(baseDir, opts = {}) {
|
|
|
3387
4028
|
updateRootClaudeMd(rootClaudeMd, quiet);
|
|
3388
4029
|
if (monorepo.isSubPackage) {
|
|
3389
4030
|
createSubPackageClaudeMd(
|
|
3390
|
-
|
|
4031
|
+
path5.join(process.cwd(), "CLAUDE.md"),
|
|
3391
4032
|
gitRoot,
|
|
3392
4033
|
quiet
|
|
3393
4034
|
);
|
|
@@ -3406,10 +4047,10 @@ async function downloadDocs(baseDir, opts = {}) {
|
|
|
3406
4047
|
|
|
3407
4048
|
\uC0C1\uC138 \uAD6C\uD604\uBC95\uC740 MCP \`search_sdk_docs\` \uB3C4\uAD6C\uB85C \uAC80\uC0C9\uD558\uC138\uC694.
|
|
3408
4049
|
`;
|
|
3409
|
-
|
|
4050
|
+
fs5.writeFileSync(path5.join(docsDir, "project-rules.md"), fallbackContent);
|
|
3410
4051
|
updateRootClaudeMd(rootClaudeMd);
|
|
3411
4052
|
if (monorepo.isSubPackage) {
|
|
3412
|
-
const subClaudeMd =
|
|
4053
|
+
const subClaudeMd = path5.join(process.cwd(), "CLAUDE.md");
|
|
3413
4054
|
createSubPackageClaudeMd(subClaudeMd, gitRoot);
|
|
3414
4055
|
}
|
|
3415
4056
|
success(`.claude/docs/ \uC0DD\uC131 \uC644\uB8CC (\uAE30\uBCF8)`);
|
|
@@ -3432,8 +4073,8 @@ function updateRootClaudeMd(claudeMdPath, quiet = false) {
|
|
|
3432
4073
|
2. \uCF54\uB4DC\uB97C \uC791\uC131\uD558\uAE30 \uC804 \`search_sdk_docs("\uD0A4\uC6CC\uB4DC")\`\uB85C SDK \uAD6C\uD604 \uBC29\uBC95\uC744 \uAC80\uC0C9\uD558\uACE0, \uAC80\uC0C9 \uACB0\uACFC\uC758 \uCF54\uB4DC \uD328\uD134\uC744 \uADF8\uB300\uB85C \uB530\uB974\uC138\uC694
|
|
3433
4074
|
3. \`search_sdk_docs\` \uB3C4\uAD6C\uAC00 \uBCF4\uC774\uC9C0 \uC54A\uC73C\uBA74 MCP\uAC00 \uC5F0\uACB0\uB418\uC9C0 \uC54A\uC740 \uC0C1\uD0DC\uC785\uB2C8\uB2E4 \u2014 \uC0AC\uC6A9\uC790\uC5D0\uAC8C \`npx connectbase-client mcp\` \uC2E4\uD589\uC744 \uC548\uB0B4\uD558\uC138\uC694 (Secret Key \uD544\uC694)
|
|
3434
4075
|
${endMarker}`;
|
|
3435
|
-
if (
|
|
3436
|
-
let content =
|
|
4076
|
+
if (fs5.existsSync(claudeMdPath)) {
|
|
4077
|
+
let content = fs5.readFileSync(claudeMdPath, "utf-8");
|
|
3437
4078
|
const startIdx = content.indexOf(startMarker);
|
|
3438
4079
|
const endIdx = content.indexOf(endMarker);
|
|
3439
4080
|
if (startIdx !== -1 && endIdx !== -1) {
|
|
@@ -3443,10 +4084,10 @@ ${endMarker}`;
|
|
|
3443
4084
|
|
|
3444
4085
|
${content.trimStart()}`;
|
|
3445
4086
|
}
|
|
3446
|
-
|
|
4087
|
+
fs5.writeFileSync(claudeMdPath, content);
|
|
3447
4088
|
if (!quiet) info("CLAUDE.md\uC5D0 ConnectBase \uCC38\uC870 \uC5C5\uB370\uC774\uD2B8 \uC644\uB8CC");
|
|
3448
4089
|
} else {
|
|
3449
|
-
|
|
4090
|
+
fs5.writeFileSync(claudeMdPath, `# \uD504\uB85C\uC81D\uD2B8
|
|
3450
4091
|
|
|
3451
4092
|
${sdkBlock}
|
|
3452
4093
|
`);
|
|
@@ -3456,7 +4097,7 @@ ${sdkBlock}
|
|
|
3456
4097
|
function createSubPackageClaudeMd(subClaudeMdPath, gitRoot, quiet = false) {
|
|
3457
4098
|
const startMarker = "<!-- CONNECTBASE_SUB_START -->";
|
|
3458
4099
|
const endMarker = "<!-- CONNECTBASE_SUB_END -->";
|
|
3459
|
-
const relPath =
|
|
4100
|
+
const relPath = path5.relative(path5.dirname(subClaudeMdPath), gitRoot);
|
|
3460
4101
|
const subBlock = `${startMarker}
|
|
3461
4102
|
## ConnectBase SDK
|
|
3462
4103
|
|
|
@@ -3468,8 +4109,8 @@ function createSubPackageClaudeMd(subClaudeMdPath, gitRoot, quiet = false) {
|
|
|
3468
4109
|
2. \uCF54\uB4DC\uB97C \uC791\uC131\uD558\uAE30 \uC804 \`search_sdk_docs("\uD0A4\uC6CC\uB4DC")\`\uB85C SDK \uAD6C\uD604 \uBC29\uBC95\uC744 \uAC80\uC0C9\uD558\uC138\uC694
|
|
3469
4110
|
3. \`search_sdk_docs\` \uB3C4\uAD6C\uAC00 \uBCF4\uC774\uC9C0 \uC54A\uC73C\uBA74 \uC0AC\uC6A9\uC790\uC5D0\uAC8C \`npx connectbase-client mcp\` \uC2E4\uD589\uC744 \uC548\uB0B4\uD558\uC138\uC694
|
|
3470
4111
|
${endMarker}`;
|
|
3471
|
-
if (
|
|
3472
|
-
let content =
|
|
4112
|
+
if (fs5.existsSync(subClaudeMdPath)) {
|
|
4113
|
+
let content = fs5.readFileSync(subClaudeMdPath, "utf-8");
|
|
3473
4114
|
const startIdx = content.indexOf(startMarker);
|
|
3474
4115
|
const endIdx = content.indexOf(endMarker);
|
|
3475
4116
|
if (startIdx !== -1 && endIdx !== -1) {
|
|
@@ -3482,11 +4123,11 @@ ${subBlock}
|
|
|
3482
4123
|
} else {
|
|
3483
4124
|
return;
|
|
3484
4125
|
}
|
|
3485
|
-
|
|
4126
|
+
fs5.writeFileSync(subClaudeMdPath, content);
|
|
3486
4127
|
} else {
|
|
3487
|
-
|
|
4128
|
+
fs5.writeFileSync(
|
|
3488
4129
|
subClaudeMdPath,
|
|
3489
|
-
`# ${
|
|
4130
|
+
`# ${path5.basename(path5.dirname(subClaudeMdPath))}
|
|
3490
4131
|
|
|
3491
4132
|
${subBlock}
|
|
3492
4133
|
`
|
|
@@ -3504,7 +4145,7 @@ async function setupMcp(secretKey, baseUrl = DEFAULT_BASE_URL) {
|
|
|
3504
4145
|
info(`MCP \uC124\uC815\uC740 \uD504\uB85C\uC81D\uD2B8 \uB8E8\uD2B8(${root})\uC5D0 \uC0DD\uC131\uB429\uB2C8\uB2E4`);
|
|
3505
4146
|
}
|
|
3506
4147
|
}
|
|
3507
|
-
const mcpConfigPath =
|
|
4148
|
+
const mcpConfigPath = path5.join(root, ".mcp.json");
|
|
3508
4149
|
if (secretKey) {
|
|
3509
4150
|
const check = await fetchAppsWithSecretKey(baseUrl, secretKey).catch(
|
|
3510
4151
|
() => null
|
|
@@ -3539,17 +4180,17 @@ async function setupMcp(secretKey, baseUrl = DEFAULT_BASE_URL) {
|
|
|
3539
4180
|
}
|
|
3540
4181
|
};
|
|
3541
4182
|
let mcpConfig = { mcpServers: {} };
|
|
3542
|
-
if (
|
|
4183
|
+
if (fs5.existsSync(mcpConfigPath)) {
|
|
3543
4184
|
try {
|
|
3544
|
-
mcpConfig = JSON.parse(
|
|
4185
|
+
mcpConfig = JSON.parse(fs5.readFileSync(mcpConfigPath, "utf-8"));
|
|
3545
4186
|
if (!mcpConfig.mcpServers || typeof mcpConfig.mcpServers !== "object") {
|
|
3546
4187
|
mcpConfig.mcpServers = {};
|
|
3547
4188
|
}
|
|
3548
4189
|
} catch {
|
|
3549
4190
|
const backupPath = `${mcpConfigPath}.backup`;
|
|
3550
|
-
|
|
4191
|
+
fs5.copyFileSync(mcpConfigPath, backupPath);
|
|
3551
4192
|
try {
|
|
3552
|
-
|
|
4193
|
+
fs5.chmodSync(backupPath, 384);
|
|
3553
4194
|
} catch {
|
|
3554
4195
|
}
|
|
3555
4196
|
warn(`.mcp.json \uD30C\uC2F1 \uC2E4\uD328, \uBC31\uC5C5 \uC0DD\uC131: ${backupPath}`);
|
|
@@ -3610,14 +4251,14 @@ function findSubPackagesWithConfig(gitRoot) {
|
|
|
3610
4251
|
const results = [];
|
|
3611
4252
|
const candidates = ["apps", "packages", "projects", "services", "libs"];
|
|
3612
4253
|
for (const candidate of candidates) {
|
|
3613
|
-
const dir =
|
|
3614
|
-
if (!
|
|
4254
|
+
const dir = path5.join(gitRoot, candidate);
|
|
4255
|
+
if (!fs5.existsSync(dir)) continue;
|
|
3615
4256
|
try {
|
|
3616
|
-
const entries =
|
|
4257
|
+
const entries = fs5.readdirSync(dir, { withFileTypes: true });
|
|
3617
4258
|
for (const entry of entries) {
|
|
3618
4259
|
if (!entry.isDirectory() || entry.name.startsWith(".")) continue;
|
|
3619
|
-
const subDir =
|
|
3620
|
-
if (
|
|
4260
|
+
const subDir = path5.join(dir, entry.name);
|
|
4261
|
+
if (fs5.existsSync(path5.join(subDir, ".connectbaserc"))) {
|
|
3621
4262
|
results.push(subDir);
|
|
3622
4263
|
}
|
|
3623
4264
|
}
|
|
@@ -3625,13 +4266,13 @@ function findSubPackagesWithConfig(gitRoot) {
|
|
|
3625
4266
|
}
|
|
3626
4267
|
}
|
|
3627
4268
|
try {
|
|
3628
|
-
const entries =
|
|
4269
|
+
const entries = fs5.readdirSync(gitRoot, { withFileTypes: true });
|
|
3629
4270
|
for (const entry of entries) {
|
|
3630
4271
|
if (!entry.isDirectory() || entry.name.startsWith(".") || candidates.includes(entry.name))
|
|
3631
4272
|
continue;
|
|
3632
4273
|
if (entry.name === "node_modules") continue;
|
|
3633
|
-
const subDir =
|
|
3634
|
-
if (
|
|
4274
|
+
const subDir = path5.join(gitRoot, entry.name);
|
|
4275
|
+
if (fs5.existsSync(path5.join(subDir, ".connectbaserc")) && !results.includes(subDir)) {
|
|
3635
4276
|
results.push(subDir);
|
|
3636
4277
|
}
|
|
3637
4278
|
}
|
|
@@ -3675,7 +4316,7 @@ ${colors.cyan}ConnectBase Update${colors.reset}
|
|
|
3675
4316
|
info(`ConnectBase\uB97C \uC0AC\uC6A9\uD558\uB294 \uC11C\uBE0C \uD328\uD0A4\uC9C0 ${subPackages.length}\uAC1C \uBC1C\uACAC:`);
|
|
3676
4317
|
for (const sp of subPackages) {
|
|
3677
4318
|
log(
|
|
3678
|
-
` ${colors.dim}\u2022 ${
|
|
4319
|
+
` ${colors.dim}\u2022 ${path5.relative(projectRoot, sp)}${colors.reset}`
|
|
3679
4320
|
);
|
|
3680
4321
|
}
|
|
3681
4322
|
}
|
|
@@ -3687,14 +4328,14 @@ ${colors.cyan}ConnectBase Update${colors.reset}
|
|
|
3687
4328
|
}
|
|
3688
4329
|
if (!opts.skipMcp) {
|
|
3689
4330
|
log("");
|
|
3690
|
-
const mcpConfigPath =
|
|
3691
|
-
if (
|
|
4331
|
+
const mcpConfigPath = path5.join(projectRoot, ".mcp.json");
|
|
4332
|
+
if (fs5.existsSync(mcpConfigPath)) {
|
|
3692
4333
|
let secretKey = config.secretKey;
|
|
3693
4334
|
if (!secretKey) {
|
|
3694
|
-
const rootRcPath =
|
|
3695
|
-
if (
|
|
4335
|
+
const rootRcPath = path5.join(projectRoot, ".connectbaserc");
|
|
4336
|
+
if (fs5.existsSync(rootRcPath)) {
|
|
3696
4337
|
try {
|
|
3697
|
-
const rc = JSON.parse(
|
|
4338
|
+
const rc = JSON.parse(fs5.readFileSync(rootRcPath, "utf-8"));
|
|
3698
4339
|
secretKey = rc.secretKey;
|
|
3699
4340
|
} catch {
|
|
3700
4341
|
}
|
|
@@ -3705,7 +4346,7 @@ ${colors.cyan}ConnectBase Update${colors.reset}
|
|
|
3705
4346
|
for (const sp of subPackages) {
|
|
3706
4347
|
try {
|
|
3707
4348
|
const rc = JSON.parse(
|
|
3708
|
-
|
|
4349
|
+
fs5.readFileSync(path5.join(sp, ".connectbaserc"), "utf-8")
|
|
3709
4350
|
);
|
|
3710
4351
|
if (rc.secretKey) {
|
|
3711
4352
|
secretKey = rc.secretKey;
|
|
@@ -3717,7 +4358,7 @@ ${colors.cyan}ConnectBase Update${colors.reset}
|
|
|
3717
4358
|
}
|
|
3718
4359
|
if (secretKey) {
|
|
3719
4360
|
try {
|
|
3720
|
-
const mcpConfig = JSON.parse(
|
|
4361
|
+
const mcpConfig = JSON.parse(fs5.readFileSync(mcpConfigPath, "utf-8"));
|
|
3721
4362
|
const servers = mcpConfig.mcpServers || {};
|
|
3722
4363
|
if (servers["connect-base"]) {
|
|
3723
4364
|
servers["connect-base"] = {
|
|
@@ -3756,15 +4397,15 @@ ${colors.green}\uC5C5\uB370\uC774\uD2B8 \uC644\uB8CC!${colors.reset}
|
|
|
3756
4397
|
`);
|
|
3757
4398
|
}
|
|
3758
4399
|
function setupMonorepoRoot(projectRoot, monorepo) {
|
|
3759
|
-
const rootPkgPath =
|
|
3760
|
-
if (!
|
|
4400
|
+
const rootPkgPath = path5.join(projectRoot, "package.json");
|
|
4401
|
+
if (!fs5.existsSync(rootPkgPath)) {
|
|
3761
4402
|
warn(
|
|
3762
4403
|
"\uD504\uB85C\uC81D\uD2B8 \uB8E8\uD2B8\uC5D0 package.json\uC774 \uC5C6\uC5B4 \uD3B8\uC758 \uC2A4\uD06C\uB9BD\uD2B8\uB97C \uCD94\uAC00\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4"
|
|
3763
4404
|
);
|
|
3764
4405
|
return;
|
|
3765
4406
|
}
|
|
3766
4407
|
try {
|
|
3767
|
-
const pkg = JSON.parse(
|
|
4408
|
+
const pkg = JSON.parse(fs5.readFileSync(rootPkgPath, "utf-8"));
|
|
3768
4409
|
if (!pkg.scripts) pkg.scripts = {};
|
|
3769
4410
|
let changed = false;
|
|
3770
4411
|
if (!pkg.scripts["cb:update"]) {
|
|
@@ -3780,7 +4421,7 @@ function setupMonorepoRoot(projectRoot, monorepo) {
|
|
|
3780
4421
|
changed = true;
|
|
3781
4422
|
}
|
|
3782
4423
|
if (changed) {
|
|
3783
|
-
|
|
4424
|
+
fs5.writeFileSync(rootPkgPath, `${JSON.stringify(pkg, null, 2)}
|
|
3784
4425
|
`);
|
|
3785
4426
|
success("\uBAA8\uB178\uB808\uD3EC \uB8E8\uD2B8\uC5D0 \uD3B8\uC758 \uC2A4\uD06C\uB9BD\uD2B8 \uCD94\uAC00 \uC644\uB8CC");
|
|
3786
4427
|
log(` ${colors.dim}\uC0AC\uC6A9\uBC95:${colors.reset}`);
|
|
@@ -4185,7 +4826,7 @@ ${colors.blue}?${colors.reset} \uC571 \uC120\uD0DD (\uBC88\uD638): `
|
|
|
4185
4826
|
success(`\uC120\uD0DD\uB428: ${apps[num2 - 1].name}`);
|
|
4186
4827
|
return { appId: apps[num2 - 1].id };
|
|
4187
4828
|
}
|
|
4188
|
-
const projectName =
|
|
4829
|
+
const projectName = path5.basename(process.cwd());
|
|
4189
4830
|
const appName = await prompt(
|
|
4190
4831
|
`${colors.blue}?${colors.reset} \uC571 \uC774\uB984 (${projectName}): `
|
|
4191
4832
|
) || projectName;
|
|
@@ -4268,11 +4909,11 @@ async function startTunnel(port, config, tunnelOpts) {
|
|
|
4268
4909
|
info("Secret Key\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4. \uBE0C\uB77C\uC6B0\uC800 \uB85C\uADF8\uC778\uC73C\uB85C \uBC1C\uAE09\uD569\uB2C8\uB2E4...");
|
|
4269
4910
|
try {
|
|
4270
4911
|
const sk = await browserAuthFlow();
|
|
4271
|
-
const rcPath2 =
|
|
4912
|
+
const rcPath2 = path5.join(process.cwd(), ".connectbaserc");
|
|
4272
4913
|
let rcData = {};
|
|
4273
|
-
if (
|
|
4914
|
+
if (fs5.existsSync(rcPath2)) {
|
|
4274
4915
|
try {
|
|
4275
|
-
rcData = JSON.parse(
|
|
4916
|
+
rcData = JSON.parse(fs5.readFileSync(rcPath2, "utf-8"));
|
|
4276
4917
|
} catch {
|
|
4277
4918
|
}
|
|
4278
4919
|
}
|
|
@@ -4291,11 +4932,11 @@ async function startTunnel(port, config, tunnelOpts) {
|
|
|
4291
4932
|
} else {
|
|
4292
4933
|
config.secretKey = tunnelKey;
|
|
4293
4934
|
}
|
|
4294
|
-
const rcPath =
|
|
4935
|
+
const rcPath = path5.join(process.cwd(), ".connectbaserc");
|
|
4295
4936
|
let savedAppId = tunnelOpts?.appId || "";
|
|
4296
4937
|
if (!savedAppId) {
|
|
4297
4938
|
try {
|
|
4298
|
-
const rc = JSON.parse(
|
|
4939
|
+
const rc = JSON.parse(fs5.readFileSync(rcPath, "utf-8"));
|
|
4299
4940
|
if (rc.tunnelAppId) savedAppId = rc.tunnelAppId;
|
|
4300
4941
|
} catch {
|
|
4301
4942
|
}
|
|
@@ -4303,9 +4944,9 @@ async function startTunnel(port, config, tunnelOpts) {
|
|
|
4303
4944
|
const { appId } = await resolveApp(tunnelKey, config.baseUrl, savedAppId);
|
|
4304
4945
|
try {
|
|
4305
4946
|
let rcData = {};
|
|
4306
|
-
if (
|
|
4947
|
+
if (fs5.existsSync(rcPath)) {
|
|
4307
4948
|
try {
|
|
4308
|
-
rcData = JSON.parse(
|
|
4949
|
+
rcData = JSON.parse(fs5.readFileSync(rcPath, "utf-8"));
|
|
4309
4950
|
} catch {
|
|
4310
4951
|
}
|
|
4311
4952
|
}
|
|
@@ -5062,7 +5703,12 @@ ${colors.yellow}\uBA85\uB839\uC5B4:${colors.reset}
|
|
|
5062
5703
|
promote [releaseId] QA \uAC80\uC99D \uD6C4 production \uBC18\uC601 (\uBBF8\uC9C0\uC815: \uCD5C\uC2E0 \uBC30\uD3EC, \uACFC\uAC70 id: \uB864\uBC31)
|
|
5063
5704
|
releases \uBC30\uD3EC \uC774\uB825 \uC870\uD68C (release \uBC88\uD638/\uC0C1\uD0DC/production\xB7QA \uD3EC\uC778\uD130)
|
|
5064
5705
|
tunnel <port> \uB85C\uCEEC \uC11C\uBE44\uC2A4\uB97C \uC778\uD130\uB137\uC5D0 \uB178\uCD9C
|
|
5065
|
-
local \
|
|
5706
|
+
local \uC124\uCE58\uAC00 \uD544\uC694\uD55C \uC2A4\uD0AC\uC744 \uB0B4 PC \uC5D0\uC11C \uC4F0\uAC8C \uC5F0\uACB0 (\uB85C\uCEEC \uC2E4\uD589\uAE30: Blender, ZBrush, Python \u2026)
|
|
5707
|
+
--add <GitHub owner/repo[/\uD3F4\uB354][@ref] | \uC8FC\uC18C | \uD3F4\uB354> \uC2A4\uD0AC \uC124\uCE58 (\uC5EC\uB7EC \uBC88 \uAC00\uB2A5)
|
|
5708
|
+
--mcp <\uC774\uB984>="<\uBA85\uB839>" | <\uC774\uB984>=<http \uC8FC\uC18C> \uC2A4\uD0AC\uC774 \uC4F0\uB294 PC \uC758 MCP \uC11C\uBC84 \uCD94\uAC00 (\uC5EC\uB7EC \uBC88 \uAC00\uB2A5,
|
|
5709
|
+
\uC791\uC5C5 \uD3F4\uB354\uC758 connectbase-local.json mcpServers \uC5D0 \uC800\uC7A5. Claude Desktop \uACFC \uAC19\uC740 \uD615\uC2DD)
|
|
5710
|
+
--update \uC124\uCE58\uB41C \uC2A4\uD0AC \uB2E4\uC2DC \uBC1B\uAE30 --dir <\uD3F4\uB354> \uC791\uC5C5 \uD3F4\uB354 (\uAE30\uBCF8 ~/ConnectBaseLocal)
|
|
5711
|
+
\uC608: npx connectbase-client local --add yorusd1/yoruskills
|
|
5066
5712
|
|
|
5067
5713
|
${colors.yellow}\uCF54\uB4DC \uBD84\uC11D (MCP \uD1B5\uD574 \uC0AC\uC6A9):${colors.reset}
|
|
5068
5714
|
AI \uB3C4\uAD6C(Claude, Cursor \uB4F1)\uC5D0\uC11C MCP\uB97C \uC124\uC815\uD558\uBA74 \uB2E4\uC74C \uBD84\uC11D \uAE30\uB2A5\uC744 \uC0AC\uC6A9\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4:
|
|
@@ -5204,8 +5850,8 @@ async function enforceBaseUrlPolicy(baseUrl, opts) {
|
|
|
5204
5850
|
process.exit(1);
|
|
5205
5851
|
}
|
|
5206
5852
|
function isOutsideProject(dir, root) {
|
|
5207
|
-
const relative3 =
|
|
5208
|
-
return relative3 === ".." || relative3.startsWith(`..${
|
|
5853
|
+
const relative3 = path5.relative(path5.resolve(root), path5.resolve(root, dir));
|
|
5854
|
+
return relative3 === ".." || relative3.startsWith(`..${path5.sep}`) || path5.isAbsolute(relative3);
|
|
5209
5855
|
}
|
|
5210
5856
|
function parseArgs(args) {
|
|
5211
5857
|
const result = {
|
|
@@ -5241,6 +5887,12 @@ function parseArgs(args) {
|
|
|
5241
5887
|
result.options.dir = args[++i];
|
|
5242
5888
|
} else if (arg === "--port") {
|
|
5243
5889
|
result.options.port = args[++i];
|
|
5890
|
+
} else if (arg === "--add") {
|
|
5891
|
+
result.options.add = result.options.add ? `${result.options.add},${args[++i]}` : args[++i];
|
|
5892
|
+
} else if (arg === "--update") {
|
|
5893
|
+
result.options.update = "true";
|
|
5894
|
+
} else if (arg === "--mcp") {
|
|
5895
|
+
result.options.mcp = result.options.mcp ? `${result.options.mcp}\0${args[++i]}` : args[++i];
|
|
5244
5896
|
} else if (arg === "--force") {
|
|
5245
5897
|
result.options.force = "true";
|
|
5246
5898
|
} else if (arg === "-y" || arg === "--yes") {
|
|
@@ -5355,8 +6007,8 @@ async function main() {
|
|
|
5355
6007
|
if (parsed.options.skipDocs !== "true") {
|
|
5356
6008
|
try {
|
|
5357
6009
|
const docsRoot = getGitRoot() || getProjectRoot();
|
|
5358
|
-
if (
|
|
5359
|
-
|
|
6010
|
+
if (fs5.existsSync(
|
|
6011
|
+
path5.join(docsRoot, ".claude", "docs", DOCS_MANIFEST_FILE)
|
|
5360
6012
|
)) {
|
|
5361
6013
|
const refreshed = await downloadDocs(docsRoot, {
|
|
5362
6014
|
quiet: true,
|
|
@@ -5399,7 +6051,10 @@ async function main() {
|
|
|
5399
6051
|
dir: parsed.options.dir,
|
|
5400
6052
|
port,
|
|
5401
6053
|
appId: parsed.options.appId,
|
|
5402
|
-
force: parsed.options.force === "true"
|
|
6054
|
+
force: parsed.options.force === "true",
|
|
6055
|
+
add: parsed.options.add,
|
|
6056
|
+
update: parsed.options.update === "true",
|
|
6057
|
+
mcp: parsed.options.mcp
|
|
5403
6058
|
},
|
|
5404
6059
|
(p, c, o) => startTunnel(p, c, o),
|
|
5405
6060
|
{ info, success, warn }
|