@taptap/maker 0.0.21-beta.2 → 0.0.21-beta.3
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 +1 -1
- package/dist/maker.js +374 -52
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/maker.js
CHANGED
|
@@ -34260,7 +34260,7 @@ function applyDefaults(config2) {
|
|
|
34260
34260
|
}
|
|
34261
34261
|
|
|
34262
34262
|
// src/maker/server/mcp.ts
|
|
34263
|
-
var VERSION = true ? "0.0.21-beta.
|
|
34263
|
+
var VERSION = true ? "0.0.21-beta.3" : "dev";
|
|
34264
34264
|
var DEFAULT_BUILD_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
34265
34265
|
var DEFAULT_PROXY_RETRY_ATTEMPTS = 5;
|
|
34266
34266
|
var DEFAULT_PROXY_RETRY_DELAY_MS = 30 * 1e3;
|
|
@@ -36663,7 +36663,7 @@ function formatError2(error2) {
|
|
|
36663
36663
|
}
|
|
36664
36664
|
|
|
36665
36665
|
// src/maker/cli/commands.ts
|
|
36666
|
-
var VERSION2 = true ? "0.0.21-beta.
|
|
36666
|
+
var VERSION2 = true ? "0.0.21-beta.3" : "dev";
|
|
36667
36667
|
var DEFAULT_MCP_NAME = "taptap-maker";
|
|
36668
36668
|
var MAKER_NPM_PACKAGE = "@taptap/maker";
|
|
36669
36669
|
var TWO_PART_COMMANDS = /* @__PURE__ */ new Set(["pat", "mcp", "dev-kit", "logs", "python", "lua-lsp", "agents"]);
|
|
@@ -36866,9 +36866,9 @@ async function runInit(parsed, ctx) {
|
|
|
36866
36866
|
environment: env
|
|
36867
36867
|
});
|
|
36868
36868
|
if (!skipMcpInstall) {
|
|
36869
|
-
const ides = parseIdeList(stringOption(parsed, "register_mcp") || "
|
|
36869
|
+
const ides = parseIdeList(stringOption(parsed, "register_mcp") || "");
|
|
36870
36870
|
const installResults = installMcpConfigs({
|
|
36871
|
-
ides,
|
|
36871
|
+
ides: ides.length > 0 ? ides : getDefaultMcpInstallIdes(),
|
|
36872
36872
|
env,
|
|
36873
36873
|
pkg: MAKER_NPM_PACKAGE,
|
|
36874
36874
|
mcpName: DEFAULT_MCP_NAME
|
|
@@ -37366,7 +37366,7 @@ async function runMcpInstall(parsed, ctx) {
|
|
|
37366
37366
|
const ides = parseIdeList(stringOption(parsed, "ide") || stringOption(parsed, "ides") || "");
|
|
37367
37367
|
const explicitTargetDir = stringOption(parsed, "target_dir");
|
|
37368
37368
|
const results = installMcpConfigs({
|
|
37369
|
-
ides: ides.length > 0 ? ides :
|
|
37369
|
+
ides: ides.length > 0 ? ides : getDefaultMcpInstallIdes(),
|
|
37370
37370
|
env: makerEnvOption(parsed),
|
|
37371
37371
|
pkg: MAKER_NPM_PACKAGE,
|
|
37372
37372
|
mcpName: stringOption(parsed, "name") || DEFAULT_MCP_NAME,
|
|
@@ -37452,7 +37452,7 @@ async function runUpgrade(parsed, ctx) {
|
|
|
37452
37452
|
const env = makerEnvOption(parsed);
|
|
37453
37453
|
const ides = parseIdeList(stringOption(parsed, "ide") || stringOption(parsed, "ides") || "");
|
|
37454
37454
|
const installResults = installMcpConfigs({
|
|
37455
|
-
ides: ides.length > 0 ? ides :
|
|
37455
|
+
ides: ides.length > 0 ? ides : getDefaultMcpInstallIdes(),
|
|
37456
37456
|
env,
|
|
37457
37457
|
pkg: MAKER_NPM_PACKAGE,
|
|
37458
37458
|
mcpName: stringOption(parsed, "name") || DEFAULT_MCP_NAME,
|
|
@@ -37887,85 +37887,241 @@ function isPatValidationFailure(message) {
|
|
|
37887
37887
|
) || /(?:过期|失效)/.test(message);
|
|
37888
37888
|
}
|
|
37889
37889
|
function installMcpConfigs(options) {
|
|
37890
|
-
return options.ides.
|
|
37890
|
+
return uniqueStrings(options.ides).flatMap((ide) => installMcpConfig(ide, options));
|
|
37891
37891
|
}
|
|
37892
37892
|
function installMcpConfig(ide, options) {
|
|
37893
37893
|
try {
|
|
37894
37894
|
return installMcpConfigUnsafe(ide, options);
|
|
37895
37895
|
} catch (error2) {
|
|
37896
|
-
return
|
|
37897
|
-
|
|
37898
|
-
|
|
37899
|
-
|
|
37900
|
-
|
|
37896
|
+
return [
|
|
37897
|
+
{
|
|
37898
|
+
ide,
|
|
37899
|
+
ok: false,
|
|
37900
|
+
message: `✗ ${ide} MCP config update failed: ${error2 instanceof Error ? error2.message : String(error2)}`
|
|
37901
|
+
}
|
|
37902
|
+
];
|
|
37901
37903
|
}
|
|
37902
37904
|
}
|
|
37903
37905
|
function installMcpConfigUnsafe(ide, options) {
|
|
37904
37906
|
if (ide === "codex") {
|
|
37905
37907
|
const configPath = path16.join(os4.homedir(), ".codex", "config.toml");
|
|
37906
37908
|
const write = mergeCodexMcpConfig(configPath, options);
|
|
37907
|
-
return
|
|
37908
|
-
ide,
|
|
37909
|
-
ok: true,
|
|
37910
|
-
path: configPath,
|
|
37911
|
-
changed: write.changed,
|
|
37912
|
-
backupPath: write.backupPath,
|
|
37913
|
-
message: formatMcpInstallMessage("Codex", configPath, write)
|
|
37914
|
-
};
|
|
37909
|
+
return [createMcpInstallResult(ide, "Codex", configPath, write)];
|
|
37915
37910
|
}
|
|
37916
37911
|
if (ide === "cursor") {
|
|
37917
37912
|
const configPath = path16.join(os4.homedir(), ".cursor", "mcp.json");
|
|
37918
37913
|
const write = mergeJsonMcpConfig(configPath, options);
|
|
37919
|
-
return
|
|
37920
|
-
ide,
|
|
37921
|
-
ok: true,
|
|
37922
|
-
path: configPath,
|
|
37923
|
-
changed: write.changed,
|
|
37924
|
-
backupPath: write.backupPath,
|
|
37925
|
-
message: formatMcpInstallMessage("Cursor", configPath, write)
|
|
37926
|
-
};
|
|
37914
|
+
return [createMcpInstallResult(ide, "Cursor", configPath, write)];
|
|
37927
37915
|
}
|
|
37928
37916
|
if (ide === "claude") {
|
|
37929
37917
|
if (!options.cwd) {
|
|
37930
37918
|
const claudeResult = tryClaudeMcpAdd(options);
|
|
37931
37919
|
if (claudeResult.ok) {
|
|
37932
|
-
return
|
|
37920
|
+
return [
|
|
37921
|
+
{
|
|
37922
|
+
ide,
|
|
37923
|
+
ok: true,
|
|
37924
|
+
message: "✓ Claude Code MCP config updated with claude mcp add"
|
|
37925
|
+
}
|
|
37926
|
+
];
|
|
37933
37927
|
}
|
|
37934
37928
|
}
|
|
37935
37929
|
const configPath = path16.join(os4.homedir(), ".claude.json");
|
|
37936
37930
|
const write = mergeJsonMcpConfig(configPath, options);
|
|
37937
|
-
return
|
|
37931
|
+
return [createMcpInstallResult(ide, "Claude fallback", configPath, write)];
|
|
37932
|
+
}
|
|
37933
|
+
if (ide === "trae") {
|
|
37934
|
+
return installJsonMcpConfigTargets(ide, getTraeMcpInstallPaths(), "Trae", options);
|
|
37935
|
+
}
|
|
37936
|
+
if (ide === "opencode") {
|
|
37937
|
+
const configPath = getOpenCodeMcpConfigPath();
|
|
37938
|
+
if (!fs15.existsSync(configPath)) {
|
|
37939
|
+
return [{ ide, ok: false, message: "Skipped OpenCode: no supported config file found" }];
|
|
37940
|
+
}
|
|
37941
|
+
const write = mergeOpenCodeMcpConfig(configPath, options);
|
|
37942
|
+
const result = createMcpInstallResult(ide, "OpenCode", configPath, write);
|
|
37943
|
+
if (write.changed) {
|
|
37944
|
+
result.message += "\n Note: OpenCode config was rewritten as standard JSON.";
|
|
37945
|
+
}
|
|
37946
|
+
return [result];
|
|
37947
|
+
}
|
|
37948
|
+
if (ide === "workbuddy") {
|
|
37949
|
+
return installJsonMcpConfigTargets(
|
|
37938
37950
|
ide,
|
|
37939
|
-
|
|
37940
|
-
|
|
37941
|
-
|
|
37942
|
-
|
|
37943
|
-
message: formatMcpInstallMessage("Claude fallback", configPath, write)
|
|
37944
|
-
};
|
|
37951
|
+
getWorkBuddyMcpInstallPaths(options.mcpName),
|
|
37952
|
+
"WorkBuddy",
|
|
37953
|
+
options
|
|
37954
|
+
);
|
|
37945
37955
|
}
|
|
37946
|
-
return { ide, ok: false, message: `Skipped unknown IDE: ${ide}` };
|
|
37956
|
+
return [{ ide, ok: false, message: `Skipped unknown IDE: ${ide}` }];
|
|
37957
|
+
}
|
|
37958
|
+
function installJsonMcpConfigTargets(ide, configPaths, label, options) {
|
|
37959
|
+
if (configPaths.length === 0) {
|
|
37960
|
+
return [{ ide, ok: false, message: `Skipped ${label}: no supported config file found` }];
|
|
37961
|
+
}
|
|
37962
|
+
return configPaths.map((configPath) => {
|
|
37963
|
+
try {
|
|
37964
|
+
const write = mergeJsonMcpConfig(configPath, options);
|
|
37965
|
+
return createMcpInstallResult(ide, label, configPath, write);
|
|
37966
|
+
} catch (error2) {
|
|
37967
|
+
return {
|
|
37968
|
+
ide,
|
|
37969
|
+
ok: false,
|
|
37970
|
+
path: configPath,
|
|
37971
|
+
message: `✗ ${label} MCP config update failed for ${configPath}: ${error2 instanceof Error ? error2.message : String(error2)}`
|
|
37972
|
+
};
|
|
37973
|
+
}
|
|
37974
|
+
});
|
|
37975
|
+
}
|
|
37976
|
+
function createMcpInstallResult(ide, label, configPath, write) {
|
|
37977
|
+
return {
|
|
37978
|
+
ide,
|
|
37979
|
+
ok: true,
|
|
37980
|
+
path: configPath,
|
|
37981
|
+
changed: write.changed,
|
|
37982
|
+
backupPath: write.backupPath,
|
|
37983
|
+
message: formatMcpInstallMessage(label, configPath, write)
|
|
37984
|
+
};
|
|
37985
|
+
}
|
|
37986
|
+
function getDefaultMcpInstallIdes() {
|
|
37987
|
+
const ides = ["codex", "cursor", "claude"];
|
|
37988
|
+
if (getTraeMcpInstallPaths().length > 0) {
|
|
37989
|
+
ides.push("trae");
|
|
37990
|
+
}
|
|
37991
|
+
if (fs15.existsSync(getOpenCodeMcpConfigPath())) {
|
|
37992
|
+
ides.push("opencode");
|
|
37993
|
+
}
|
|
37994
|
+
if (getWorkBuddyMcpInstallPaths(DEFAULT_MCP_NAME).length > 0) {
|
|
37995
|
+
ides.push("workbuddy");
|
|
37996
|
+
}
|
|
37997
|
+
return ides;
|
|
37998
|
+
}
|
|
37999
|
+
function getTraeMcpInstallPaths() {
|
|
38000
|
+
const soloPaths = getExistingTraeUserConfigPaths(getTraeSoloMcpConfigPaths());
|
|
38001
|
+
const unverifiedPaths = getExistingConfigPaths(getTraeUnverifiedMcpConfigPaths());
|
|
38002
|
+
return uniqueStrings([...soloPaths, ...unverifiedPaths]);
|
|
38003
|
+
}
|
|
38004
|
+
function getExistingTraeUserConfigPaths(paths) {
|
|
38005
|
+
const seen = /* @__PURE__ */ new Set();
|
|
38006
|
+
return paths.filter((configPath) => {
|
|
38007
|
+
const key = normalizeConfigPathKey(configPath);
|
|
38008
|
+
if (seen.has(key) || !fs15.existsSync(path16.dirname(configPath))) {
|
|
38009
|
+
return false;
|
|
38010
|
+
}
|
|
38011
|
+
seen.add(key);
|
|
38012
|
+
return true;
|
|
38013
|
+
});
|
|
38014
|
+
}
|
|
38015
|
+
function getExistingConfigPaths(paths) {
|
|
38016
|
+
const seen = /* @__PURE__ */ new Set();
|
|
38017
|
+
return paths.filter((configPath) => {
|
|
38018
|
+
const key = normalizeConfigPathKey(configPath);
|
|
38019
|
+
if (seen.has(key) || !fs15.existsSync(configPath)) {
|
|
38020
|
+
return false;
|
|
38021
|
+
}
|
|
38022
|
+
seen.add(key);
|
|
38023
|
+
return true;
|
|
38024
|
+
});
|
|
38025
|
+
}
|
|
38026
|
+
function normalizeConfigPathKey(configPath) {
|
|
38027
|
+
const resolved = path16.resolve(configPath);
|
|
38028
|
+
return process.platform === "win32" || process.platform === "darwin" ? resolved.toLowerCase() : resolved;
|
|
38029
|
+
}
|
|
38030
|
+
function getTraeSoloMcpConfigPaths() {
|
|
38031
|
+
if (process.platform === "win32") {
|
|
38032
|
+
const roaming = process.env.APPDATA || path16.join(os4.homedir(), "AppData", "Roaming");
|
|
38033
|
+
return [
|
|
38034
|
+
path16.join(roaming, "TRAE SOLO", "User", "mcp.json"),
|
|
38035
|
+
path16.join(roaming, "TRAE SOLO CN", "User", "mcp.json")
|
|
38036
|
+
];
|
|
38037
|
+
}
|
|
38038
|
+
const appSupport = path16.join(os4.homedir(), "Library", "Application Support");
|
|
38039
|
+
return [
|
|
38040
|
+
path16.join(appSupport, "TRAE SOLO CN", "User", "mcp.json"),
|
|
38041
|
+
path16.join(appSupport, "TRAE SOLO", "User", "mcp.json")
|
|
38042
|
+
];
|
|
38043
|
+
}
|
|
38044
|
+
function getTraeUnverifiedMcpConfigPaths() {
|
|
38045
|
+
if (process.platform === "win32") {
|
|
38046
|
+
const roaming = process.env.APPDATA || path16.join(os4.homedir(), "AppData", "Roaming");
|
|
38047
|
+
return [
|
|
38048
|
+
path16.join(roaming, "Trae", "User", "mcp.json"),
|
|
38049
|
+
path16.join(roaming, "TRAE", "User", "mcp.json"),
|
|
38050
|
+
path16.join(roaming, "Trae CN", "User", "mcp.json")
|
|
38051
|
+
];
|
|
38052
|
+
}
|
|
38053
|
+
const appSupport = path16.join(os4.homedir(), "Library", "Application Support");
|
|
38054
|
+
return [
|
|
38055
|
+
path16.join(appSupport, "Trae", "User", "mcp.json"),
|
|
38056
|
+
path16.join(appSupport, "TRAE", "User", "mcp.json"),
|
|
38057
|
+
path16.join(appSupport, "Trae CN", "User", "mcp.json")
|
|
38058
|
+
];
|
|
38059
|
+
}
|
|
38060
|
+
function getOpenCodeMcpConfigPath() {
|
|
38061
|
+
return path16.join(os4.homedir(), ".config", "opencode", "opencode.jsonc");
|
|
38062
|
+
}
|
|
38063
|
+
function getWorkBuddyMcpInstallPaths(_mcpName) {
|
|
38064
|
+
const primary = path16.join(os4.homedir(), ".workbuddy", "mcp.json");
|
|
38065
|
+
const runtime = path16.join(os4.homedir(), ".workbuddy", ".mcp.json");
|
|
38066
|
+
const preferred = process.platform === "win32" ? primary : runtime;
|
|
38067
|
+
const fallback = process.platform === "win32" ? runtime : primary;
|
|
38068
|
+
const paths = [];
|
|
38069
|
+
if (fs15.existsSync(preferred)) {
|
|
38070
|
+
paths.push(preferred);
|
|
38071
|
+
}
|
|
38072
|
+
if (fs15.existsSync(fallback)) {
|
|
38073
|
+
paths.push(fallback);
|
|
38074
|
+
}
|
|
38075
|
+
return paths;
|
|
37947
38076
|
}
|
|
37948
38077
|
function mergeJsonMcpConfig(configPath, options) {
|
|
37949
38078
|
const existing = readJsonObject(configPath);
|
|
37950
38079
|
const mcpServers = asObject(existing.mcpServers);
|
|
37951
38080
|
mcpServers[options.mcpName] = createJsonMcpServerConfig(options);
|
|
37952
38081
|
existing.mcpServers = mcpServers;
|
|
37953
|
-
return writeConfigWithTapTapBackupIfChanged(
|
|
37954
|
-
|
|
38082
|
+
return writeConfigWithTapTapBackupIfChanged(
|
|
38083
|
+
configPath,
|
|
38084
|
+
`${JSON.stringify(existing, null, 2)}
|
|
38085
|
+
`,
|
|
38086
|
+
(updated) => validateJsonMcpServersConfig(updated, options)
|
|
38087
|
+
);
|
|
38088
|
+
}
|
|
38089
|
+
function mergeOpenCodeMcpConfig(configPath, options) {
|
|
38090
|
+
const existing = readJsonObject(configPath, { jsonc: true });
|
|
38091
|
+
const mcp = asObject(existing.mcp);
|
|
38092
|
+
mcp[options.mcpName] = createOpenCodeMcpServerConfig(options);
|
|
38093
|
+
existing.mcp = mcp;
|
|
38094
|
+
const mcpServers = asObject(existing.mcpServers);
|
|
38095
|
+
if (Object.prototype.hasOwnProperty.call(mcpServers, options.mcpName)) {
|
|
38096
|
+
delete mcpServers[options.mcpName];
|
|
38097
|
+
if (Object.keys(mcpServers).length === 0) {
|
|
38098
|
+
delete existing.mcpServers;
|
|
38099
|
+
} else {
|
|
38100
|
+
existing.mcpServers = mcpServers;
|
|
38101
|
+
}
|
|
38102
|
+
}
|
|
38103
|
+
if (!existing.$schema) {
|
|
38104
|
+
existing.$schema = "https://opencode.ai/config.json";
|
|
38105
|
+
}
|
|
38106
|
+
return writeConfigWithTapTapBackupIfChanged(
|
|
38107
|
+
configPath,
|
|
38108
|
+
`${JSON.stringify(existing, null, 2)}
|
|
38109
|
+
`,
|
|
38110
|
+
(updated) => validateOpenCodeMcpConfig(updated, options)
|
|
38111
|
+
);
|
|
37955
38112
|
}
|
|
37956
38113
|
function mergeCodexMcpConfig(configPath, options) {
|
|
37957
38114
|
const existing = fs15.existsSync(configPath) ? fs15.readFileSync(configPath, "utf8") : "";
|
|
37958
38115
|
const sectionPattern = createCodexMcpSectionPattern(options.mcpName);
|
|
37959
38116
|
const withoutOld = existing.replace(sectionPattern, "").trimEnd();
|
|
37960
38117
|
const launch = getNpxCliCommand(options.pkg);
|
|
38118
|
+
const envSection = options.env === "production" ? [] : ["", `[mcp_servers."${options.mcpName}".env]`, `TAPTAP_MCP_ENV = "${options.env}"`];
|
|
37961
38119
|
const section = [
|
|
37962
38120
|
`[mcp_servers."${options.mcpName}"]`,
|
|
37963
38121
|
`command = "${escapeToml(launch.command)}"`,
|
|
37964
38122
|
`args = [${launch.args.map((arg) => `"${escapeToml(arg)}"`).join(", ")}]`,
|
|
37965
38123
|
options.cwd ? `cwd = "${escapeToml(options.cwd)}"` : "",
|
|
37966
|
-
|
|
37967
|
-
`[mcp_servers."${options.mcpName}".env]`,
|
|
37968
|
-
`TAPTAP_MCP_ENV = "${options.env}"`,
|
|
38124
|
+
...envSection,
|
|
37969
38125
|
""
|
|
37970
38126
|
].join("\n");
|
|
37971
38127
|
return writeConfigWithTapTapBackupIfChanged(
|
|
@@ -38032,8 +38188,7 @@ function tryClaudeMcpAdd(options) {
|
|
|
38032
38188
|
"user",
|
|
38033
38189
|
"--transport",
|
|
38034
38190
|
"stdio",
|
|
38035
|
-
"--env",
|
|
38036
|
-
`TAPTAP_MCP_ENV=${options.env}`,
|
|
38191
|
+
...options.env === "production" ? [] : ["--env", `TAPTAP_MCP_ENV=${options.env}`],
|
|
38037
38192
|
options.mcpName,
|
|
38038
38193
|
"--",
|
|
38039
38194
|
...npxLaunch.commandAndArgs
|
|
@@ -38052,11 +38207,31 @@ function createJsonMcpServerConfig(options) {
|
|
|
38052
38207
|
command: launch.command,
|
|
38053
38208
|
args: launch.args,
|
|
38054
38209
|
...options.cwd ? { cwd: options.cwd } : {},
|
|
38055
|
-
env
|
|
38056
|
-
|
|
38210
|
+
...createOptionalMcpEnvironment(options.env, "env")
|
|
38211
|
+
};
|
|
38212
|
+
}
|
|
38213
|
+
function createOpenCodeMcpServerConfig(options) {
|
|
38214
|
+
return {
|
|
38215
|
+
type: "local",
|
|
38216
|
+
command: getOpenCodeNpxCliCommand(options.pkg),
|
|
38217
|
+
...options.cwd ? { cwd: options.cwd } : {},
|
|
38218
|
+
enabled: true
|
|
38219
|
+
};
|
|
38220
|
+
}
|
|
38221
|
+
function createOptionalMcpEnvironment(env, key) {
|
|
38222
|
+
if (env === "production") {
|
|
38223
|
+
return {};
|
|
38224
|
+
}
|
|
38225
|
+
return {
|
|
38226
|
+
[key]: {
|
|
38227
|
+
TAPTAP_MCP_ENV: env
|
|
38057
38228
|
}
|
|
38058
38229
|
};
|
|
38059
38230
|
}
|
|
38231
|
+
function getOpenCodeNpxCliCommand(pkg) {
|
|
38232
|
+
const executable = process.platform === "win32" ? "npx.cmd" : "npx";
|
|
38233
|
+
return [executable, "-y", "-p", pkg, "taptap-maker"];
|
|
38234
|
+
}
|
|
38060
38235
|
function getCurrentCliCommand() {
|
|
38061
38236
|
if (process.argv[1]) {
|
|
38062
38237
|
return { command: process.execPath, args: [process.argv[1]] };
|
|
@@ -38088,11 +38263,22 @@ function rejectPackageOption(parsed) {
|
|
|
38088
38263
|
);
|
|
38089
38264
|
}
|
|
38090
38265
|
}
|
|
38091
|
-
function readJsonObject(filePath) {
|
|
38266
|
+
function readJsonObject(filePath, options = {}) {
|
|
38092
38267
|
if (!fs15.existsSync(filePath)) {
|
|
38093
38268
|
return {};
|
|
38094
38269
|
}
|
|
38095
|
-
|
|
38270
|
+
const raw = fs15.readFileSync(filePath, "utf8");
|
|
38271
|
+
try {
|
|
38272
|
+
const normalized = options.jsonc ? normalizeJsonc(raw) : raw;
|
|
38273
|
+
const parsed = JSON.parse(normalized);
|
|
38274
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
38275
|
+
throw new Error("top-level value must be an object");
|
|
38276
|
+
}
|
|
38277
|
+
return parsed;
|
|
38278
|
+
} catch (error2) {
|
|
38279
|
+
const detail = error2 instanceof Error ? error2.message : String(error2);
|
|
38280
|
+
throw new Error(`Invalid JSON in ${filePath}: ${detail}`);
|
|
38281
|
+
}
|
|
38096
38282
|
}
|
|
38097
38283
|
function asObject(value) {
|
|
38098
38284
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
@@ -38124,6 +38310,131 @@ function writeConfigWithTapTapBackupIfChanged(filePath, nextContent, validate) {
|
|
|
38124
38310
|
throw error2;
|
|
38125
38311
|
}
|
|
38126
38312
|
}
|
|
38313
|
+
function validateJsonMcpServersConfig(content, options) {
|
|
38314
|
+
const parsed = parseGeneratedJsonObject(content);
|
|
38315
|
+
const server = asObject(asObject(parsed.mcpServers)[options.mcpName]);
|
|
38316
|
+
const expected = createJsonMcpServerConfig(options);
|
|
38317
|
+
if (!deepJsonEqual(server, expected)) {
|
|
38318
|
+
throw new Error(`Generated MCP config for ${options.mcpName} failed validation.`);
|
|
38319
|
+
}
|
|
38320
|
+
}
|
|
38321
|
+
function validateOpenCodeMcpConfig(content, options) {
|
|
38322
|
+
const parsed = parseGeneratedJsonObject(content);
|
|
38323
|
+
const server = asObject(asObject(parsed.mcp)[options.mcpName]);
|
|
38324
|
+
const expected = createOpenCodeMcpServerConfig(options);
|
|
38325
|
+
if (!deepJsonEqual(server, expected)) {
|
|
38326
|
+
throw new Error(`Generated OpenCode MCP config for ${options.mcpName} failed validation.`);
|
|
38327
|
+
}
|
|
38328
|
+
const legacyServer = asObject(parsed.mcpServers)[options.mcpName];
|
|
38329
|
+
if (legacyServer !== void 0) {
|
|
38330
|
+
throw new Error(
|
|
38331
|
+
`Generated OpenCode config still contains legacy mcpServers.${options.mcpName}.`
|
|
38332
|
+
);
|
|
38333
|
+
}
|
|
38334
|
+
}
|
|
38335
|
+
function parseGeneratedJsonObject(content) {
|
|
38336
|
+
const parsed = JSON.parse(content);
|
|
38337
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
38338
|
+
throw new Error("Generated JSON config top-level value must be an object.");
|
|
38339
|
+
}
|
|
38340
|
+
return parsed;
|
|
38341
|
+
}
|
|
38342
|
+
function deepJsonEqual(left, right) {
|
|
38343
|
+
return JSON.stringify(left) === JSON.stringify(right);
|
|
38344
|
+
}
|
|
38345
|
+
function normalizeJsonc(content) {
|
|
38346
|
+
return removeTrailingCommas(stripJsonComments(content));
|
|
38347
|
+
}
|
|
38348
|
+
function stripJsonComments(content) {
|
|
38349
|
+
let result = "";
|
|
38350
|
+
let inString = false;
|
|
38351
|
+
let escaped = false;
|
|
38352
|
+
let inLineComment = false;
|
|
38353
|
+
let inBlockComment = false;
|
|
38354
|
+
for (let index = 0; index < content.length; index += 1) {
|
|
38355
|
+
const char = content[index];
|
|
38356
|
+
const next = content[index + 1];
|
|
38357
|
+
if (inLineComment) {
|
|
38358
|
+
if (char === "\n" || char === "\r") {
|
|
38359
|
+
inLineComment = false;
|
|
38360
|
+
result += char;
|
|
38361
|
+
}
|
|
38362
|
+
continue;
|
|
38363
|
+
}
|
|
38364
|
+
if (inBlockComment) {
|
|
38365
|
+
if (char === "*" && next === "/") {
|
|
38366
|
+
inBlockComment = false;
|
|
38367
|
+
index += 1;
|
|
38368
|
+
} else if (char === "\n" || char === "\r") {
|
|
38369
|
+
result += char;
|
|
38370
|
+
}
|
|
38371
|
+
continue;
|
|
38372
|
+
}
|
|
38373
|
+
if (inString) {
|
|
38374
|
+
result += char;
|
|
38375
|
+
if (escaped) {
|
|
38376
|
+
escaped = false;
|
|
38377
|
+
} else if (char === "\\") {
|
|
38378
|
+
escaped = true;
|
|
38379
|
+
} else if (char === '"') {
|
|
38380
|
+
inString = false;
|
|
38381
|
+
}
|
|
38382
|
+
continue;
|
|
38383
|
+
}
|
|
38384
|
+
if (char === '"') {
|
|
38385
|
+
inString = true;
|
|
38386
|
+
result += char;
|
|
38387
|
+
continue;
|
|
38388
|
+
}
|
|
38389
|
+
if (char === "/" && next === "/") {
|
|
38390
|
+
inLineComment = true;
|
|
38391
|
+
index += 1;
|
|
38392
|
+
continue;
|
|
38393
|
+
}
|
|
38394
|
+
if (char === "/" && next === "*") {
|
|
38395
|
+
inBlockComment = true;
|
|
38396
|
+
index += 1;
|
|
38397
|
+
continue;
|
|
38398
|
+
}
|
|
38399
|
+
result += char;
|
|
38400
|
+
}
|
|
38401
|
+
return result;
|
|
38402
|
+
}
|
|
38403
|
+
function removeTrailingCommas(content) {
|
|
38404
|
+
let result = "";
|
|
38405
|
+
let inString = false;
|
|
38406
|
+
let escaped = false;
|
|
38407
|
+
for (let index = 0; index < content.length; index += 1) {
|
|
38408
|
+
const char = content[index];
|
|
38409
|
+
if (inString) {
|
|
38410
|
+
result += char;
|
|
38411
|
+
if (escaped) {
|
|
38412
|
+
escaped = false;
|
|
38413
|
+
} else if (char === "\\") {
|
|
38414
|
+
escaped = true;
|
|
38415
|
+
} else if (char === '"') {
|
|
38416
|
+
inString = false;
|
|
38417
|
+
}
|
|
38418
|
+
continue;
|
|
38419
|
+
}
|
|
38420
|
+
if (char === '"') {
|
|
38421
|
+
inString = true;
|
|
38422
|
+
result += char;
|
|
38423
|
+
continue;
|
|
38424
|
+
}
|
|
38425
|
+
if (char === ",") {
|
|
38426
|
+
let lookahead = index + 1;
|
|
38427
|
+
while (/\s/.test(content[lookahead] || "")) {
|
|
38428
|
+
lookahead += 1;
|
|
38429
|
+
}
|
|
38430
|
+
if (content[lookahead] === "}" || content[lookahead] === "]") {
|
|
38431
|
+
continue;
|
|
38432
|
+
}
|
|
38433
|
+
}
|
|
38434
|
+
result += char;
|
|
38435
|
+
}
|
|
38436
|
+
return result;
|
|
38437
|
+
}
|
|
38127
38438
|
function formatMcpInstallMessage(label, configPath, write) {
|
|
38128
38439
|
if (!write.changed) {
|
|
38129
38440
|
return `✓ ${label} MCP config unchanged: ${configPath}`;
|
|
@@ -38297,6 +38608,9 @@ function mcpVerifyModeOption(parsed) {
|
|
|
38297
38608
|
function parseIdeList(value) {
|
|
38298
38609
|
return value.split(/[\s,]+/).map((item) => item.trim().toLowerCase()).filter(Boolean);
|
|
38299
38610
|
}
|
|
38611
|
+
function uniqueStrings(values) {
|
|
38612
|
+
return Array.from(new Set(values));
|
|
38613
|
+
}
|
|
38300
38614
|
function mask(value) {
|
|
38301
38615
|
if (value.length <= 12) {
|
|
38302
38616
|
return "***";
|
|
@@ -38325,7 +38639,8 @@ function printHelp() {
|
|
|
38325
38639
|
" taptap-maker Start MCP server mode",
|
|
38326
38640
|
" taptap-maker init [--env rnd|production] [--app-id ID] [--target-dir DIR] [--pat PAT]",
|
|
38327
38641
|
" [--create --name NAME]",
|
|
38328
|
-
" [--skip-confirm] [--skip-mcp-install]
|
|
38642
|
+
" [--skip-confirm] [--skip-mcp-install]",
|
|
38643
|
+
" [--register-mcp codex,cursor,claude,trae,opencode,workbuddy]",
|
|
38329
38644
|
" [--json]",
|
|
38330
38645
|
"",
|
|
38331
38646
|
"Init flows:",
|
|
@@ -38345,10 +38660,12 @@ function printHelp() {
|
|
|
38345
38660
|
" taptap-maker login [--env rnd|production] [--json]",
|
|
38346
38661
|
" taptap-maker pat set [--pat-stdin] [--json]",
|
|
38347
38662
|
" taptap-maker pat set [PAT|--pat PAT] [--json] # fallback; warns: PAT appears in ps/history",
|
|
38348
|
-
" taptap-maker install [--ide codex,cursor,claude]
|
|
38663
|
+
" taptap-maker install [--ide codex,cursor,claude,trae,opencode,workbuddy]",
|
|
38664
|
+
" [--env rnd|production]",
|
|
38349
38665
|
" [--target-dir DIR]",
|
|
38350
38666
|
" [--json] # alias for mcp install",
|
|
38351
|
-
" taptap-maker mcp install [--ide codex,cursor,claude]
|
|
38667
|
+
" taptap-maker mcp install [--ide codex,cursor,claude,trae,opencode,workbuddy]",
|
|
38668
|
+
" [--env rnd|production]",
|
|
38352
38669
|
" [--target-dir DIR] [--json]",
|
|
38353
38670
|
" taptap-maker mcp verify [--mode npx|self] [--json]",
|
|
38354
38671
|
" taptap-maker agents update [--target-dir DIR] [--json]",
|
|
@@ -38360,8 +38677,13 @@ function printHelp() {
|
|
|
38360
38677
|
"MCP verify defaults to the npx command written into AI client config.",
|
|
38361
38678
|
"Maker MCP configs and npx verification use @taptap/maker.",
|
|
38362
38679
|
"",
|
|
38680
|
+
"MCP install defaults:",
|
|
38681
|
+
" Writes Codex, Cursor, Claude, detected Trae/OpenCode/WorkBuddy configs,",
|
|
38682
|
+
" unless --ide is specified. It does not create missing Trae config files.",
|
|
38683
|
+
"",
|
|
38363
38684
|
"Windows note:",
|
|
38364
|
-
"
|
|
38685
|
+
" mcpServers configs wrap npx.cmd with cmd.exe on Windows for spawn compatibility.",
|
|
38686
|
+
" OpenCode uses its own mcp schema and writes a command array with npx.cmd.",
|
|
38365
38687
|
""
|
|
38366
38688
|
].join("\n")
|
|
38367
38689
|
);
|