@dosu/cli 0.6.0 → 0.8.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/bin/dosu.js +395 -252
- package/package.json +1 -1
package/bin/dosu.js
CHANGED
|
@@ -2118,6 +2118,192 @@ function emptyConfig() {
|
|
|
2118
2118
|
var MODE_OSS = "oss";
|
|
2119
2119
|
var init_config = () => {};
|
|
2120
2120
|
|
|
2121
|
+
// node_modules/picocolors/picocolors.js
|
|
2122
|
+
var require_picocolors = __commonJS((exports, module) => {
|
|
2123
|
+
var p = process || {};
|
|
2124
|
+
var argv = p.argv || [];
|
|
2125
|
+
var env = p.env || {};
|
|
2126
|
+
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
2127
|
+
var formatter = (open, close, replace = open) => (input) => {
|
|
2128
|
+
let string = "" + input, index = string.indexOf(close, open.length);
|
|
2129
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
2130
|
+
};
|
|
2131
|
+
var replaceClose = (string, close, replace, index) => {
|
|
2132
|
+
let result = "", cursor = 0;
|
|
2133
|
+
do {
|
|
2134
|
+
result += string.substring(cursor, index) + replace;
|
|
2135
|
+
cursor = index + close.length;
|
|
2136
|
+
index = string.indexOf(close, cursor);
|
|
2137
|
+
} while (~index);
|
|
2138
|
+
return result + string.substring(cursor);
|
|
2139
|
+
};
|
|
2140
|
+
var createColors = (enabled = isColorSupported) => {
|
|
2141
|
+
let f = enabled ? formatter : () => String;
|
|
2142
|
+
return {
|
|
2143
|
+
isColorSupported: enabled,
|
|
2144
|
+
reset: f("\x1B[0m", "\x1B[0m"),
|
|
2145
|
+
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
2146
|
+
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
2147
|
+
italic: f("\x1B[3m", "\x1B[23m"),
|
|
2148
|
+
underline: f("\x1B[4m", "\x1B[24m"),
|
|
2149
|
+
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
2150
|
+
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
2151
|
+
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
2152
|
+
black: f("\x1B[30m", "\x1B[39m"),
|
|
2153
|
+
red: f("\x1B[31m", "\x1B[39m"),
|
|
2154
|
+
green: f("\x1B[32m", "\x1B[39m"),
|
|
2155
|
+
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
2156
|
+
blue: f("\x1B[34m", "\x1B[39m"),
|
|
2157
|
+
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
2158
|
+
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
2159
|
+
white: f("\x1B[37m", "\x1B[39m"),
|
|
2160
|
+
gray: f("\x1B[90m", "\x1B[39m"),
|
|
2161
|
+
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
2162
|
+
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
2163
|
+
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
2164
|
+
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
2165
|
+
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
2166
|
+
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
2167
|
+
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
2168
|
+
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
2169
|
+
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
2170
|
+
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
2171
|
+
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
2172
|
+
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
2173
|
+
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
2174
|
+
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
2175
|
+
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
2176
|
+
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
2177
|
+
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
2178
|
+
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
2179
|
+
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
2180
|
+
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
2181
|
+
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
2182
|
+
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
2183
|
+
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
2184
|
+
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
2185
|
+
};
|
|
2186
|
+
};
|
|
2187
|
+
module.exports = createColors();
|
|
2188
|
+
module.exports.createColors = createColors;
|
|
2189
|
+
});
|
|
2190
|
+
|
|
2191
|
+
// src/version/version.ts
|
|
2192
|
+
function getVersionString() {
|
|
2193
|
+
return `v${VERSION}`;
|
|
2194
|
+
}
|
|
2195
|
+
var VERSION = "0.8.0";
|
|
2196
|
+
|
|
2197
|
+
// src/debug/logger.ts
|
|
2198
|
+
import {
|
|
2199
|
+
appendFileSync,
|
|
2200
|
+
existsSync as existsSync2,
|
|
2201
|
+
mkdirSync as mkdirSync2,
|
|
2202
|
+
readFileSync as readFileSync2,
|
|
2203
|
+
statSync,
|
|
2204
|
+
writeFileSync as writeFileSync2
|
|
2205
|
+
} from "node:fs";
|
|
2206
|
+
import { join as join2 } from "node:path";
|
|
2207
|
+
function ensureInit() {
|
|
2208
|
+
if (!initialized) {
|
|
2209
|
+
initLogger({});
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
function resolveLogPath() {
|
|
2213
|
+
if (!logFilePath) {
|
|
2214
|
+
const dir = getConfigDir();
|
|
2215
|
+
if (!existsSync2(dir)) {
|
|
2216
|
+
mkdirSync2(dir, { recursive: true, mode: 448 });
|
|
2217
|
+
}
|
|
2218
|
+
logFilePath = join2(dir, LOG_FILENAME);
|
|
2219
|
+
}
|
|
2220
|
+
return logFilePath;
|
|
2221
|
+
}
|
|
2222
|
+
function truncateIfNeeded() {
|
|
2223
|
+
try {
|
|
2224
|
+
const path = resolveLogPath();
|
|
2225
|
+
if (!existsSync2(path))
|
|
2226
|
+
return;
|
|
2227
|
+
const stat = statSync(path);
|
|
2228
|
+
if (stat.size <= MAX_LOG_SIZE)
|
|
2229
|
+
return;
|
|
2230
|
+
const content = readFileSync2(path);
|
|
2231
|
+
const start = content.length - TRUNCATE_KEEP;
|
|
2232
|
+
let lineStart = start;
|
|
2233
|
+
while (lineStart < content.length && content[lineStart] !== 10) {
|
|
2234
|
+
lineStart++;
|
|
2235
|
+
}
|
|
2236
|
+
lineStart = Math.min(lineStart + 1, content.length);
|
|
2237
|
+
writeFileSync2(path, content.subarray(lineStart), { mode: 384 });
|
|
2238
|
+
} catch {}
|
|
2239
|
+
}
|
|
2240
|
+
function writeSessionHeader() {
|
|
2241
|
+
try {
|
|
2242
|
+
const now = new Date().toISOString();
|
|
2243
|
+
const header = `
|
|
2244
|
+
════════════════════════════════════════
|
|
2245
|
+
` + `Session: ${now} | v${VERSION} | ${process.platform} ${process.arch} | node ${process.version}
|
|
2246
|
+
` + `════════════════════════════════════════
|
|
2247
|
+
`;
|
|
2248
|
+
appendFileSync(resolveLogPath(), header, { mode: 384 });
|
|
2249
|
+
} catch {}
|
|
2250
|
+
}
|
|
2251
|
+
function initLogger(opts) {
|
|
2252
|
+
debugToConsole = opts.debug ?? false;
|
|
2253
|
+
try {
|
|
2254
|
+
resolveLogPath();
|
|
2255
|
+
truncateIfNeeded();
|
|
2256
|
+
writeSessionHeader();
|
|
2257
|
+
} catch {}
|
|
2258
|
+
initialized = true;
|
|
2259
|
+
}
|
|
2260
|
+
function writeEntry(level, mod, message) {
|
|
2261
|
+
ensureInit();
|
|
2262
|
+
const timestamp = new Date().toISOString();
|
|
2263
|
+
const line = `[${timestamp}] [${level}] [${mod}] ${message}
|
|
2264
|
+
`;
|
|
2265
|
+
try {
|
|
2266
|
+
appendFileSync(resolveLogPath(), line, { mode: 384 });
|
|
2267
|
+
} catch {}
|
|
2268
|
+
if (debugToConsole) {
|
|
2269
|
+
const colorize = {
|
|
2270
|
+
DEBUG: import_picocolors.default.dim,
|
|
2271
|
+
INFO: import_picocolors.default.cyan,
|
|
2272
|
+
WARN: import_picocolors.default.yellow,
|
|
2273
|
+
ERROR: import_picocolors.default.red
|
|
2274
|
+
}[level];
|
|
2275
|
+
console.error(colorize(line.trimEnd()));
|
|
2276
|
+
}
|
|
2277
|
+
}
|
|
2278
|
+
var import_picocolors, MAX_LOG_SIZE = 1048576, TRUNCATE_KEEP = 524288, LOG_FILENAME = "debug.log", initialized = false, debugToConsole = false, logFilePath = null, logger;
|
|
2279
|
+
var init_logger = __esm(() => {
|
|
2280
|
+
init_config();
|
|
2281
|
+
import_picocolors = __toESM(require_picocolors(), 1);
|
|
2282
|
+
logger = {
|
|
2283
|
+
init: initLogger,
|
|
2284
|
+
getLogPath() {
|
|
2285
|
+
return resolveLogPath();
|
|
2286
|
+
},
|
|
2287
|
+
debug(mod, message) {
|
|
2288
|
+
writeEntry("DEBUG", mod, message);
|
|
2289
|
+
},
|
|
2290
|
+
info(mod, message) {
|
|
2291
|
+
writeEntry("INFO", mod, message);
|
|
2292
|
+
},
|
|
2293
|
+
warn(mod, message) {
|
|
2294
|
+
writeEntry("WARN", mod, message);
|
|
2295
|
+
},
|
|
2296
|
+
error(mod, message) {
|
|
2297
|
+
writeEntry("ERROR", mod, message);
|
|
2298
|
+
},
|
|
2299
|
+
_resetForTesting() {
|
|
2300
|
+
initialized = false;
|
|
2301
|
+
debugToConsole = false;
|
|
2302
|
+
logFilePath = null;
|
|
2303
|
+
}
|
|
2304
|
+
};
|
|
2305
|
+
});
|
|
2306
|
+
|
|
2121
2307
|
// src/config/constants.ts
|
|
2122
2308
|
function getWebAppURL() {
|
|
2123
2309
|
return "https://app.dosu.dev";
|
|
@@ -2133,7 +2319,7 @@ function getSupabaseAnonKey() {
|
|
|
2133
2319
|
}
|
|
2134
2320
|
|
|
2135
2321
|
// src/mcp/config-helpers.ts
|
|
2136
|
-
import { existsSync as
|
|
2322
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "node:fs";
|
|
2137
2323
|
import { dirname } from "node:path";
|
|
2138
2324
|
function mcpURL(deploymentID) {
|
|
2139
2325
|
return `${getBackendURL()}/v1/mcp/deployments/${deploymentID}`;
|
|
@@ -2145,9 +2331,9 @@ function mcpHeaders(apiKey) {
|
|
|
2145
2331
|
return { "X-Dosu-API-Key": apiKey };
|
|
2146
2332
|
}
|
|
2147
2333
|
function loadJSONConfig(path) {
|
|
2148
|
-
if (!
|
|
2334
|
+
if (!existsSync3(path))
|
|
2149
2335
|
return {};
|
|
2150
|
-
let data =
|
|
2336
|
+
let data = readFileSync3(path, "utf-8").trim();
|
|
2151
2337
|
if (!data)
|
|
2152
2338
|
return {};
|
|
2153
2339
|
if (path.endsWith(".jsonc")) {
|
|
@@ -2207,10 +2393,10 @@ function stripJSONComments(data) {
|
|
|
2207
2393
|
}
|
|
2208
2394
|
function saveJSONConfig(path, cfg) {
|
|
2209
2395
|
const dir = dirname(path);
|
|
2210
|
-
if (!
|
|
2211
|
-
|
|
2396
|
+
if (!existsSync3(dir)) {
|
|
2397
|
+
mkdirSync3(dir, { recursive: true });
|
|
2212
2398
|
}
|
|
2213
|
-
|
|
2399
|
+
writeFileSync3(path, JSON.stringify(cfg, null, 2));
|
|
2214
2400
|
}
|
|
2215
2401
|
function isJSONKeyConfigured(configPath, topLevelKey) {
|
|
2216
2402
|
const cfg = loadJSONConfig(configPath);
|
|
@@ -2245,21 +2431,21 @@ function removeJSONServer(configPath, topKey) {
|
|
|
2245
2431
|
var init_config_helpers = () => {};
|
|
2246
2432
|
|
|
2247
2433
|
// src/mcp/detect.ts
|
|
2248
|
-
import { existsSync as
|
|
2434
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
2249
2435
|
import { homedir, platform } from "node:os";
|
|
2250
|
-
import { join as
|
|
2436
|
+
import { join as join3 } from "node:path";
|
|
2251
2437
|
function isInstalled(paths) {
|
|
2252
|
-
return paths.some((p) =>
|
|
2438
|
+
return paths.some((p) => existsSync4(expandHome(p)));
|
|
2253
2439
|
}
|
|
2254
2440
|
function expandHome(path) {
|
|
2255
2441
|
if (!path.startsWith("~"))
|
|
2256
2442
|
return path;
|
|
2257
|
-
return
|
|
2443
|
+
return join3(homedir(), path.slice(1));
|
|
2258
2444
|
}
|
|
2259
2445
|
function appSupportDir() {
|
|
2260
2446
|
switch (platform()) {
|
|
2261
2447
|
case "darwin": {
|
|
2262
|
-
return
|
|
2448
|
+
return join3(homedir(), "Library", "Application Support");
|
|
2263
2449
|
}
|
|
2264
2450
|
case "win32": {
|
|
2265
2451
|
return process.env.APPDATA ?? "";
|
|
@@ -2268,7 +2454,7 @@ function appSupportDir() {
|
|
|
2268
2454
|
const xdg = process.env.XDG_CONFIG_HOME;
|
|
2269
2455
|
if (xdg)
|
|
2270
2456
|
return xdg;
|
|
2271
|
-
return
|
|
2457
|
+
return join3(homedir(), ".config");
|
|
2272
2458
|
}
|
|
2273
2459
|
}
|
|
2274
2460
|
}
|
|
@@ -2349,7 +2535,7 @@ var init_antigravity = __esm(() => {
|
|
|
2349
2535
|
});
|
|
2350
2536
|
|
|
2351
2537
|
// src/mcp/providers/claude.ts
|
|
2352
|
-
import { join as
|
|
2538
|
+
import { join as join4 } from "node:path";
|
|
2353
2539
|
var ClaudeProvider = () => createJSONProvider({
|
|
2354
2540
|
providerName: "Claude Code",
|
|
2355
2541
|
providerID: "claude",
|
|
@@ -2358,22 +2544,22 @@ var ClaudeProvider = () => createJSONProvider({
|
|
|
2358
2544
|
paths: ["~/.claude"],
|
|
2359
2545
|
globalPath: "~/.claude.json",
|
|
2360
2546
|
topKey: "mcpServers",
|
|
2361
|
-
localConfigPath: (cwd) =>
|
|
2547
|
+
localConfigPath: (cwd) => join4(cwd, ".mcp.json")
|
|
2362
2548
|
});
|
|
2363
2549
|
var init_claude = __esm(() => {
|
|
2364
2550
|
init_base();
|
|
2365
2551
|
});
|
|
2366
2552
|
|
|
2367
2553
|
// src/mcp/providers/claude-desktop.ts
|
|
2368
|
-
import { join as
|
|
2554
|
+
import { join as join5 } from "node:path";
|
|
2369
2555
|
var ClaudeDesktopProvider = () => ({
|
|
2370
2556
|
name: () => "Claude Desktop",
|
|
2371
2557
|
id: () => "claude-desktop",
|
|
2372
2558
|
supportsLocal: () => false,
|
|
2373
2559
|
priority: () => 2,
|
|
2374
|
-
detectPaths: () => [
|
|
2375
|
-
isInstalled: () => isInstalled([
|
|
2376
|
-
globalConfigPath: () =>
|
|
2560
|
+
detectPaths: () => [join5(appSupportDir(), "Claude")],
|
|
2561
|
+
isInstalled: () => isInstalled([join5(appSupportDir(), "Claude")]),
|
|
2562
|
+
globalConfigPath: () => join5(appSupportDir(), "Claude", "claude_desktop_config.json"),
|
|
2377
2563
|
isConfigured: () => false,
|
|
2378
2564
|
install() {
|
|
2379
2565
|
throw new Error("this tool only supports local (stdio) servers and cannot be configured for remote MCP");
|
|
@@ -2387,14 +2573,14 @@ var init_claude_desktop = __esm(() => {
|
|
|
2387
2573
|
});
|
|
2388
2574
|
|
|
2389
2575
|
// src/mcp/providers/cline.ts
|
|
2390
|
-
import { join as
|
|
2391
|
-
var extensionDir = () =>
|
|
2576
|
+
import { join as join6 } from "node:path";
|
|
2577
|
+
var extensionDir = () => join6(appSupportDir(), "Code", "User", "globalStorage", "saoudrizwan.claude-dev"), ClineProvider = () => createJSONProvider({
|
|
2392
2578
|
providerName: "Cline",
|
|
2393
2579
|
providerID: "cline",
|
|
2394
2580
|
local: false,
|
|
2395
2581
|
priorityValue: 11,
|
|
2396
2582
|
paths: [extensionDir()],
|
|
2397
|
-
globalPath:
|
|
2583
|
+
globalPath: join6(extensionDir(), "settings", "cline_mcp_settings.json"),
|
|
2398
2584
|
topKey: "mcpServers",
|
|
2399
2585
|
buildServer: (cfg) => ({
|
|
2400
2586
|
url: mcpURL(cfg.deployment_id),
|
|
@@ -2410,7 +2596,7 @@ var init_cline = __esm(() => {
|
|
|
2410
2596
|
});
|
|
2411
2597
|
|
|
2412
2598
|
// src/mcp/providers/cline-cli.ts
|
|
2413
|
-
import { join as
|
|
2599
|
+
import { join as join7 } from "node:path";
|
|
2414
2600
|
function clineDir() {
|
|
2415
2601
|
return process.env.CLINE_DIR ?? expandHome("~/.cline");
|
|
2416
2602
|
}
|
|
@@ -2420,7 +2606,7 @@ var ClineCliProvider = () => createJSONProvider({
|
|
|
2420
2606
|
local: false,
|
|
2421
2607
|
priorityValue: 12,
|
|
2422
2608
|
paths: [clineDir()],
|
|
2423
|
-
globalPath:
|
|
2609
|
+
globalPath: join7(clineDir(), "data", "settings", "cline_mcp_settings.json"),
|
|
2424
2610
|
topKey: "mcpServers",
|
|
2425
2611
|
buildServer: (cfg) => ({
|
|
2426
2612
|
url: mcpURL(cfg.deployment_id),
|
|
@@ -2436,26 +2622,26 @@ var init_cline_cli = __esm(() => {
|
|
|
2436
2622
|
});
|
|
2437
2623
|
|
|
2438
2624
|
// src/mcp/providers/codex.ts
|
|
2439
|
-
import { existsSync as
|
|
2440
|
-
import { dirname as dirname2, join as
|
|
2625
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync4, readFileSync as readFileSync4, writeFileSync as writeFileSync4 } from "node:fs";
|
|
2626
|
+
import { dirname as dirname2, join as join8 } from "node:path";
|
|
2441
2627
|
function codexHome() {
|
|
2442
2628
|
return process.env.CODEX_HOME ?? expandHome("~/.codex");
|
|
2443
2629
|
}
|
|
2444
2630
|
function getConfigPath2(global) {
|
|
2445
2631
|
if (global)
|
|
2446
|
-
return
|
|
2447
|
-
return
|
|
2632
|
+
return join8(codexHome(), "config.toml");
|
|
2633
|
+
return join8(process.cwd(), ".codex", "config.toml");
|
|
2448
2634
|
}
|
|
2449
2635
|
function readTOML(path) {
|
|
2450
|
-
if (!
|
|
2636
|
+
if (!existsSync5(path))
|
|
2451
2637
|
return "";
|
|
2452
|
-
return
|
|
2638
|
+
return readFileSync4(path, "utf-8");
|
|
2453
2639
|
}
|
|
2454
2640
|
function writeTOML(path, content) {
|
|
2455
2641
|
const dir = dirname2(path);
|
|
2456
|
-
if (!
|
|
2457
|
-
|
|
2458
|
-
|
|
2642
|
+
if (!existsSync5(dir))
|
|
2643
|
+
mkdirSync4(dir, { recursive: true });
|
|
2644
|
+
writeFileSync4(path, content);
|
|
2459
2645
|
}
|
|
2460
2646
|
function installDosuToTOML(path, cfg) {
|
|
2461
2647
|
let content = readTOML(path);
|
|
@@ -2503,9 +2689,9 @@ var CodexProvider = () => ({
|
|
|
2503
2689
|
priority: () => 8,
|
|
2504
2690
|
detectPaths: () => ["~/.codex"],
|
|
2505
2691
|
isInstalled: () => isInstalled(["~/.codex"]),
|
|
2506
|
-
globalConfigPath: () =>
|
|
2692
|
+
globalConfigPath: () => join8(codexHome(), "config.toml"),
|
|
2507
2693
|
isConfigured: () => {
|
|
2508
|
-
const content = readTOML(
|
|
2694
|
+
const content = readTOML(join8(codexHome(), "config.toml"));
|
|
2509
2695
|
return content.includes("[mcp_servers.dosu]");
|
|
2510
2696
|
},
|
|
2511
2697
|
install(cfg, global) {
|
|
@@ -2527,10 +2713,10 @@ var init_codex = __esm(() => {
|
|
|
2527
2713
|
});
|
|
2528
2714
|
|
|
2529
2715
|
// src/mcp/providers/copilot.ts
|
|
2530
|
-
import { join as
|
|
2716
|
+
import { join as join9 } from "node:path";
|
|
2531
2717
|
function globalPath() {
|
|
2532
2718
|
if (process.env.XDG_CONFIG_HOME) {
|
|
2533
|
-
return
|
|
2719
|
+
return join9(process.env.XDG_CONFIG_HOME, "mcp-config.json");
|
|
2534
2720
|
}
|
|
2535
2721
|
return expandHome("~/.copilot/mcp-config.json");
|
|
2536
2722
|
}
|
|
@@ -2556,7 +2742,7 @@ var CopilotProvider = () => ({
|
|
|
2556
2742
|
};
|
|
2557
2743
|
installJSONServer(globalPath(), "mcpServers", server);
|
|
2558
2744
|
} else {
|
|
2559
|
-
const configPath =
|
|
2745
|
+
const configPath = join9(process.cwd(), ".vscode", "mcp.json");
|
|
2560
2746
|
const server = {
|
|
2561
2747
|
type: "http",
|
|
2562
2748
|
url,
|
|
@@ -2569,7 +2755,7 @@ var CopilotProvider = () => ({
|
|
|
2569
2755
|
if (global) {
|
|
2570
2756
|
removeJSONServer(globalPath(), "mcpServers");
|
|
2571
2757
|
} else {
|
|
2572
|
-
const configPath =
|
|
2758
|
+
const configPath = join9(process.cwd(), ".vscode", "mcp.json");
|
|
2573
2759
|
removeJSONServer(configPath, "servers");
|
|
2574
2760
|
}
|
|
2575
2761
|
}
|
|
@@ -2581,7 +2767,7 @@ var init_copilot = __esm(() => {
|
|
|
2581
2767
|
});
|
|
2582
2768
|
|
|
2583
2769
|
// src/mcp/providers/cursor.ts
|
|
2584
|
-
import { join as
|
|
2770
|
+
import { join as join10 } from "node:path";
|
|
2585
2771
|
var CursorProvider = () => createJSONProvider({
|
|
2586
2772
|
providerName: "Cursor",
|
|
2587
2773
|
providerID: "cursor",
|
|
@@ -2594,7 +2780,7 @@ var CursorProvider = () => createJSONProvider({
|
|
|
2594
2780
|
url: mcpURL(cfg.deployment_id),
|
|
2595
2781
|
headers: mcpHeaders(cfg.api_key)
|
|
2596
2782
|
}),
|
|
2597
|
-
localConfigPath: (cwd) =>
|
|
2783
|
+
localConfigPath: (cwd) => join10(cwd, ".cursor", "mcp.json")
|
|
2598
2784
|
});
|
|
2599
2785
|
var init_cursor = __esm(() => {
|
|
2600
2786
|
init_config_helpers();
|
|
@@ -2602,7 +2788,7 @@ var init_cursor = __esm(() => {
|
|
|
2602
2788
|
});
|
|
2603
2789
|
|
|
2604
2790
|
// src/mcp/providers/gemini.ts
|
|
2605
|
-
import { join as
|
|
2791
|
+
import { join as join11 } from "node:path";
|
|
2606
2792
|
var GeminiProvider = () => createJSONProvider({
|
|
2607
2793
|
providerName: "Gemini CLI",
|
|
2608
2794
|
providerID: "gemini",
|
|
@@ -2611,7 +2797,7 @@ var GeminiProvider = () => createJSONProvider({
|
|
|
2611
2797
|
paths: ["~/.gemini"],
|
|
2612
2798
|
globalPath: "~/.gemini/settings.json",
|
|
2613
2799
|
topKey: "mcpServers",
|
|
2614
|
-
localConfigPath: (cwd) =>
|
|
2800
|
+
localConfigPath: (cwd) => join11(cwd, ".gemini", "settings.json")
|
|
2615
2801
|
});
|
|
2616
2802
|
var init_gemini = __esm(() => {
|
|
2617
2803
|
init_base();
|
|
@@ -2642,14 +2828,14 @@ var init_manual = __esm(() => {
|
|
|
2642
2828
|
});
|
|
2643
2829
|
|
|
2644
2830
|
// src/mcp/providers/mcporter.ts
|
|
2645
|
-
import { existsSync as
|
|
2646
|
-
import { join as
|
|
2831
|
+
import { existsSync as existsSync6 } from "node:fs";
|
|
2832
|
+
import { join as join12 } from "node:path";
|
|
2647
2833
|
function resolveGlobalConfigPath() {
|
|
2648
2834
|
const jsonPath = expandHome("~/.mcporter/mcporter.json");
|
|
2649
|
-
if (
|
|
2835
|
+
if (existsSync6(jsonPath))
|
|
2650
2836
|
return jsonPath;
|
|
2651
2837
|
const jsoncPath = expandHome("~/.mcporter/mcporter.jsonc");
|
|
2652
|
-
if (
|
|
2838
|
+
if (existsSync6(jsoncPath))
|
|
2653
2839
|
return jsoncPath;
|
|
2654
2840
|
return jsonPath;
|
|
2655
2841
|
}
|
|
@@ -2665,7 +2851,7 @@ var MCPorterProvider = () => ({
|
|
|
2665
2851
|
install(cfg, global) {
|
|
2666
2852
|
if (cfg.mode !== MODE_OSS && !cfg.deployment_id)
|
|
2667
2853
|
throw new Error("deployment ID is required");
|
|
2668
|
-
const configPath = global ? resolveGlobalConfigPath() :
|
|
2854
|
+
const configPath = global ? resolveGlobalConfigPath() : join12(process.cwd(), "config", "mcporter.json");
|
|
2669
2855
|
const server = {
|
|
2670
2856
|
type: "http",
|
|
2671
2857
|
url: cfg.mode === MODE_OSS ? mcpBaseURL() : mcpURL(cfg.deployment_id),
|
|
@@ -2674,7 +2860,7 @@ var MCPorterProvider = () => ({
|
|
|
2674
2860
|
installJSONServer(configPath, "mcpServers", server);
|
|
2675
2861
|
},
|
|
2676
2862
|
remove(global) {
|
|
2677
|
-
const configPath = global ? resolveGlobalConfigPath() :
|
|
2863
|
+
const configPath = global ? resolveGlobalConfigPath() : join12(process.cwd(), "config", "mcporter.json");
|
|
2678
2864
|
removeJSONServer(configPath, "mcpServers");
|
|
2679
2865
|
}
|
|
2680
2866
|
});
|
|
@@ -2685,7 +2871,7 @@ var init_mcporter = __esm(() => {
|
|
|
2685
2871
|
});
|
|
2686
2872
|
|
|
2687
2873
|
// src/mcp/providers/opencode.ts
|
|
2688
|
-
import { join as
|
|
2874
|
+
import { join as join13 } from "node:path";
|
|
2689
2875
|
var OpenCodeProvider = () => createJSONProvider({
|
|
2690
2876
|
providerName: "OpenCode",
|
|
2691
2877
|
providerID: "opencode",
|
|
@@ -2700,7 +2886,7 @@ var OpenCodeProvider = () => createJSONProvider({
|
|
|
2700
2886
|
enabled: true,
|
|
2701
2887
|
headers: mcpHeaders(cfg.api_key)
|
|
2702
2888
|
}),
|
|
2703
|
-
localConfigPath: (cwd) =>
|
|
2889
|
+
localConfigPath: (cwd) => join13(cwd, "opencode.json")
|
|
2704
2890
|
});
|
|
2705
2891
|
var init_opencode = __esm(() => {
|
|
2706
2892
|
init_config_helpers();
|
|
@@ -2708,16 +2894,16 @@ var init_opencode = __esm(() => {
|
|
|
2708
2894
|
});
|
|
2709
2895
|
|
|
2710
2896
|
// src/mcp/providers/vscode.ts
|
|
2711
|
-
import { join as
|
|
2897
|
+
import { join as join14 } from "node:path";
|
|
2712
2898
|
var VSCodeProvider = () => createJSONProvider({
|
|
2713
2899
|
providerName: "VS Code",
|
|
2714
2900
|
providerID: "vscode",
|
|
2715
2901
|
local: true,
|
|
2716
2902
|
priorityValue: 6,
|
|
2717
|
-
paths: [
|
|
2718
|
-
globalPath:
|
|
2903
|
+
paths: [join14(appSupportDir(), "Code")],
|
|
2904
|
+
globalPath: join14(appSupportDir(), "Code", "User", "mcp.json"),
|
|
2719
2905
|
topKey: "servers",
|
|
2720
|
-
localConfigPath: (cwd) =>
|
|
2906
|
+
localConfigPath: (cwd) => join14(cwd, ".vscode", "mcp.json")
|
|
2721
2907
|
});
|
|
2722
2908
|
var init_vscode = __esm(() => {
|
|
2723
2909
|
init_detect();
|
|
@@ -2726,14 +2912,14 @@ var init_vscode = __esm(() => {
|
|
|
2726
2912
|
|
|
2727
2913
|
// src/mcp/providers/windsurf.ts
|
|
2728
2914
|
import { homedir as homedir2 } from "node:os";
|
|
2729
|
-
import { join as
|
|
2915
|
+
import { join as join15 } from "node:path";
|
|
2730
2916
|
var WindsurfProvider = () => createJSONProvider({
|
|
2731
2917
|
providerName: "Windsurf",
|
|
2732
2918
|
providerID: "windsurf",
|
|
2733
2919
|
local: false,
|
|
2734
2920
|
priorityValue: 9,
|
|
2735
|
-
paths: [
|
|
2736
|
-
globalPath:
|
|
2921
|
+
paths: [join15(homedir2(), ".codeium", "windsurf")],
|
|
2922
|
+
globalPath: join15(homedir2(), ".codeium", "windsurf", "mcp_config.json"),
|
|
2737
2923
|
topKey: "mcpServers"
|
|
2738
2924
|
});
|
|
2739
2925
|
var init_windsurf = __esm(() => {
|
|
@@ -2742,12 +2928,12 @@ var init_windsurf = __esm(() => {
|
|
|
2742
2928
|
|
|
2743
2929
|
// src/mcp/providers/zed.ts
|
|
2744
2930
|
import { platform as platform2 } from "node:os";
|
|
2745
|
-
import { join as
|
|
2931
|
+
import { join as join16 } from "node:path";
|
|
2746
2932
|
function zedConfigDir() {
|
|
2747
2933
|
const os = platform2();
|
|
2748
2934
|
if (os === "darwin" || os === "win32")
|
|
2749
|
-
return
|
|
2750
|
-
return
|
|
2935
|
+
return join16(appSupportDir(), "Zed");
|
|
2936
|
+
return join16(appSupportDir(), "zed");
|
|
2751
2937
|
}
|
|
2752
2938
|
var ZedProvider = () => createJSONProvider({
|
|
2753
2939
|
providerName: "Zed",
|
|
@@ -2755,7 +2941,7 @@ var ZedProvider = () => createJSONProvider({
|
|
|
2755
2941
|
local: true,
|
|
2756
2942
|
priorityValue: 10,
|
|
2757
2943
|
paths: [zedConfigDir()],
|
|
2758
|
-
globalPath:
|
|
2944
|
+
globalPath: join16(zedConfigDir(), "settings.json"),
|
|
2759
2945
|
topKey: "context_servers",
|
|
2760
2946
|
buildServer: (cfg) => ({
|
|
2761
2947
|
source: "custom",
|
|
@@ -2763,7 +2949,7 @@ var ZedProvider = () => createJSONProvider({
|
|
|
2763
2949
|
url: mcpURL(cfg.deployment_id),
|
|
2764
2950
|
headers: mcpHeaders(cfg.api_key)
|
|
2765
2951
|
}),
|
|
2766
|
-
localConfigPath: (cwd) =>
|
|
2952
|
+
localConfigPath: (cwd) => join16(cwd, ".zed", "settings.json")
|
|
2767
2953
|
});
|
|
2768
2954
|
var init_zed = __esm(() => {
|
|
2769
2955
|
init_config_helpers();
|
|
@@ -2772,13 +2958,6 @@ var init_zed = __esm(() => {
|
|
|
2772
2958
|
});
|
|
2773
2959
|
|
|
2774
2960
|
// src/mcp/providers.ts
|
|
2775
|
-
var exports_providers = {};
|
|
2776
|
-
__export(exports_providers, {
|
|
2777
|
-
getProvider: () => getProvider,
|
|
2778
|
-
detectInstalledProviders: () => detectInstalledProviders,
|
|
2779
|
-
allSetupProviders: () => allSetupProviders,
|
|
2780
|
-
allProviders: () => allProviders
|
|
2781
|
-
});
|
|
2782
2961
|
function allProviders() {
|
|
2783
2962
|
return [
|
|
2784
2963
|
ClaudeProvider(),
|
|
@@ -2802,9 +2981,6 @@ function allSetupProviders() {
|
|
|
2802
2981
|
const providers = allProviders().filter((p) => ("detectPaths" in p) && ("isInstalled" in p));
|
|
2803
2982
|
return providers.sort((a, b) => a.priority() - b.priority());
|
|
2804
2983
|
}
|
|
2805
|
-
function detectInstalledProviders() {
|
|
2806
|
-
return allSetupProviders().filter((p) => p.isInstalled());
|
|
2807
|
-
}
|
|
2808
2984
|
function getProvider(toolID) {
|
|
2809
2985
|
const provider = allProviders().find((p) => p.id() === toolID);
|
|
2810
2986
|
if (!provider)
|
|
@@ -2887,76 +3063,6 @@ var require_src = __commonJS((exports, module) => {
|
|
|
2887
3063
|
module.exports = { cursor, scroll, erase, beep };
|
|
2888
3064
|
});
|
|
2889
3065
|
|
|
2890
|
-
// node_modules/picocolors/picocolors.js
|
|
2891
|
-
var require_picocolors = __commonJS((exports, module) => {
|
|
2892
|
-
var p = process || {};
|
|
2893
|
-
var argv = p.argv || [];
|
|
2894
|
-
var env = p.env || {};
|
|
2895
|
-
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
2896
|
-
var formatter = (open, close, replace = open) => (input) => {
|
|
2897
|
-
let string = "" + input, index = string.indexOf(close, open.length);
|
|
2898
|
-
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
2899
|
-
};
|
|
2900
|
-
var replaceClose = (string, close, replace, index) => {
|
|
2901
|
-
let result = "", cursor = 0;
|
|
2902
|
-
do {
|
|
2903
|
-
result += string.substring(cursor, index) + replace;
|
|
2904
|
-
cursor = index + close.length;
|
|
2905
|
-
index = string.indexOf(close, cursor);
|
|
2906
|
-
} while (~index);
|
|
2907
|
-
return result + string.substring(cursor);
|
|
2908
|
-
};
|
|
2909
|
-
var createColors = (enabled = isColorSupported) => {
|
|
2910
|
-
let f = enabled ? formatter : () => String;
|
|
2911
|
-
return {
|
|
2912
|
-
isColorSupported: enabled,
|
|
2913
|
-
reset: f("\x1B[0m", "\x1B[0m"),
|
|
2914
|
-
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
2915
|
-
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
2916
|
-
italic: f("\x1B[3m", "\x1B[23m"),
|
|
2917
|
-
underline: f("\x1B[4m", "\x1B[24m"),
|
|
2918
|
-
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
2919
|
-
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
2920
|
-
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
2921
|
-
black: f("\x1B[30m", "\x1B[39m"),
|
|
2922
|
-
red: f("\x1B[31m", "\x1B[39m"),
|
|
2923
|
-
green: f("\x1B[32m", "\x1B[39m"),
|
|
2924
|
-
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
2925
|
-
blue: f("\x1B[34m", "\x1B[39m"),
|
|
2926
|
-
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
2927
|
-
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
2928
|
-
white: f("\x1B[37m", "\x1B[39m"),
|
|
2929
|
-
gray: f("\x1B[90m", "\x1B[39m"),
|
|
2930
|
-
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
2931
|
-
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
2932
|
-
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
2933
|
-
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
2934
|
-
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
2935
|
-
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
2936
|
-
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
2937
|
-
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
2938
|
-
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
2939
|
-
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
2940
|
-
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
2941
|
-
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
2942
|
-
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
2943
|
-
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
2944
|
-
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
2945
|
-
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
2946
|
-
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
2947
|
-
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
2948
|
-
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
2949
|
-
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
2950
|
-
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
2951
|
-
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
2952
|
-
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
2953
|
-
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
2954
|
-
};
|
|
2955
|
-
};
|
|
2956
|
-
module.exports = createColors();
|
|
2957
|
-
module.exports.createColors = createColors;
|
|
2958
|
-
});
|
|
2959
|
-
|
|
2960
3066
|
// node_modules/@clack/core/dist/index.mjs
|
|
2961
3067
|
import { stdin as j, stdout as M } from "node:process";
|
|
2962
3068
|
import * as g from "node:readline";
|
|
@@ -3379,17 +3485,17 @@ import y2 from "node:process";
|
|
|
3379
3485
|
function ce() {
|
|
3380
3486
|
return y2.platform !== "win32" ? y2.env.TERM !== "linux" : !!y2.env.CI || !!y2.env.WT_SESSION || !!y2.env.TERMINUS_SUBLIME || y2.env.ConEmuTask === "{cmd::Cmder}" || y2.env.TERM_PROGRAM === "Terminus-Sublime" || y2.env.TERM_PROGRAM === "vscode" || y2.env.TERM === "xterm-256color" || y2.env.TERM === "alacritty" || y2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
3381
3487
|
}
|
|
3382
|
-
var
|
|
3488
|
+
var import_picocolors2, import_sisteransi2, V2, u = (t, n) => V2 ? t : n, le, L2, W2, C2, ue, o, d2, k2, P2, A2, T, F, $e, _2, me, de, pe, q, D, U, K2, b2 = (t) => {
|
|
3383
3489
|
switch (t) {
|
|
3384
3490
|
case "initial":
|
|
3385
3491
|
case "active":
|
|
3386
|
-
return
|
|
3492
|
+
return import_picocolors2.default.cyan(le);
|
|
3387
3493
|
case "cancel":
|
|
3388
|
-
return
|
|
3494
|
+
return import_picocolors2.default.red(L2);
|
|
3389
3495
|
case "error":
|
|
3390
|
-
return
|
|
3496
|
+
return import_picocolors2.default.yellow(W2);
|
|
3391
3497
|
case "submit":
|
|
3392
|
-
return
|
|
3498
|
+
return import_picocolors2.default.green(C2);
|
|
3393
3499
|
}
|
|
3394
3500
|
}, G2 = (t) => {
|
|
3395
3501
|
const { cursor: n, options: r, style: i } = t, s = t.maxItems ?? Number.POSITIVE_INFINITY, c = Math.max(process.stdout.rows - 4, 0), a = Math.min(c, Math.max(s, 5));
|
|
@@ -3398,23 +3504,23 @@ var import_picocolors, import_sisteransi2, V2, u = (t, n) => V2 ? t : n, le, L2,
|
|
|
3398
3504
|
const $2 = a < r.length && l2 > 0, g2 = a < r.length && l2 + a < r.length;
|
|
3399
3505
|
return r.slice(l2, l2 + a).map((p2, v, f) => {
|
|
3400
3506
|
const j2 = v === 0 && $2, E = v === f.length - 1 && g2;
|
|
3401
|
-
return j2 || E ?
|
|
3507
|
+
return j2 || E ? import_picocolors2.default.dim("...") : i(p2, v + l2 === n);
|
|
3402
3508
|
});
|
|
3403
3509
|
}, ye = (t) => {
|
|
3404
3510
|
const n = t.active ?? "Yes", r = t.inactive ?? "No";
|
|
3405
3511
|
return new dD({ active: n, inactive: r, initialValue: t.initialValue ?? true, render() {
|
|
3406
|
-
const i = `${
|
|
3512
|
+
const i = `${import_picocolors2.default.gray(o)}
|
|
3407
3513
|
${b2(this.state)} ${t.message}
|
|
3408
3514
|
`, s = this.value ? n : r;
|
|
3409
3515
|
switch (this.state) {
|
|
3410
3516
|
case "submit":
|
|
3411
|
-
return `${i}${
|
|
3517
|
+
return `${i}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.dim(s)}`;
|
|
3412
3518
|
case "cancel":
|
|
3413
|
-
return `${i}${
|
|
3414
|
-
${
|
|
3519
|
+
return `${i}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(s))}
|
|
3520
|
+
${import_picocolors2.default.gray(o)}`;
|
|
3415
3521
|
default:
|
|
3416
|
-
return `${i}${
|
|
3417
|
-
${
|
|
3522
|
+
return `${i}${import_picocolors2.default.cyan(o)} ${this.value ? `${import_picocolors2.default.green(k2)} ${n}` : `${import_picocolors2.default.dim(P2)} ${import_picocolors2.default.dim(n)}`} ${import_picocolors2.default.dim("/")} ${this.value ? `${import_picocolors2.default.dim(P2)} ${import_picocolors2.default.dim(r)}` : `${import_picocolors2.default.green(k2)} ${r}`}
|
|
3523
|
+
${import_picocolors2.default.cyan(d2)}
|
|
3418
3524
|
`;
|
|
3419
3525
|
}
|
|
3420
3526
|
} }).prompt();
|
|
@@ -3423,43 +3529,43 @@ ${import_picocolors.default.cyan(d2)}
|
|
|
3423
3529
|
const s = r.label ?? String(r.value);
|
|
3424
3530
|
switch (i) {
|
|
3425
3531
|
case "selected":
|
|
3426
|
-
return `${
|
|
3532
|
+
return `${import_picocolors2.default.dim(s)}`;
|
|
3427
3533
|
case "active":
|
|
3428
|
-
return `${
|
|
3534
|
+
return `${import_picocolors2.default.green(k2)} ${s} ${r.hint ? import_picocolors2.default.dim(`(${r.hint})`) : ""}`;
|
|
3429
3535
|
case "cancelled":
|
|
3430
|
-
return `${
|
|
3536
|
+
return `${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(s))}`;
|
|
3431
3537
|
default:
|
|
3432
|
-
return `${
|
|
3538
|
+
return `${import_picocolors2.default.dim(P2)} ${import_picocolors2.default.dim(s)}`;
|
|
3433
3539
|
}
|
|
3434
3540
|
};
|
|
3435
3541
|
return new LD({ options: t.options, initialValue: t.initialValue, render() {
|
|
3436
|
-
const r = `${
|
|
3542
|
+
const r = `${import_picocolors2.default.gray(o)}
|
|
3437
3543
|
${b2(this.state)} ${t.message}
|
|
3438
3544
|
`;
|
|
3439
3545
|
switch (this.state) {
|
|
3440
3546
|
case "submit":
|
|
3441
|
-
return `${r}${
|
|
3547
|
+
return `${r}${import_picocolors2.default.gray(o)} ${n(this.options[this.cursor], "selected")}`;
|
|
3442
3548
|
case "cancel":
|
|
3443
|
-
return `${r}${
|
|
3444
|
-
${
|
|
3549
|
+
return `${r}${import_picocolors2.default.gray(o)} ${n(this.options[this.cursor], "cancelled")}
|
|
3550
|
+
${import_picocolors2.default.gray(o)}`;
|
|
3445
3551
|
default:
|
|
3446
|
-
return `${r}${
|
|
3447
|
-
${
|
|
3448
|
-
${
|
|
3552
|
+
return `${r}${import_picocolors2.default.cyan(o)} ${G2({ cursor: this.cursor, options: this.options, maxItems: t.maxItems, style: (i, s) => n(i, s ? "active" : "inactive") }).join(`
|
|
3553
|
+
${import_picocolors2.default.cyan(o)} `)}
|
|
3554
|
+
${import_picocolors2.default.cyan(d2)}
|
|
3449
3555
|
`;
|
|
3450
3556
|
}
|
|
3451
3557
|
} }).prompt();
|
|
3452
3558
|
}, fe = (t) => {
|
|
3453
3559
|
const n = (r, i) => {
|
|
3454
3560
|
const s = r.label ?? String(r.value);
|
|
3455
|
-
return i === "active" ? `${
|
|
3561
|
+
return i === "active" ? `${import_picocolors2.default.cyan(A2)} ${s} ${r.hint ? import_picocolors2.default.dim(`(${r.hint})`) : ""}` : i === "selected" ? `${import_picocolors2.default.green(T)} ${import_picocolors2.default.dim(s)} ${r.hint ? import_picocolors2.default.dim(`(${r.hint})`) : ""}` : i === "cancelled" ? `${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(s))}` : i === "active-selected" ? `${import_picocolors2.default.green(T)} ${s} ${r.hint ? import_picocolors2.default.dim(`(${r.hint})`) : ""}` : i === "submitted" ? `${import_picocolors2.default.dim(s)}` : `${import_picocolors2.default.dim(F)} ${import_picocolors2.default.dim(s)}`;
|
|
3456
3562
|
};
|
|
3457
3563
|
return new SD({ options: t.options, initialValues: t.initialValues, required: t.required ?? true, cursorAt: t.cursorAt, validate(r) {
|
|
3458
3564
|
if (this.required && r.length === 0)
|
|
3459
3565
|
return `Please select at least one option.
|
|
3460
|
-
${
|
|
3566
|
+
${import_picocolors2.default.reset(import_picocolors2.default.dim(`Press ${import_picocolors2.default.gray(import_picocolors2.default.bgWhite(import_picocolors2.default.inverse(" space ")))} to select, ${import_picocolors2.default.gray(import_picocolors2.default.bgWhite(import_picocolors2.default.inverse(" enter ")))} to submit`))}`;
|
|
3461
3567
|
}, render() {
|
|
3462
|
-
const r = `${
|
|
3568
|
+
const r = `${import_picocolors2.default.gray(o)}
|
|
3463
3569
|
${b2(this.state)} ${t.message}
|
|
3464
3570
|
`, i = (s, c) => {
|
|
3465
3571
|
const a = this.value.includes(s.value);
|
|
@@ -3467,34 +3573,34 @@ ${b2(this.state)} ${t.message}
|
|
|
3467
3573
|
};
|
|
3468
3574
|
switch (this.state) {
|
|
3469
3575
|
case "submit":
|
|
3470
|
-
return `${r}${
|
|
3576
|
+
return `${r}${import_picocolors2.default.gray(o)} ${this.options.filter(({ value: s }) => this.value.includes(s)).map((s) => n(s, "submitted")).join(import_picocolors2.default.dim(", ")) || import_picocolors2.default.dim("none")}`;
|
|
3471
3577
|
case "cancel": {
|
|
3472
|
-
const s = this.options.filter(({ value: c }) => this.value.includes(c)).map((c) => n(c, "cancelled")).join(
|
|
3473
|
-
return `${r}${
|
|
3474
|
-
${
|
|
3578
|
+
const s = this.options.filter(({ value: c }) => this.value.includes(c)).map((c) => n(c, "cancelled")).join(import_picocolors2.default.dim(", "));
|
|
3579
|
+
return `${r}${import_picocolors2.default.gray(o)} ${s.trim() ? `${s}
|
|
3580
|
+
${import_picocolors2.default.gray(o)}` : ""}`;
|
|
3475
3581
|
}
|
|
3476
3582
|
case "error": {
|
|
3477
3583
|
const s = this.error.split(`
|
|
3478
|
-
`).map((c, a) => a === 0 ? `${
|
|
3584
|
+
`).map((c, a) => a === 0 ? `${import_picocolors2.default.yellow(d2)} ${import_picocolors2.default.yellow(c)}` : ` ${c}`).join(`
|
|
3479
3585
|
`);
|
|
3480
|
-
return `${r +
|
|
3481
|
-
${
|
|
3586
|
+
return `${r + import_picocolors2.default.yellow(o)} ${G2({ options: this.options, cursor: this.cursor, maxItems: t.maxItems, style: i }).join(`
|
|
3587
|
+
${import_picocolors2.default.yellow(o)} `)}
|
|
3482
3588
|
${s}
|
|
3483
3589
|
`;
|
|
3484
3590
|
}
|
|
3485
3591
|
default:
|
|
3486
|
-
return `${r}${
|
|
3487
|
-
${
|
|
3488
|
-
${
|
|
3592
|
+
return `${r}${import_picocolors2.default.cyan(o)} ${G2({ options: this.options, cursor: this.cursor, maxItems: t.maxItems, style: i }).join(`
|
|
3593
|
+
${import_picocolors2.default.cyan(o)} `)}
|
|
3594
|
+
${import_picocolors2.default.cyan(d2)}
|
|
3489
3595
|
`;
|
|
3490
3596
|
}
|
|
3491
3597
|
} }).prompt();
|
|
3492
3598
|
}, Ie = (t = "") => {
|
|
3493
|
-
process.stdout.write(`${
|
|
3599
|
+
process.stdout.write(`${import_picocolors2.default.gray(ue)} ${t}
|
|
3494
3600
|
`);
|
|
3495
3601
|
}, Se = (t = "") => {
|
|
3496
|
-
process.stdout.write(`${
|
|
3497
|
-
${
|
|
3602
|
+
process.stdout.write(`${import_picocolors2.default.gray(o)}
|
|
3603
|
+
${import_picocolors2.default.gray(d2)} ${t}
|
|
3498
3604
|
|
|
3499
3605
|
`);
|
|
3500
3606
|
}, M2, J2, Y2 = ({ indicator: t = "dots" } = {}) => {
|
|
@@ -3519,14 +3625,14 @@ ${import_picocolors.default.gray(d2)} ${t}
|
|
|
3519
3625
|
const h2 = (performance.now() - m2) / 1000, w2 = Math.floor(h2 / 60), I2 = Math.floor(h2 % 60);
|
|
3520
3626
|
return w2 > 0 ? `[${w2}m ${I2}s]` : `[${I2}s]`;
|
|
3521
3627
|
}, H2 = (m2 = "") => {
|
|
3522
|
-
a = true, s = fD(), l2 = R2(m2), g2 = performance.now(), process.stdout.write(`${
|
|
3628
|
+
a = true, s = fD(), l2 = R2(m2), g2 = performance.now(), process.stdout.write(`${import_picocolors2.default.gray(o)}
|
|
3523
3629
|
`);
|
|
3524
3630
|
let h2 = 0, w2 = 0;
|
|
3525
3631
|
j2(), c = setInterval(() => {
|
|
3526
3632
|
if (i && l2 === $2)
|
|
3527
3633
|
return;
|
|
3528
3634
|
B2(), $2 = l2;
|
|
3529
|
-
const I2 =
|
|
3635
|
+
const I2 = import_picocolors2.default.magenta(n[h2]);
|
|
3530
3636
|
if (i)
|
|
3531
3637
|
process.stdout.write(`${I2} ${l2}...`);
|
|
3532
3638
|
else if (t === "timer")
|
|
@@ -3539,7 +3645,7 @@ ${import_picocolors.default.gray(d2)} ${t}
|
|
|
3539
3645
|
}, r);
|
|
3540
3646
|
}, N2 = (m2 = "", h2 = 0) => {
|
|
3541
3647
|
a = false, clearInterval(c), B2();
|
|
3542
|
-
const w2 = h2 === 0 ?
|
|
3648
|
+
const w2 = h2 === 0 ? import_picocolors2.default.green(C2) : h2 === 1 ? import_picocolors2.default.red(L2) : import_picocolors2.default.red(W2);
|
|
3543
3649
|
l2 = R2(m2 ?? l2), t === "timer" ? process.stdout.write(`${w2} ${l2} ${O2(g2)}
|
|
3544
3650
|
`) : process.stdout.write(`${w2} ${l2}
|
|
3545
3651
|
`), E(), s();
|
|
@@ -3551,7 +3657,7 @@ ${import_picocolors.default.gray(d2)} ${t}
|
|
|
3551
3657
|
var init_dist2 = __esm(() => {
|
|
3552
3658
|
init_dist();
|
|
3553
3659
|
init_dist();
|
|
3554
|
-
|
|
3660
|
+
import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
3555
3661
|
import_sisteransi2 = __toESM(require_src(), 1);
|
|
3556
3662
|
V2 = ce();
|
|
3557
3663
|
le = u("◆", "*");
|
|
@@ -3575,30 +3681,30 @@ var init_dist2 = __esm(() => {
|
|
|
3575
3681
|
D = u("◆", "*");
|
|
3576
3682
|
U = u("▲", "!");
|
|
3577
3683
|
K2 = u("■", "x");
|
|
3578
|
-
M2 = { message: (t = "", { symbol: n =
|
|
3579
|
-
const r = [`${
|
|
3684
|
+
M2 = { message: (t = "", { symbol: n = import_picocolors2.default.gray(o) } = {}) => {
|
|
3685
|
+
const r = [`${import_picocolors2.default.gray(o)}`];
|
|
3580
3686
|
if (t) {
|
|
3581
3687
|
const [i, ...s] = t.split(`
|
|
3582
3688
|
`);
|
|
3583
|
-
r.push(`${n} ${i}`, ...s.map((c) => `${
|
|
3689
|
+
r.push(`${n} ${i}`, ...s.map((c) => `${import_picocolors2.default.gray(o)} ${c}`));
|
|
3584
3690
|
}
|
|
3585
3691
|
process.stdout.write(`${r.join(`
|
|
3586
3692
|
`)}
|
|
3587
3693
|
`);
|
|
3588
3694
|
}, info: (t) => {
|
|
3589
|
-
M2.message(t, { symbol:
|
|
3695
|
+
M2.message(t, { symbol: import_picocolors2.default.blue(q) });
|
|
3590
3696
|
}, success: (t) => {
|
|
3591
|
-
M2.message(t, { symbol:
|
|
3697
|
+
M2.message(t, { symbol: import_picocolors2.default.green(D) });
|
|
3592
3698
|
}, step: (t) => {
|
|
3593
|
-
M2.message(t, { symbol:
|
|
3699
|
+
M2.message(t, { symbol: import_picocolors2.default.green(C2) });
|
|
3594
3700
|
}, warn: (t) => {
|
|
3595
|
-
M2.message(t, { symbol:
|
|
3701
|
+
M2.message(t, { symbol: import_picocolors2.default.yellow(U) });
|
|
3596
3702
|
}, warning: (t) => {
|
|
3597
3703
|
M2.warn(t);
|
|
3598
3704
|
}, error: (t) => {
|
|
3599
|
-
M2.message(t, { symbol:
|
|
3705
|
+
M2.message(t, { symbol: import_picocolors2.default.red(K2) });
|
|
3600
3706
|
} };
|
|
3601
|
-
J2 = `${
|
|
3707
|
+
J2 = `${import_picocolors2.default.gray(o)} `;
|
|
3602
3708
|
});
|
|
3603
3709
|
|
|
3604
3710
|
// src/client/client.ts
|
|
@@ -3753,14 +3859,14 @@ var init_client = __esm(() => {
|
|
|
3753
3859
|
|
|
3754
3860
|
// src/setup/styles.ts
|
|
3755
3861
|
function dim(msg) {
|
|
3756
|
-
return
|
|
3862
|
+
return import_picocolors3.default.dim(msg);
|
|
3757
3863
|
}
|
|
3758
3864
|
function info(msg) {
|
|
3759
|
-
return
|
|
3865
|
+
return import_picocolors3.default.cyan(msg);
|
|
3760
3866
|
}
|
|
3761
|
-
var
|
|
3867
|
+
var import_picocolors3;
|
|
3762
3868
|
var init_styles = __esm(() => {
|
|
3763
|
-
|
|
3869
|
+
import_picocolors3 = __toESM(require_picocolors(), 1);
|
|
3764
3870
|
});
|
|
3765
3871
|
|
|
3766
3872
|
// src/auth/server.ts
|
|
@@ -3850,7 +3956,11 @@ async function startCallbackServer() {
|
|
|
3850
3956
|
const http = __require("node:http");
|
|
3851
3957
|
const httpServer = http.createServer((req, res) => {
|
|
3852
3958
|
const url = new URL(req.url ?? "/", `http://localhost`);
|
|
3959
|
+
const cookieLen = (req.headers.cookie ?? "").length;
|
|
3960
|
+
const ua = req.headers["user-agent"] ?? "none";
|
|
3961
|
+
logger.debug("auth.server", `Request: ${req.method} ${req.url} cookie-len=${cookieLen} ua=${ua} has-token=${url.searchParams.has("access_token")}`);
|
|
3853
3962
|
if (url.pathname !== "/callback") {
|
|
3963
|
+
logger.debug("auth.server", `404: ${url.pathname}`);
|
|
3854
3964
|
res.writeHead(404, { "Content-Type": "text/plain" });
|
|
3855
3965
|
res.end("Not Found");
|
|
3856
3966
|
return;
|
|
@@ -3861,6 +3971,7 @@ async function startCallbackServer() {
|
|
|
3861
3971
|
const email = url.searchParams.get("email");
|
|
3862
3972
|
const mode = url.searchParams.get("mode");
|
|
3863
3973
|
if (!accessToken) {
|
|
3974
|
+
logger.debug("auth.server", "Served extract HTML (no token in query)");
|
|
3864
3975
|
res.writeHead(200, { "Content-Type": "text/html" });
|
|
3865
3976
|
res.end(CALLBACK_HTML_EXTRACT);
|
|
3866
3977
|
return;
|
|
@@ -3871,6 +3982,7 @@ async function startCallbackServer() {
|
|
|
3871
3982
|
if (!Number.isNaN(parsed))
|
|
3872
3983
|
expiresInInt = parsed;
|
|
3873
3984
|
}
|
|
3985
|
+
logger.info("auth.server", `Token resolved, email=${email ?? "none"}`);
|
|
3874
3986
|
resolveToken?.({
|
|
3875
3987
|
access_token: accessToken,
|
|
3876
3988
|
refresh_token: refreshToken && refreshToken !== "null" ? refreshToken : "",
|
|
@@ -3878,6 +3990,7 @@ async function startCallbackServer() {
|
|
|
3878
3990
|
email: email ?? undefined,
|
|
3879
3991
|
...mode === MODE_OSS && { mode: MODE_OSS }
|
|
3880
3992
|
});
|
|
3993
|
+
logger.info("auth.server", "Served success HTML");
|
|
3881
3994
|
res.writeHead(200, { "Content-Type": "text/html" });
|
|
3882
3995
|
res.end(buildSuccessHtml(email ?? undefined));
|
|
3883
3996
|
});
|
|
@@ -3885,6 +3998,7 @@ async function startCallbackServer() {
|
|
|
3885
3998
|
httpServer.listen(0, "localhost", () => resolve());
|
|
3886
3999
|
});
|
|
3887
4000
|
const addr = httpServer.address();
|
|
4001
|
+
logger.info("auth.server", `Callback server listening on port ${addr.port}`);
|
|
3888
4002
|
return {
|
|
3889
4003
|
server: {
|
|
3890
4004
|
port: addr.port,
|
|
@@ -3960,6 +4074,7 @@ if (hash) {
|
|
|
3960
4074
|
</html>`;
|
|
3961
4075
|
var init_server = __esm(() => {
|
|
3962
4076
|
init_config();
|
|
4077
|
+
init_logger();
|
|
3963
4078
|
});
|
|
3964
4079
|
|
|
3965
4080
|
// node_modules/is-docker/index.js
|
|
@@ -4512,19 +4627,31 @@ async function startOAuthFlow(signal, path2 = "/cli/auth") {
|
|
|
4512
4627
|
let timeoutId;
|
|
4513
4628
|
try {
|
|
4514
4629
|
const callbackURL = `http://localhost:${server.port}/callback`;
|
|
4630
|
+
logger.debug("auth.flow", `Callback URL: ${callbackURL}`);
|
|
4515
4631
|
const authURL = buildAuthURL(callbackURL, path2);
|
|
4632
|
+
logger.info("auth.flow", `Auth URL: ${authURL}`);
|
|
4516
4633
|
const open2 = await Promise.resolve().then(() => (init_open(), exports_open));
|
|
4517
4634
|
await open2.default(authURL);
|
|
4635
|
+
logger.info("auth.flow", "Browser open command executed");
|
|
4518
4636
|
const timeout = new Promise((_3, reject) => {
|
|
4519
|
-
timeoutId = setTimeout(() =>
|
|
4637
|
+
timeoutId = setTimeout(() => {
|
|
4638
|
+
logger.warn("auth.flow", "Authentication timed out (15min)");
|
|
4639
|
+
reject(new Error("authentication timeout - please try again"));
|
|
4640
|
+
}, 900000);
|
|
4520
4641
|
});
|
|
4521
4642
|
const abort = signal ? new Promise((_3, reject) => {
|
|
4522
|
-
signal.addEventListener("abort", () =>
|
|
4643
|
+
signal.addEventListener("abort", () => {
|
|
4644
|
+
logger.warn("auth.flow", "Authentication cancelled via abort");
|
|
4645
|
+
reject(new Error("authentication cancelled"));
|
|
4646
|
+
});
|
|
4523
4647
|
}) : new Promise(() => {});
|
|
4524
|
-
|
|
4648
|
+
const token = await Promise.race([tokenPromise, timeout, abort]);
|
|
4649
|
+
logger.info("auth.flow", "Token received");
|
|
4650
|
+
return token;
|
|
4525
4651
|
} finally {
|
|
4526
4652
|
clearTimeout(timeoutId);
|
|
4527
4653
|
server.close();
|
|
4654
|
+
logger.debug("auth.flow", "Cleaning up: timeout cleared, server closed");
|
|
4528
4655
|
}
|
|
4529
4656
|
}
|
|
4530
4657
|
function buildAuthURL(callbackURL, path2) {
|
|
@@ -4536,6 +4663,7 @@ function buildAuthURL(callbackURL, path2) {
|
|
|
4536
4663
|
return `${webAppURL}${path2}?${params}`;
|
|
4537
4664
|
}
|
|
4538
4665
|
var init_flow = __esm(() => {
|
|
4666
|
+
init_logger();
|
|
4539
4667
|
init_server();
|
|
4540
4668
|
});
|
|
4541
4669
|
|
|
@@ -4549,6 +4677,7 @@ __export(exports_flow2, {
|
|
|
4549
4677
|
isStdioOnly: () => isStdioOnly
|
|
4550
4678
|
});
|
|
4551
4679
|
async function runSetup(opts = {}) {
|
|
4680
|
+
logger.info("setup", `Setup flow started${opts.deploymentID ? ` deployment=${opts.deploymentID}` : ""}`);
|
|
4552
4681
|
Ie("Dosu CLI Setup");
|
|
4553
4682
|
const cfg = await stepAuthenticate(opts);
|
|
4554
4683
|
if (!cfg)
|
|
@@ -4602,6 +4731,7 @@ Run ${info("dosu mcp add <tool>")} to manually configure a tool.`);
|
|
|
4602
4731
|
}
|
|
4603
4732
|
}
|
|
4604
4733
|
async function stepAuthenticate(opts) {
|
|
4734
|
+
logger.info("setup", "Step: authenticate");
|
|
4605
4735
|
const cfg = loadConfig();
|
|
4606
4736
|
if (cfg.access_token) {
|
|
4607
4737
|
const s = Y2();
|
|
@@ -4610,6 +4740,7 @@ async function stepAuthenticate(opts) {
|
|
|
4610
4740
|
const apiClient = new Client(cfg);
|
|
4611
4741
|
const resp = await apiClient.doRequestRaw("GET", "/v1/mcp/deployments");
|
|
4612
4742
|
if (resp.status === 200) {
|
|
4743
|
+
logger.info("setup", `Session verified, status=${resp.status}`);
|
|
4613
4744
|
s.stop("Authenticated");
|
|
4614
4745
|
if (!opts.deploymentID && cfg.mode === MODE_OSS) {
|
|
4615
4746
|
const modeLabel = "open-source libraries only";
|
|
@@ -4629,6 +4760,7 @@ async function stepAuthenticate(opts) {
|
|
|
4629
4760
|
return cfg;
|
|
4630
4761
|
}
|
|
4631
4762
|
try {
|
|
4763
|
+
logger.debug("setup", "Attempting token refresh");
|
|
4632
4764
|
await apiClient.refreshToken();
|
|
4633
4765
|
const resp2 = await apiClient.doRequestRaw("GET", "/v1/mcp/deployments");
|
|
4634
4766
|
if (resp2.status === 200) {
|
|
@@ -4637,6 +4769,7 @@ async function stepAuthenticate(opts) {
|
|
|
4637
4769
|
}
|
|
4638
4770
|
} catch {}
|
|
4639
4771
|
s.stop("Session expired");
|
|
4772
|
+
logger.warn("setup", "Session expired");
|
|
4640
4773
|
M2.warn("Session expired.");
|
|
4641
4774
|
} catch {
|
|
4642
4775
|
s.stop("Session verification failed");
|
|
@@ -4655,6 +4788,7 @@ async function openBrowserForSetup(cfg, opts) {
|
|
|
4655
4788
|
const authPath = opts.deploymentID ? "/cli/auth" : "/cli/setup";
|
|
4656
4789
|
const token = await startOAuthFlow2(undefined, authPath);
|
|
4657
4790
|
s.stop("Authenticated");
|
|
4791
|
+
logger.info("setup", `Browser auth completed, mode=${token.mode ?? "cloud"}`);
|
|
4658
4792
|
cfg.access_token = token.access_token;
|
|
4659
4793
|
cfg.refresh_token = token.refresh_token;
|
|
4660
4794
|
cfg.expires_at = Math.floor(Date.now() / 1000) + token.expires_in;
|
|
@@ -4662,6 +4796,8 @@ async function openBrowserForSetup(cfg, opts) {
|
|
|
4662
4796
|
saveConfig(cfg);
|
|
4663
4797
|
return cfg;
|
|
4664
4798
|
} catch (err) {
|
|
4799
|
+
const msg = err instanceof Error ? err.stack ?? err.message : String(err);
|
|
4800
|
+
logger.error("setup", `Auth failed: ${msg}`);
|
|
4665
4801
|
M2.error(`Authentication failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
4666
4802
|
return null;
|
|
4667
4803
|
}
|
|
@@ -4681,6 +4817,7 @@ async function stepSelectOrg(apiClient) {
|
|
|
4681
4817
|
return null;
|
|
4682
4818
|
}
|
|
4683
4819
|
if (orgs.length === 1) {
|
|
4820
|
+
logger.info("setup", `Selected org: ${orgs[0].name} (auto, only one)`);
|
|
4684
4821
|
M2.success(`Organization
|
|
4685
4822
|
${dim(orgs[0].name)}`);
|
|
4686
4823
|
return orgs[0];
|
|
@@ -4691,7 +4828,10 @@ ${dim(orgs[0].name)}`);
|
|
|
4691
4828
|
});
|
|
4692
4829
|
if (pD(selected))
|
|
4693
4830
|
return null;
|
|
4694
|
-
|
|
4831
|
+
const org = orgs.find((o2) => o2.org_id === selected) ?? null;
|
|
4832
|
+
if (org)
|
|
4833
|
+
logger.info("setup", `Selected org: ${org.name}`);
|
|
4834
|
+
return org;
|
|
4695
4835
|
} catch (err) {
|
|
4696
4836
|
if (err instanceof SessionExpiredError) {
|
|
4697
4837
|
M2.warn(`Session expired. Please run ${info("dosu setup")} again.`);
|
|
@@ -4706,9 +4846,11 @@ async function stepResolveDeployment(apiClient, id) {
|
|
|
4706
4846
|
const deployments = await apiClient.getDeployments();
|
|
4707
4847
|
const d3 = deployments.find((d4) => d4.deployment_id === id);
|
|
4708
4848
|
if (!d3) {
|
|
4849
|
+
logger.warn("setup", `Deployment ${id} not found`);
|
|
4709
4850
|
M2.error(`Deployment ${id} not found`);
|
|
4710
4851
|
return null;
|
|
4711
4852
|
}
|
|
4853
|
+
logger.info("setup", `Resolved deployment: ${d3.name}`);
|
|
4712
4854
|
M2.success(`Using deployment
|
|
4713
4855
|
${dim(d3.name)}`);
|
|
4714
4856
|
return d3;
|
|
@@ -4720,23 +4862,27 @@ ${dim(d3.name)}`);
|
|
|
4720
4862
|
async function stepSelectDeployment(apiClient, org) {
|
|
4721
4863
|
try {
|
|
4722
4864
|
const allDeployments = await apiClient.getDeployments();
|
|
4723
|
-
const deployments = allDeployments.filter((
|
|
4865
|
+
const deployments = allDeployments.filter((d4) => d4.org_id === org.org_id);
|
|
4724
4866
|
if (deployments.length === 0) {
|
|
4725
4867
|
M2.error(`No deployments found for ${org.name}`);
|
|
4726
4868
|
return null;
|
|
4727
4869
|
}
|
|
4728
4870
|
if (deployments.length === 1) {
|
|
4871
|
+
logger.info("setup", `Selected deployment: ${deployments[0].name} (auto, only one)`);
|
|
4729
4872
|
M2.success(`Using deployment
|
|
4730
4873
|
${dim(deployments[0].name)}`);
|
|
4731
4874
|
return deployments[0];
|
|
4732
4875
|
}
|
|
4733
4876
|
const selected = await ve({
|
|
4734
4877
|
message: "Select an MCP",
|
|
4735
|
-
options: deployments.map((
|
|
4878
|
+
options: deployments.map((d4) => ({ label: d4.name, value: d4.deployment_id }))
|
|
4736
4879
|
});
|
|
4737
4880
|
if (pD(selected))
|
|
4738
4881
|
return null;
|
|
4739
|
-
|
|
4882
|
+
const d3 = deployments.find((d4) => d4.deployment_id === selected) ?? null;
|
|
4883
|
+
if (d3)
|
|
4884
|
+
logger.info("setup", `Selected deployment: ${d3.name}`);
|
|
4885
|
+
return d3;
|
|
4740
4886
|
} catch (err) {
|
|
4741
4887
|
M2.error(`Deployment selection failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
4742
4888
|
return null;
|
|
@@ -4749,6 +4895,7 @@ async function stepMintAPIKey(apiClient, cfg) {
|
|
|
4749
4895
|
}
|
|
4750
4896
|
if (cfg.api_key) {
|
|
4751
4897
|
const valid = await apiClient.validateAPIKey(cfg.api_key, cfg.deployment_id);
|
|
4898
|
+
logger.debug("setup", `Existing API key valid=${valid}`);
|
|
4752
4899
|
if (valid) {
|
|
4753
4900
|
M2.success(`API key
|
|
4754
4901
|
${dim("using existing")}`);
|
|
@@ -4758,6 +4905,7 @@ ${dim("using existing")}`);
|
|
|
4758
4905
|
}
|
|
4759
4906
|
try {
|
|
4760
4907
|
const resp = await apiClient.createAPIKey(cfg.deployment_id, "dosu-cli");
|
|
4908
|
+
logger.info("setup", "API key created");
|
|
4761
4909
|
M2.success(`API key
|
|
4762
4910
|
${dim("created")}`);
|
|
4763
4911
|
return resp.api_key;
|
|
@@ -4810,9 +4958,11 @@ function stepConfigureTools(cfg, selection) {
|
|
|
4810
4958
|
for (const provider of selection.toInstall) {
|
|
4811
4959
|
try {
|
|
4812
4960
|
provider.install(cfg, true);
|
|
4961
|
+
logger.info("setup", `Configured ${provider.name()}`);
|
|
4813
4962
|
results.push({ provider, action: "install" });
|
|
4814
4963
|
} catch (err) {
|
|
4815
4964
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
4965
|
+
logger.error("setup", `Config failed for ${provider.name()}: ${error.stack ?? error.message}`);
|
|
4816
4966
|
M2.error(`Failed to configure ${provider.name()}: ${error.message}`);
|
|
4817
4967
|
results.push({ provider, action: "install", error });
|
|
4818
4968
|
}
|
|
@@ -4820,9 +4970,11 @@ function stepConfigureTools(cfg, selection) {
|
|
|
4820
4970
|
for (const provider of selection.toRemove) {
|
|
4821
4971
|
try {
|
|
4822
4972
|
provider.remove(true);
|
|
4973
|
+
logger.info("setup", `Removed ${provider.name()}`);
|
|
4823
4974
|
results.push({ provider, action: "remove" });
|
|
4824
4975
|
} catch (err) {
|
|
4825
4976
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
4977
|
+
logger.error("setup", `Remove failed for ${provider.name()}: ${error.stack ?? error.message}`);
|
|
4826
4978
|
M2.error(`Failed to remove ${provider.name()}: ${error.message}`);
|
|
4827
4979
|
results.push({ provider, action: "remove", error });
|
|
4828
4980
|
}
|
|
@@ -4864,6 +5016,7 @@ var init_flow2 = __esm(() => {
|
|
|
4864
5016
|
init_dist2();
|
|
4865
5017
|
init_client();
|
|
4866
5018
|
init_config();
|
|
5019
|
+
init_logger();
|
|
4867
5020
|
init_providers();
|
|
4868
5021
|
init_styles();
|
|
4869
5022
|
});
|
|
@@ -4875,7 +5028,7 @@ __export(exports_tui, {
|
|
|
4875
5028
|
handleLogout: () => handleLogout
|
|
4876
5029
|
});
|
|
4877
5030
|
async function runTUI() {
|
|
4878
|
-
console.log(
|
|
5031
|
+
console.log(import_picocolors4.default.magenta(LOGO));
|
|
4879
5032
|
const cfg = loadConfig();
|
|
4880
5033
|
if (!isAuthenticated(cfg)) {
|
|
4881
5034
|
await handleAuthenticate(cfg);
|
|
@@ -4883,7 +5036,6 @@ async function runTUI() {
|
|
|
4883
5036
|
return;
|
|
4884
5037
|
}
|
|
4885
5038
|
while (true) {
|
|
4886
|
-
const hasMcpTarget = cfg.mode === MODE_OSS || !!cfg.deployment_id;
|
|
4887
5039
|
const action = await ve({
|
|
4888
5040
|
message: "What would you like to do?",
|
|
4889
5041
|
options: [
|
|
@@ -4897,11 +5049,6 @@ async function runTUI() {
|
|
|
4897
5049
|
value: "auth",
|
|
4898
5050
|
hint: isAuthenticated(cfg) ? "Re-authenticate" : undefined
|
|
4899
5051
|
},
|
|
4900
|
-
{
|
|
4901
|
-
label: "Remove MCP",
|
|
4902
|
-
value: "mcp-remove",
|
|
4903
|
-
hint: !hasMcpTarget ? "Select deployment first" : undefined
|
|
4904
|
-
},
|
|
4905
5052
|
{ label: "Clear Credentials", value: "logout" },
|
|
4906
5053
|
{ label: "Exit", value: "exit" }
|
|
4907
5054
|
]
|
|
@@ -4917,13 +5064,6 @@ async function runTUI() {
|
|
|
4917
5064
|
await runSetup();
|
|
4918
5065
|
Object.assign(cfg, loadConfig());
|
|
4919
5066
|
break;
|
|
4920
|
-
case "mcp-remove":
|
|
4921
|
-
if (!hasMcpTarget) {
|
|
4922
|
-
M2.warn("Please select a deployment first.");
|
|
4923
|
-
continue;
|
|
4924
|
-
}
|
|
4925
|
-
await handleMCPRemove(cfg);
|
|
4926
|
-
break;
|
|
4927
5067
|
case "logout":
|
|
4928
5068
|
handleLogout(cfg);
|
|
4929
5069
|
break;
|
|
@@ -4931,28 +5071,6 @@ async function runTUI() {
|
|
|
4931
5071
|
}
|
|
4932
5072
|
Se("Goodbye!");
|
|
4933
5073
|
}
|
|
4934
|
-
async function handleMCPRemove(_cfg) {
|
|
4935
|
-
const { allProviders: allProviders2 } = await Promise.resolve().then(() => (init_providers(), exports_providers));
|
|
4936
|
-
const providers = allProviders2();
|
|
4937
|
-
const selected = await ve({
|
|
4938
|
-
message: "Select tool to remove MCP from",
|
|
4939
|
-
options: providers.filter((p2) => p2.id() !== "manual").map((p2) => ({
|
|
4940
|
-
label: p2.name(),
|
|
4941
|
-
value: p2.id()
|
|
4942
|
-
}))
|
|
4943
|
-
});
|
|
4944
|
-
if (pD(selected))
|
|
4945
|
-
return;
|
|
4946
|
-
const provider = providers.find((p2) => p2.id() === selected);
|
|
4947
|
-
if (!provider)
|
|
4948
|
-
return;
|
|
4949
|
-
try {
|
|
4950
|
-
provider.remove(true);
|
|
4951
|
-
M2.success(`Removed Dosu MCP from ${provider.name()}`);
|
|
4952
|
-
} catch (err) {
|
|
4953
|
-
M2.error(`Failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
4954
|
-
}
|
|
4955
|
-
}
|
|
4956
5074
|
async function handleAuthenticate(cfg) {
|
|
4957
5075
|
if (cfg.access_token) {
|
|
4958
5076
|
const s = Y2();
|
|
@@ -5007,7 +5125,7 @@ function handleLogout(cfg) {
|
|
|
5007
5125
|
saveConfig(cfg);
|
|
5008
5126
|
M2.success("Credentials cleared.");
|
|
5009
5127
|
}
|
|
5010
|
-
var
|
|
5128
|
+
var import_picocolors4, LOGO = `
|
|
5011
5129
|
/$$$$$$$
|
|
5012
5130
|
| $$__ $$
|
|
5013
5131
|
| $$ \\ $$ /$$$$$$ /$$$$$$$ /$$ /$$
|
|
@@ -5022,9 +5140,12 @@ var init_tui = __esm(() => {
|
|
|
5022
5140
|
init_client();
|
|
5023
5141
|
init_config();
|
|
5024
5142
|
init_flow2();
|
|
5025
|
-
|
|
5143
|
+
import_picocolors4 = __toESM(require_picocolors(), 1);
|
|
5026
5144
|
});
|
|
5027
5145
|
|
|
5146
|
+
// src/cli/cli.ts
|
|
5147
|
+
import { readFileSync as readFileSync5, unlinkSync } from "node:fs";
|
|
5148
|
+
|
|
5028
5149
|
// node_modules/commander/esm.mjs
|
|
5029
5150
|
var import__ = __toESM(require_commander(), 1);
|
|
5030
5151
|
var {
|
|
@@ -5043,18 +5164,14 @@ var {
|
|
|
5043
5164
|
|
|
5044
5165
|
// src/cli/cli.ts
|
|
5045
5166
|
init_config();
|
|
5167
|
+
init_logger();
|
|
5046
5168
|
init_providers();
|
|
5047
|
-
|
|
5048
|
-
// src/version/version.ts
|
|
5049
|
-
var VERSION = "0.6.0";
|
|
5050
|
-
function getVersionString() {
|
|
5051
|
-
return `v${VERSION}`;
|
|
5052
|
-
}
|
|
5053
|
-
|
|
5054
|
-
// src/cli/cli.ts
|
|
5055
5169
|
function createProgram() {
|
|
5056
5170
|
const program2 = new Command;
|
|
5057
|
-
program2.name("dosu").description("Dosu CLI - Manage MCP servers for AI tools").version(getVersionString(), "-v, --version").
|
|
5171
|
+
program2.name("dosu").description("Dosu CLI - Manage MCP servers for AI tools").version(getVersionString(), "-v, --version").option("--debug", "Enable debug logging to stderr", false).hook("preAction", (thisCommand) => {
|
|
5172
|
+
const opts = thisCommand.optsWithGlobals();
|
|
5173
|
+
logger.init({ debug: opts.debug });
|
|
5174
|
+
}).action(async () => {
|
|
5058
5175
|
const { runTUI: runTUI2 } = await Promise.resolve().then(() => (init_tui(), exports_tui));
|
|
5059
5176
|
await runTUI2();
|
|
5060
5177
|
});
|
|
@@ -5173,6 +5290,32 @@ Use 'dosu mcp add <tool>' to add Dosu MCP to a tool.`);
|
|
|
5173
5290
|
const { runSetup: runSetup2 } = await Promise.resolve().then(() => (init_flow2(), exports_flow2));
|
|
5174
5291
|
await runSetup2({ deploymentID: opts.deployment });
|
|
5175
5292
|
});
|
|
5293
|
+
program2.command("logs").description("View or manage debug logs").option("-t, --tail [n]", "Show last N lines (default: 50)").option("--clear", "Delete the log file").action((opts) => {
|
|
5294
|
+
const logPath = logger.getLogPath();
|
|
5295
|
+
if (opts.clear) {
|
|
5296
|
+
try {
|
|
5297
|
+
unlinkSync(logPath);
|
|
5298
|
+
console.log("Log file deleted.");
|
|
5299
|
+
} catch {
|
|
5300
|
+
console.log("No log file to delete.");
|
|
5301
|
+
}
|
|
5302
|
+
return;
|
|
5303
|
+
}
|
|
5304
|
+
if (opts.tail !== undefined) {
|
|
5305
|
+
const n = typeof opts.tail === "string" ? parseInt(opts.tail, 10) || 50 : 50;
|
|
5306
|
+
try {
|
|
5307
|
+
const content = readFileSync5(logPath, "utf-8");
|
|
5308
|
+
const lines = content.split(`
|
|
5309
|
+
`);
|
|
5310
|
+
console.log(lines.slice(-n).join(`
|
|
5311
|
+
`));
|
|
5312
|
+
} catch {
|
|
5313
|
+
console.log(`No log file found at ${logPath}`);
|
|
5314
|
+
}
|
|
5315
|
+
return;
|
|
5316
|
+
}
|
|
5317
|
+
console.log(logPath);
|
|
5318
|
+
});
|
|
5176
5319
|
return program2;
|
|
5177
5320
|
}
|
|
5178
5321
|
async function execute() {
|