@snapback/cli 1.1.14 → 1.1.15
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/README.md +70 -9
- package/dist/SkippedTestDetector-AXTMWWHC.js +5 -0
- package/dist/SkippedTestDetector-QLSQV7K7.js +5 -0
- package/dist/analysis-6WTBZJH3.js +6 -0
- package/dist/analysis-C472LUGW.js +2475 -0
- package/dist/auth-HFJRXXG2.js +1446 -0
- package/dist/auto-provision-organization-SF6XM7X4.js +161 -0
- package/dist/chunk-23G5VYA3.js +4259 -0
- package/dist/{chunk-QAKFE3NE.js → chunk-4YTE4JEW.js} +3 -4
- package/dist/chunk-5EOPYJ4Y.js +12 -0
- package/dist/{chunk-OJNDAPC2.js → chunk-5SQA44V7.js} +1086 -19
- package/dist/{chunk-BW7RALUZ.js → chunk-7ADPL4Q3.js} +11 -4
- package/dist/chunk-CBGOC6RV.js +293 -0
- package/dist/chunk-DNEADD2G.js +3499 -0
- package/dist/{chunk-Q5XZ3DCB.js → chunk-DPWFZNMY.js} +122 -15
- package/dist/chunk-GQ73B37K.js +314 -0
- package/dist/chunk-HR34NJP7.js +6133 -0
- package/dist/chunk-ICKSHS3A.js +2264 -0
- package/dist/{chunk-2TOJVUVJ.js → chunk-OI2HNNT6.js} +285 -33
- package/dist/chunk-PL4HF4M2.js +593 -0
- package/dist/chunk-WS36HDEU.js +3735 -0
- package/dist/chunk-XYU5FFE3.js +111 -0
- package/dist/chunk-ZBQDE6WJ.js +108 -0
- package/dist/client-WIO6W447.js +8 -0
- package/dist/dist-E7E2T3DQ.js +9 -0
- package/dist/dist-TEWNOZYS.js +5 -0
- package/dist/dist-YZBJAYEJ.js +12 -0
- package/dist/index.js +63852 -39806
- package/dist/local-service-adapter-3JHN6G4O.js +6 -0
- package/dist/pioneer-oauth-hook-V2JKEXM7.js +12 -0
- package/dist/{secure-credentials-A4QHHOE2.js → secure-credentials-UEPG7GWW.js} +3 -4
- package/dist/snapback-dir-MG7DTRMF.js +6 -0
- package/package.json +8 -41
- package/scripts/postinstall.mjs +2 -3
- package/dist/SkippedTestDetector-B3JZUE5G.js +0 -5
- package/dist/SkippedTestDetector-B3JZUE5G.js.map +0 -1
- package/dist/analysis-C6XVLBAL.js +0 -6
- package/dist/analysis-C6XVLBAL.js.map +0 -1
- package/dist/chunk-2TOJVUVJ.js.map +0 -1
- package/dist/chunk-5EQLSU5B.js +0 -385
- package/dist/chunk-5EQLSU5B.js.map +0 -1
- package/dist/chunk-6MR2TINI.js +0 -27
- package/dist/chunk-6MR2TINI.js.map +0 -1
- package/dist/chunk-A3TUM7U4.js +0 -13002
- package/dist/chunk-A3TUM7U4.js.map +0 -1
- package/dist/chunk-BW7RALUZ.js.map +0 -1
- package/dist/chunk-LEXNOXPV.js +0 -21621
- package/dist/chunk-LEXNOXPV.js.map +0 -1
- package/dist/chunk-OJNDAPC2.js.map +0 -1
- package/dist/chunk-Q5XZ3DCB.js.map +0 -1
- package/dist/chunk-QAKFE3NE.js.map +0 -1
- package/dist/chunk-QLCHTUT5.js +0 -1067
- package/dist/chunk-QLCHTUT5.js.map +0 -1
- package/dist/dist-D2SHOZMS.js +0 -8
- package/dist/dist-D2SHOZMS.js.map +0 -1
- package/dist/dist-L76VXYJ5.js +0 -5
- package/dist/dist-L76VXYJ5.js.map +0 -1
- package/dist/dist-RPM72FHJ.js +0 -5
- package/dist/dist-RPM72FHJ.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/learning-pruner-YSZSOOOC.js +0 -7
- package/dist/learning-pruner-YSZSOOOC.js.map +0 -1
- package/dist/secure-credentials-A4QHHOE2.js.map +0 -1
- package/dist/snapback-dir-6QUSO6Y3.js +0 -6
- package/dist/snapback-dir-6QUSO6Y3.js.map +0 -1
- package/dist/storage-H366UNAR.js +0 -6
- package/dist/storage-H366UNAR.js.map +0 -1
|
@@ -1,17 +1,92 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { __name } from './chunk-
|
|
3
|
-
import {
|
|
1
|
+
#!/usr/bin/env node --no-warnings=ExperimentalWarning
|
|
2
|
+
import { __name } from './chunk-7ADPL4Q3.js';
|
|
3
|
+
import { readFileSync, mkdirSync, writeFileSync, existsSync } from 'fs';
|
|
4
4
|
import { homedir, platform } from 'os';
|
|
5
5
|
import { join, resolve, dirname } from 'path';
|
|
6
6
|
import { randomUUID } from 'crypto';
|
|
7
7
|
import { exec, execSync } from 'child_process';
|
|
8
8
|
import { promisify } from 'util';
|
|
9
9
|
|
|
10
|
+
process.env.SNAPBACK_CLI='true';
|
|
10
11
|
var __defProp = Object.defineProperty;
|
|
11
12
|
var __name2 = /* @__PURE__ */ __name((target, value) => __defProp(target, "name", {
|
|
12
13
|
value,
|
|
13
14
|
configurable: true
|
|
14
15
|
}), "__name");
|
|
16
|
+
var CACHE_TTL_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
17
|
+
function getCacheFilePath() {
|
|
18
|
+
return join(homedir(), ".snapback", "mcp-configs", "paths.json");
|
|
19
|
+
}
|
|
20
|
+
__name(getCacheFilePath, "getCacheFilePath");
|
|
21
|
+
__name2(getCacheFilePath, "getCacheFilePath");
|
|
22
|
+
function readCache() {
|
|
23
|
+
try {
|
|
24
|
+
const raw = readFileSync(getCacheFilePath(), "utf-8");
|
|
25
|
+
const parsed = JSON.parse(raw);
|
|
26
|
+
if (parsed.version === 1 && typeof parsed.discovered === "object") {
|
|
27
|
+
return parsed;
|
|
28
|
+
}
|
|
29
|
+
} catch {
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
version: 1,
|
|
33
|
+
discovered: {}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
__name(readCache, "readCache");
|
|
37
|
+
__name2(readCache, "readCache");
|
|
38
|
+
function writeCache(cache) {
|
|
39
|
+
try {
|
|
40
|
+
const dir = join(homedir(), ".snapback", "mcp-configs");
|
|
41
|
+
mkdirSync(dir, {
|
|
42
|
+
recursive: true
|
|
43
|
+
});
|
|
44
|
+
writeFileSync(getCacheFilePath(), JSON.stringify(cache, null, 2));
|
|
45
|
+
} catch {
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
__name(writeCache, "writeCache");
|
|
49
|
+
__name2(writeCache, "writeCache");
|
|
50
|
+
function getCachedPath(clientName) {
|
|
51
|
+
const cache = readCache();
|
|
52
|
+
const entry = cache.discovered[clientName];
|
|
53
|
+
if (!entry) return null;
|
|
54
|
+
const age = Date.now() - new Date(entry.discoveredAt).getTime();
|
|
55
|
+
if (age > CACHE_TTL_MS) return null;
|
|
56
|
+
if (!existsSync(entry.path)) {
|
|
57
|
+
delete cache.discovered[clientName];
|
|
58
|
+
writeCache(cache);
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
return entry.path;
|
|
62
|
+
}
|
|
63
|
+
__name(getCachedPath, "getCachedPath");
|
|
64
|
+
__name2(getCachedPath, "getCachedPath");
|
|
65
|
+
function setCachedPath(clientName, configPath) {
|
|
66
|
+
const cache = readCache();
|
|
67
|
+
cache.discovered[clientName] = {
|
|
68
|
+
path: configPath,
|
|
69
|
+
discoveredAt: /* @__PURE__ */ (/* @__PURE__ */ new Date()).toISOString(),
|
|
70
|
+
platform: process.platform
|
|
71
|
+
};
|
|
72
|
+
writeCache(cache);
|
|
73
|
+
}
|
|
74
|
+
__name(setCachedPath, "setCachedPath");
|
|
75
|
+
__name2(setCachedPath, "setCachedPath");
|
|
76
|
+
function evictCachedPath(clientName) {
|
|
77
|
+
const cache = readCache();
|
|
78
|
+
if (cache.discovered[clientName]) {
|
|
79
|
+
delete cache.discovered[clientName];
|
|
80
|
+
writeCache(cache);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
__name(evictCachedPath, "evictCachedPath");
|
|
84
|
+
__name2(evictCachedPath, "evictCachedPath");
|
|
85
|
+
function getAllCachedPaths() {
|
|
86
|
+
return readCache().discovered;
|
|
87
|
+
}
|
|
88
|
+
__name(getAllCachedPaths, "getAllCachedPaths");
|
|
89
|
+
__name2(getAllCachedPaths, "getAllCachedPaths");
|
|
15
90
|
var CLIENT_CONFIGS = {
|
|
16
91
|
claude: /* @__PURE__ */ __name2((home) => {
|
|
17
92
|
switch (platform()) {
|
|
@@ -36,14 +111,17 @@ var CLIENT_CONFIGS = {
|
|
|
36
111
|
] : [],
|
|
37
112
|
join(_home, ".cursor/mcp.json")
|
|
38
113
|
], "cursor"),
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
join(cwd, ".windsurf/mcp.json")
|
|
42
|
-
] : [],
|
|
114
|
+
// Windsurf only has a global config — no project-level support (confirmed by Windsurf docs, June 2025)
|
|
115
|
+
windsurf: /* @__PURE__ */ __name2((home) => [
|
|
43
116
|
join(home, ".codeium/windsurf/mcp_config.json")
|
|
44
117
|
], "windsurf"),
|
|
45
|
-
|
|
46
|
-
|
|
118
|
+
// Continue: global config.json or config.yaml; project-level .continue/mcpServers/mcp.json
|
|
119
|
+
continue: /* @__PURE__ */ __name2((home, cwd) => [
|
|
120
|
+
...cwd ? [
|
|
121
|
+
join(cwd, ".continue/mcpServers/mcp.json")
|
|
122
|
+
] : [],
|
|
123
|
+
join(home, ".continue/config.json"),
|
|
124
|
+
join(home, ".continue/config.yaml")
|
|
47
125
|
], "continue"),
|
|
48
126
|
// New clients
|
|
49
127
|
vscode: /* @__PURE__ */ __name2((_home, cwd) => [
|
|
@@ -51,9 +129,16 @@ var CLIENT_CONFIGS = {
|
|
|
51
129
|
join(cwd, ".vscode/mcp.json")
|
|
52
130
|
] : []
|
|
53
131
|
], "vscode"),
|
|
54
|
-
|
|
132
|
+
// Zed: global ~/.config/zed/settings.json, plus project-level .zed/settings.json
|
|
133
|
+
zed: /* @__PURE__ */ __name2((home, cwd) => [
|
|
134
|
+
...cwd ? [
|
|
135
|
+
join(cwd, ".zed/settings.json")
|
|
136
|
+
] : [],
|
|
55
137
|
join(home, ".config/zed/settings.json")
|
|
56
138
|
], "zed"),
|
|
139
|
+
// Cline / Roo Code store their actual settings in VS Code extension globalStorage,
|
|
140
|
+
// but `snap tools configure --cline/--roo-code` writes to these paths as a side-channel.
|
|
141
|
+
// Detection via these paths is best-effort; users may need `snap mcp link --client cline` instead.
|
|
57
142
|
cline: /* @__PURE__ */ __name2((home) => [
|
|
58
143
|
join(home, ".cline/mcp.json")
|
|
59
144
|
], "cline"),
|
|
@@ -71,19 +156,26 @@ var CLIENT_CONFIGS = {
|
|
|
71
156
|
const workspaceConfig = cwd ? [
|
|
72
157
|
join(cwd, ".qoder-mcp-config.json")
|
|
73
158
|
] : [];
|
|
74
|
-
const
|
|
159
|
+
const globalConfigs = (() => {
|
|
75
160
|
switch (platform()) {
|
|
76
161
|
case "darwin":
|
|
77
|
-
return
|
|
162
|
+
return [
|
|
163
|
+
join(home, "Library/Application Support/Qoder/SharedClientCache/mcp.json"),
|
|
164
|
+
join(home, "Library/Application Support/Qoder/SharedClientCache/extension/local/mcp.json")
|
|
165
|
+
];
|
|
78
166
|
case "win32":
|
|
79
|
-
return
|
|
167
|
+
return [
|
|
168
|
+
join(process.env.APPDATA || "", "Qoder/mcp.json")
|
|
169
|
+
];
|
|
80
170
|
default:
|
|
81
|
-
return
|
|
171
|
+
return [
|
|
172
|
+
join(home, ".config/Qoder/mcp.json")
|
|
173
|
+
];
|
|
82
174
|
}
|
|
83
175
|
})();
|
|
84
176
|
return [
|
|
85
177
|
...workspaceConfig,
|
|
86
|
-
|
|
178
|
+
...globalConfigs
|
|
87
179
|
];
|
|
88
180
|
}, "qoder")
|
|
89
181
|
};
|
|
@@ -106,7 +198,12 @@ function detectAIClients(options = {}) {
|
|
|
106
198
|
const clients = [];
|
|
107
199
|
const seenPaths = /* @__PURE__ */ new Set();
|
|
108
200
|
for (const [name, getPaths] of Object.entries(CLIENT_CONFIGS)) {
|
|
109
|
-
const
|
|
201
|
+
const candidates = getPaths(home, cwd);
|
|
202
|
+
const cachedPath = getCachedPath(name);
|
|
203
|
+
const paths = cachedPath && candidates.includes(cachedPath) ? [
|
|
204
|
+
cachedPath,
|
|
205
|
+
...candidates.filter((p) => p !== cachedPath)
|
|
206
|
+
] : candidates;
|
|
110
207
|
for (const configPath of paths) {
|
|
111
208
|
if (seenPaths.has(configPath)) {
|
|
112
209
|
continue;
|
|
@@ -115,6 +212,7 @@ function detectAIClients(options = {}) {
|
|
|
115
212
|
const exists = existsSync(configPath);
|
|
116
213
|
let hasSnapback = false;
|
|
117
214
|
if (exists) {
|
|
215
|
+
setCachedPath(name, configPath);
|
|
118
216
|
try {
|
|
119
217
|
const content = readFileSync(configPath, "utf-8");
|
|
120
218
|
if (configPath.endsWith(".yaml") || configPath.endsWith(".yml")) {
|
|
@@ -169,12 +267,17 @@ function checkForSnapback(config, format) {
|
|
|
169
267
|
case "windsurf":
|
|
170
268
|
case "cline":
|
|
171
269
|
case "roo-code":
|
|
172
|
-
case "qoder":
|
|
173
270
|
if ("mcpServers" in configObj && typeof configObj.mcpServers === "object" && configObj.mcpServers !== null) {
|
|
174
271
|
const servers = configObj.mcpServers;
|
|
175
272
|
return "snapback" in servers || `snapback-${format}` in servers;
|
|
176
273
|
}
|
|
177
274
|
return false;
|
|
275
|
+
case "qoder":
|
|
276
|
+
if ("mcpServers" in configObj && typeof configObj.mcpServers === "object" && configObj.mcpServers !== null) {
|
|
277
|
+
const servers = configObj.mcpServers;
|
|
278
|
+
return Object.keys(servers).some((k) => k === "snapback" || k.startsWith("snapback-"));
|
|
279
|
+
}
|
|
280
|
+
return false;
|
|
178
281
|
case "vscode":
|
|
179
282
|
if ("servers" in configObj && typeof configObj.servers === "object" && configObj.servers !== null) {
|
|
180
283
|
const servers = configObj.servers;
|
|
@@ -793,14 +896,11 @@ var STDIO_ONLY_CLIENTS = /* @__PURE__ */ new Set([
|
|
|
793
896
|
"claude"
|
|
794
897
|
]);
|
|
795
898
|
function getSnapbackMCPConfig(options = {}) {
|
|
796
|
-
const { apiKey, workspaceId, serverUrl, useBinary = false, customCommand, additionalEnv, workspaceRoot, useLocalDev = false, localCliPath, client } = options;
|
|
899
|
+
const { apiKey, workspaceId, serverUrl, useBinary = false, customCommand, additionalEnv, workspaceRoot, useLocalDev = false, localCliPath, client, useDoppler = false, dopplerProject = "snapback-shared", dopplerConfig = "dev", useSse = false, useStreamableHttp = false } = options;
|
|
797
900
|
const useNpx = options.useNpx ?? (client ? STDIO_ONLY_CLIENTS.has(client) : false);
|
|
798
901
|
const env = {
|
|
799
902
|
...additionalEnv
|
|
800
903
|
};
|
|
801
|
-
if (workspaceId) {
|
|
802
|
-
env.SNAPBACK_WORKSPACE_ID = workspaceId;
|
|
803
|
-
}
|
|
804
904
|
if (apiKey) {
|
|
805
905
|
env.SNAPBACK_API_KEY = apiKey;
|
|
806
906
|
}
|
|
@@ -813,9 +913,65 @@ function getSnapbackMCPConfig(options = {}) {
|
|
|
813
913
|
}
|
|
814
914
|
};
|
|
815
915
|
}
|
|
916
|
+
if (useSse || useStreamableHttp) {
|
|
917
|
+
const url = serverUrl || "https://mcp.snapback.dev/mcp";
|
|
918
|
+
const headers2 = {};
|
|
919
|
+
if (workspaceId) {
|
|
920
|
+
headers2["x-workspace-id"] = workspaceId;
|
|
921
|
+
}
|
|
922
|
+
if (apiKey) {
|
|
923
|
+
headers2["x-api-key"] = apiKey;
|
|
924
|
+
}
|
|
925
|
+
return {
|
|
926
|
+
url,
|
|
927
|
+
...Object.keys(headers2).length > 0 && {
|
|
928
|
+
headers: headers2
|
|
929
|
+
}
|
|
930
|
+
};
|
|
931
|
+
}
|
|
932
|
+
if (useDoppler && localCliPath) {
|
|
933
|
+
const tier = apiKey ? "pro" : "free";
|
|
934
|
+
const nodePath = resolveNodePath();
|
|
935
|
+
const dopplerArgs = [
|
|
936
|
+
"run",
|
|
937
|
+
"--project",
|
|
938
|
+
dopplerProject,
|
|
939
|
+
"--config",
|
|
940
|
+
dopplerConfig,
|
|
941
|
+
"--",
|
|
942
|
+
nodePath,
|
|
943
|
+
localCliPath,
|
|
944
|
+
"mcp",
|
|
945
|
+
"--stdio",
|
|
946
|
+
"--tier",
|
|
947
|
+
tier
|
|
948
|
+
];
|
|
949
|
+
if (workspaceRoot) {
|
|
950
|
+
dopplerArgs.push("--workspace", workspaceRoot);
|
|
951
|
+
}
|
|
952
|
+
return {
|
|
953
|
+
command: "doppler",
|
|
954
|
+
args: dopplerArgs
|
|
955
|
+
};
|
|
956
|
+
}
|
|
816
957
|
if (useNpx) {
|
|
958
|
+
const isClaudeDesktop = client === "claude";
|
|
959
|
+
if (isClaudeDesktop) {
|
|
960
|
+
const args2 = [
|
|
961
|
+
"--yes",
|
|
962
|
+
"@snapback/mcpb"
|
|
963
|
+
];
|
|
964
|
+
if (workspaceRoot) {
|
|
965
|
+
args2.push(workspaceRoot);
|
|
966
|
+
}
|
|
967
|
+
return {
|
|
968
|
+
command: "npx",
|
|
969
|
+
args: args2
|
|
970
|
+
};
|
|
971
|
+
}
|
|
817
972
|
const tier = apiKey ? "pro" : "free";
|
|
818
973
|
const args = [
|
|
974
|
+
"--yes",
|
|
819
975
|
"@snapback/cli",
|
|
820
976
|
"mcp",
|
|
821
977
|
"--stdio",
|
|
@@ -833,12 +989,19 @@ function getSnapbackMCPConfig(options = {}) {
|
|
|
833
989
|
}
|
|
834
990
|
};
|
|
835
991
|
}
|
|
836
|
-
if (serverUrl || !useLocalDev && !useBinary) {
|
|
837
|
-
const url = serverUrl || "https://
|
|
992
|
+
if (serverUrl || !useLocalDev && !useBinary && !useDoppler) {
|
|
993
|
+
const url = serverUrl || "https://mcp.snapback.dev/mcp";
|
|
994
|
+
const headers2 = {};
|
|
995
|
+
if (workspaceId) {
|
|
996
|
+
headers2["x-workspace-id"] = workspaceId;
|
|
997
|
+
}
|
|
998
|
+
if (apiKey) {
|
|
999
|
+
headers2["x-api-key"] = apiKey;
|
|
1000
|
+
}
|
|
838
1001
|
return {
|
|
839
1002
|
url,
|
|
840
|
-
...Object.keys(
|
|
841
|
-
|
|
1003
|
+
...Object.keys(headers2).length > 0 && {
|
|
1004
|
+
headers: headers2
|
|
842
1005
|
}
|
|
843
1006
|
};
|
|
844
1007
|
}
|
|
@@ -882,10 +1045,17 @@ function getSnapbackMCPConfig(options = {}) {
|
|
|
882
1045
|
}
|
|
883
1046
|
};
|
|
884
1047
|
}
|
|
1048
|
+
const headers = {};
|
|
1049
|
+
if (workspaceId) {
|
|
1050
|
+
headers["x-workspace-id"] = workspaceId;
|
|
1051
|
+
}
|
|
1052
|
+
if (apiKey) {
|
|
1053
|
+
headers["x-api-key"] = apiKey;
|
|
1054
|
+
}
|
|
885
1055
|
return {
|
|
886
|
-
url: "https://
|
|
887
|
-
...Object.keys(
|
|
888
|
-
|
|
1056
|
+
url: "https://mcp.snapback.dev/mcp",
|
|
1057
|
+
...Object.keys(headers).length > 0 && {
|
|
1058
|
+
headers
|
|
889
1059
|
}
|
|
890
1060
|
};
|
|
891
1061
|
}
|
|
@@ -986,6 +1156,7 @@ function removeSnapbackConfig(client) {
|
|
|
986
1156
|
}
|
|
987
1157
|
}
|
|
988
1158
|
writeFileSync(client.configPath, JSON.stringify(config, null, 2));
|
|
1159
|
+
evictCachedPath(client.name);
|
|
989
1160
|
return {
|
|
990
1161
|
success: true
|
|
991
1162
|
};
|
|
@@ -1033,17 +1204,19 @@ function mergeConfig(existing, snapbackConfig, format) {
|
|
|
1033
1204
|
}
|
|
1034
1205
|
}
|
|
1035
1206
|
};
|
|
1036
|
-
case "qoder":
|
|
1207
|
+
case "qoder": {
|
|
1208
|
+
const qoderType = snapbackConfig.url ? "sse" : "stdio";
|
|
1037
1209
|
return {
|
|
1038
1210
|
...existing,
|
|
1039
1211
|
mcpServers: {
|
|
1040
1212
|
...existing.mcpServers || {},
|
|
1041
1213
|
[serverKey]: {
|
|
1042
|
-
type:
|
|
1214
|
+
type: qoderType,
|
|
1043
1215
|
...snapbackConfig
|
|
1044
1216
|
}
|
|
1045
1217
|
}
|
|
1046
1218
|
};
|
|
1219
|
+
}
|
|
1047
1220
|
case "vscode": {
|
|
1048
1221
|
const vscodeConfig = existing;
|
|
1049
1222
|
const servers = vscodeConfig.servers || {};
|
|
@@ -1105,6 +1278,87 @@ function mergeConfig(existing, snapbackConfig, format) {
|
|
|
1105
1278
|
}
|
|
1106
1279
|
__name(mergeConfig, "mergeConfig");
|
|
1107
1280
|
__name2(mergeConfig, "mergeConfig");
|
|
1281
|
+
function patchApiKeyInClientConfig(client, apiKey) {
|
|
1282
|
+
try {
|
|
1283
|
+
if (!existsSync(client.configPath)) return false;
|
|
1284
|
+
const raw = readFileSync(client.configPath, "utf-8");
|
|
1285
|
+
const config = JSON.parse(raw);
|
|
1286
|
+
const serverKey = getServerKey(client.format);
|
|
1287
|
+
let patched = false;
|
|
1288
|
+
const patchEntry = /* @__PURE__ */ __name2((entry) => {
|
|
1289
|
+
if (typeof entry !== "object" || entry === null) return false;
|
|
1290
|
+
const e = entry;
|
|
1291
|
+
if (e.url && typeof e.url === "string") {
|
|
1292
|
+
if (!e.headers || typeof e.headers !== "object") {
|
|
1293
|
+
e.headers = {};
|
|
1294
|
+
}
|
|
1295
|
+
e.headers["x-api-key"] = apiKey;
|
|
1296
|
+
const headers = e.headers;
|
|
1297
|
+
if (headers.Authorization?.includes("<your-token>")) {
|
|
1298
|
+
delete headers.Authorization;
|
|
1299
|
+
}
|
|
1300
|
+
return true;
|
|
1301
|
+
}
|
|
1302
|
+
if (!e.env || typeof e.env !== "object") {
|
|
1303
|
+
e.env = {};
|
|
1304
|
+
}
|
|
1305
|
+
e.env.SNAPBACK_API_KEY = apiKey;
|
|
1306
|
+
return true;
|
|
1307
|
+
}, "patchEntry");
|
|
1308
|
+
switch (client.format) {
|
|
1309
|
+
case "claude":
|
|
1310
|
+
case "cursor":
|
|
1311
|
+
case "windsurf":
|
|
1312
|
+
case "cline":
|
|
1313
|
+
case "roo-code":
|
|
1314
|
+
case "gemini": {
|
|
1315
|
+
const servers = config.mcpServers || {};
|
|
1316
|
+
const entry = servers[serverKey] ?? servers.snapback;
|
|
1317
|
+
if (entry) patched = patchEntry(entry);
|
|
1318
|
+
break;
|
|
1319
|
+
}
|
|
1320
|
+
case "qoder": {
|
|
1321
|
+
const servers = config.mcpServers || {};
|
|
1322
|
+
for (const key of Object.keys(servers)) {
|
|
1323
|
+
if (key === "snapback" || key.startsWith("snapback-")) {
|
|
1324
|
+
patched = patchEntry(servers[key]) || patched;
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
break;
|
|
1328
|
+
}
|
|
1329
|
+
case "vscode": {
|
|
1330
|
+
const servers = config.servers || {};
|
|
1331
|
+
const entry = servers[serverKey] ?? servers.snapback;
|
|
1332
|
+
if (entry) patched = patchEntry(entry);
|
|
1333
|
+
break;
|
|
1334
|
+
}
|
|
1335
|
+
case "zed": {
|
|
1336
|
+
const servers = config.context_servers || {};
|
|
1337
|
+
const entry = servers[serverKey] ?? servers.snapback;
|
|
1338
|
+
if (entry) patched = patchEntry(entry);
|
|
1339
|
+
break;
|
|
1340
|
+
}
|
|
1341
|
+
case "continue": {
|
|
1342
|
+
const exp = config.experimental || {};
|
|
1343
|
+
const list = exp.modelContextProtocolServers || [];
|
|
1344
|
+
for (const item of list) {
|
|
1345
|
+
if (typeof item.name === "string" && item.name.startsWith("snapback")) {
|
|
1346
|
+
patched = patchEntry(item) || patched;
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
break;
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
if (patched) {
|
|
1353
|
+
writeFileSync(client.configPath, JSON.stringify(config, null, 2));
|
|
1354
|
+
}
|
|
1355
|
+
return patched;
|
|
1356
|
+
} catch {
|
|
1357
|
+
return false;
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
__name(patchApiKeyInClientConfig, "patchApiKeyInClientConfig");
|
|
1361
|
+
__name2(patchApiKeyInClientConfig, "patchApiKeyInClientConfig");
|
|
1108
1362
|
function validateConfig(client) {
|
|
1109
1363
|
try {
|
|
1110
1364
|
const content = readFileSync(client.configPath, "utf-8");
|
|
@@ -1418,6 +1672,4 @@ function findCliPath() {
|
|
|
1418
1672
|
__name(findCliPath, "findCliPath");
|
|
1419
1673
|
__name2(findCliPath, "findCliPath");
|
|
1420
1674
|
|
|
1421
|
-
export { createManagedMetadata, detectAIClients, detectMCPProcesses, detectWorkspaceConfig, getClient, getClientConfigPath, getConfiguredClients, getOrCreateIdentity, getServerKey, getSnapbackConfigDir, getSnapbackMCPConfig, injectWorkspacePath, isCommandExecutable2, isOwnedByThisInstall, isSnapbackMCPRunning, readClientConfig, removeSnapbackConfig, repairClientConfig, resetIdentityCache, resolveNodePath, validateClientConfig, validateConfig, validateWorkspacePath, writeClientConfig };
|
|
1422
|
-
//# sourceMappingURL=chunk-2TOJVUVJ.js.map
|
|
1423
|
-
//# sourceMappingURL=chunk-2TOJVUVJ.js.map
|
|
1675
|
+
export { createManagedMetadata, detectAIClients, detectMCPProcesses, detectWorkspaceConfig, evictCachedPath, getAllCachedPaths, getCachedPath, getClient, getClientConfigPath, getConfiguredClients, getOrCreateIdentity, getServerKey, getSnapbackConfigDir, getSnapbackMCPConfig, injectWorkspacePath, isCommandExecutable2, isOwnedByThisInstall, isSnapbackMCPRunning, patchApiKeyInClientConfig, readClientConfig, removeSnapbackConfig, repairClientConfig, resetIdentityCache, resolveNodePath, setCachedPath, validateClientConfig, validateConfig, validateWorkspacePath, writeClientConfig };
|