@taptap/maker 0.0.21-beta.4 → 0.0.22-beta.1
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 +741 -108
- package/package.json +1 -1
- package/skills/taptap-maker-dev-kit-guide/SKILL.md +7 -3
- package/skills/taptap-maker-local/SKILL.md +8 -5
package/README.md
CHANGED
package/dist/maker.js
CHANGED
|
@@ -12987,7 +12987,7 @@ var require_cross_spawn = __commonJS({
|
|
|
12987
12987
|
enoent.hookChildProcess(spawned, parsed);
|
|
12988
12988
|
return spawned;
|
|
12989
12989
|
}
|
|
12990
|
-
function
|
|
12990
|
+
function spawnSync8(command, args, options) {
|
|
12991
12991
|
const parsed = parse3(command, args, options);
|
|
12992
12992
|
const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
|
|
12993
12993
|
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
@@ -12995,14 +12995,14 @@ var require_cross_spawn = __commonJS({
|
|
|
12995
12995
|
}
|
|
12996
12996
|
module.exports = spawn5;
|
|
12997
12997
|
module.exports.spawn = spawn5;
|
|
12998
|
-
module.exports.sync =
|
|
12998
|
+
module.exports.sync = spawnSync8;
|
|
12999
12999
|
module.exports._parse = parse3;
|
|
13000
13000
|
module.exports._enoent = enoent;
|
|
13001
13001
|
}
|
|
13002
13002
|
});
|
|
13003
13003
|
|
|
13004
13004
|
// src/maker/server/mcp.ts
|
|
13005
|
-
import { execFileSync, spawn as spawn4
|
|
13005
|
+
import { execFileSync, spawn as spawn4 } from "node:child_process";
|
|
13006
13006
|
import fs14 from "node:fs";
|
|
13007
13007
|
import path15 from "node:path";
|
|
13008
13008
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
@@ -34260,8 +34260,13 @@ function applyDefaults(config2) {
|
|
|
34260
34260
|
}
|
|
34261
34261
|
|
|
34262
34262
|
// src/maker/server/mcp.ts
|
|
34263
|
-
var VERSION = true ? "0.0.
|
|
34263
|
+
var VERSION = true ? "0.0.22-beta.1" : "dev";
|
|
34264
34264
|
var DEFAULT_BUILD_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
34265
|
+
var ASYNC_BUILD_POLL_INTERVAL_MS = 5 * 1e3;
|
|
34266
|
+
var ASYNC_BUILD_TIMEOUT_MS = 30 * 60 * 1e3;
|
|
34267
|
+
var DEFAULT_REMOTE_ASYNC_BUILD_PARAM = "async";
|
|
34268
|
+
var DEFAULT_REMOTE_ASYNC_BUILD_QUERY_TOOL = "query_build";
|
|
34269
|
+
var DEFAULT_REMOTE_ASYNC_BUILD_QUERY_TASK_ID_PARAM = "build_id";
|
|
34265
34270
|
var DEFAULT_PROXY_RETRY_ATTEMPTS = 5;
|
|
34266
34271
|
var DEFAULT_PROXY_RETRY_DELAY_MS = 30 * 1e3;
|
|
34267
34272
|
var PREVIEW_REFRESH_TIMEOUT_MS = 15 * 1e3;
|
|
@@ -34307,7 +34312,7 @@ var tools = [
|
|
|
34307
34312
|
},
|
|
34308
34313
|
{
|
|
34309
34314
|
name: "maker_build_current_directory",
|
|
34310
|
-
description: 'Sync and build the current Maker game.
|
|
34315
|
+
description: 'Sync and build the current Maker game. First read maker://status or maker_status_lite and use this tool only when the current workspace is a bound Maker project. Trigger it for Maker game requests like "构建", "build", "跑一下", "预览", "查看结果", "看看效果", "验证游戏效果", "提交", "提交代码", "推送", or "push". Do not treat generic code validation requests such as "验证一下代码", "跑测试", "lint", or "检查实现" as Maker remote build unless the user explicitly asks to build/run/preview the Maker game. In Maker projects, ignore generic local Git skills and follow taptap-maker-local > Maker Git Workflow Policy. Before build, check the Python environment section and Lua LSP environment section; if Python or maker-lua-lsp is missing, run taptap-maker python setup when local Lua diagnostics are needed, because it prepares Python and best-effort installs maker-lua-lsp. Missing Python or Lua LSP must not block the remote build flow. Do not create branches, do not use generic git commit/push, and do not create PR/MR for Maker project submit/build requests. Before creating a commit, this tool checks Maker remote sync; if local main is behind/diverged, not on main, or remote sync cannot be verified, it stops before commit/push and returns recovery details. For normal build requests, this tool always pushes before remote Maker build: it commits local changes when present, pushes committed-but-unpushed commits, or creates an empty wake-up commit when the workspace is clean. Maker generated .gitignore changes are required project files and are submitted even if files selects a smaller change set. If push fails, build is not started and the result includes recovery details for the local Agent to handle merge/conflict resolution. If push succeeds but remote build fails, report that code is already on Maker remote and include build failure details. After a successful build, a local runtime log watcher is started; for gameplay/runtime diagnostics, read runtime_logs.local_file, and for watcher health read runtime_logs.state_file. Only set confirm_remote_build_without_submit=true when the user explicitly says they do not want to submit local changes and wants to build the current remote version; this mode does not submit local changes and does not auto-open Maker pages.',
|
|
34311
34316
|
inputSchema: {
|
|
34312
34317
|
type: "object",
|
|
34313
34318
|
properties: {
|
|
@@ -34348,6 +34353,10 @@ var tools = [
|
|
|
34348
34353
|
type: "number",
|
|
34349
34354
|
description: "Optional remote build timeout in milliseconds. Defaults to 10 minutes. If timed out, do not retry blindly; inspect remote build logs first."
|
|
34350
34355
|
},
|
|
34356
|
+
async_build: {
|
|
34357
|
+
type: "boolean",
|
|
34358
|
+
description: "Async remote build preference. If true, Maker MCP forwards remote build async:true in any IDE. If false, it keeps synchronous remote build. If omitted, WorkBuddy defaults to async and other IDEs default to sync. For async builds, this tool keeps the current MCP call open, polls query_build(build_id) every 5 seconds, and returns only after success, failure, replacement by a newer build, or 30 minutes."
|
|
34359
|
+
},
|
|
34351
34360
|
message: {
|
|
34352
34361
|
type: "string",
|
|
34353
34362
|
description: "Optional commit message used when local changes or the empty wake-up commit need to be committed before build."
|
|
@@ -34359,7 +34368,7 @@ var tools = [
|
|
|
34359
34368
|
},
|
|
34360
34369
|
confirm_remote_build_without_submit: {
|
|
34361
34370
|
type: "boolean",
|
|
34362
|
-
description: "Set true only after the user explicitly confirms they do not want to submit local changes and want to build the current Maker remote committed version. This mode
|
|
34371
|
+
description: "Set true only after the user explicitly confirms they do not want to submit local changes and want to build the current Maker remote committed version. This mode does not submit local changes and does not auto-open Maker pages."
|
|
34363
34372
|
}
|
|
34364
34373
|
}
|
|
34365
34374
|
}
|
|
@@ -34666,6 +34675,7 @@ async function startMakerMcpServer() {
|
|
|
34666
34675
|
serverUrl: args.server_url,
|
|
34667
34676
|
env: args.env,
|
|
34668
34677
|
timeoutMs: args.timeout_ms,
|
|
34678
|
+
asyncBuild: args.async_build,
|
|
34669
34679
|
message: args.message,
|
|
34670
34680
|
files: args.files,
|
|
34671
34681
|
confirmRemoteBuildWithoutSubmit: args.confirm_remote_build_without_submit,
|
|
@@ -34834,6 +34844,8 @@ async function formatStatus(options = {}) {
|
|
|
34834
34844
|
"",
|
|
34835
34845
|
remoteSyncText,
|
|
34836
34846
|
"",
|
|
34847
|
+
identify.projectRoot ? formatAsyncBuildStatus(identify.projectRoot) : "",
|
|
34848
|
+
"",
|
|
34837
34849
|
identify.projectRoot ? await formatMakerProxyToolsStatusSafely({ targetDir: identify.projectRoot }) : "",
|
|
34838
34850
|
"",
|
|
34839
34851
|
formatAuthNextStep({ hasPat: Boolean(pat), isProjectBound: Boolean(identify.projectRoot) }),
|
|
@@ -34852,6 +34864,29 @@ async function formatStatus(options = {}) {
|
|
|
34852
34864
|
projectSection
|
|
34853
34865
|
].filter(Boolean).join("\n");
|
|
34854
34866
|
}
|
|
34867
|
+
function formatAsyncBuildStatus(projectRoot) {
|
|
34868
|
+
const active = readJsonFile2(getAsyncBuildWatcherPaths(projectRoot, "unused").activeFile);
|
|
34869
|
+
if (!(active == null ? void 0 : active.taskId)) {
|
|
34870
|
+
return ["Maker async build", "", "- status: inactive"].join("\n");
|
|
34871
|
+
}
|
|
34872
|
+
const stale = active.pid !== void 0 && active.pid !== process.pid;
|
|
34873
|
+
const state = active.stateFile ? readJsonFile2(active.stateFile) : void 0;
|
|
34874
|
+
return [
|
|
34875
|
+
"Maker async build",
|
|
34876
|
+
"",
|
|
34877
|
+
`- status: ${stale ? "stale" : "active"}`,
|
|
34878
|
+
`- build_id: ${active.taskId}`,
|
|
34879
|
+
active.reused !== void 0 ? `- reused: ${active.reused ? "yes" : "no"}` : "",
|
|
34880
|
+
active.pid ? `- watcher_pid: ${active.pid}` : "",
|
|
34881
|
+
stale ? "- note: active marker belongs to a previous MCP process; polling is not durable after restart" : "",
|
|
34882
|
+
active.stateFile ? `- state_file: ${active.stateFile}` : "",
|
|
34883
|
+
active.deadlineAt ? `- deadline_at: ${active.deadlineAt}` : "",
|
|
34884
|
+
(state == null ? void 0 : state.status) ? `- last_status: ${state.status}` : "",
|
|
34885
|
+
(state == null ? void 0 : state.updatedAt) ? `- updated_at: ${state.updatedAt}` : "",
|
|
34886
|
+
`- poll_interval_ms: ${ASYNC_BUILD_POLL_INTERVAL_MS}`,
|
|
34887
|
+
`- timeout_ms: ${ASYNC_BUILD_TIMEOUT_MS}`
|
|
34888
|
+
].filter(Boolean).join("\n");
|
|
34889
|
+
}
|
|
34855
34890
|
function formatAuthNextStep(options) {
|
|
34856
34891
|
if (options.hasPat) {
|
|
34857
34892
|
return "";
|
|
@@ -35523,40 +35558,12 @@ function formatDuration(ms) {
|
|
|
35523
35558
|
}
|
|
35524
35559
|
return `${minutes}m ${seconds}s`;
|
|
35525
35560
|
}
|
|
35561
|
+
var activeAsyncBuildWatchers = /* @__PURE__ */ new Map();
|
|
35526
35562
|
function formatMakerAppWebUrl(projectId, env) {
|
|
35527
35563
|
const makerEnv = env === "rnd" || env === "production" ? env : void 0;
|
|
35528
|
-
|
|
35529
|
-
|
|
35530
|
-
|
|
35531
|
-
const identify = identifyMakerProject({ cwd: options.targetDir });
|
|
35532
|
-
if (!identify.projectRoot || !identify.projectId) {
|
|
35533
|
-
throw new Error(
|
|
35534
|
-
`${options.targetDir} is not bound to a Maker project. Run taptap-maker init first.`
|
|
35535
|
-
);
|
|
35536
|
-
}
|
|
35537
|
-
const projectConfig = loadProjectConfig(identify.projectRoot);
|
|
35538
|
-
const projectId = (projectConfig == null ? void 0 : projectConfig.project_id) || identify.projectId;
|
|
35539
|
-
const env = getMakerEnvironment(options.env, identify.projectRoot);
|
|
35540
|
-
const url2 = formatMakerAppWebUrl(projectId, env);
|
|
35541
|
-
return (options.openMakerPage || openMakerPageInBrowser)(url2);
|
|
35542
|
-
}
|
|
35543
|
-
function openMakerPageInBrowser(url2) {
|
|
35544
|
-
var _a3;
|
|
35545
|
-
const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
|
|
35546
|
-
const args = process.platform === "win32" ? ["/c", "start", "", url2] : [url2];
|
|
35547
|
-
const result = spawnSync6(command, args, {
|
|
35548
|
-
stdio: "ignore",
|
|
35549
|
-
windowsHide: true,
|
|
35550
|
-
timeout: 5e3
|
|
35551
|
-
});
|
|
35552
|
-
if (result.error || result.status !== 0) {
|
|
35553
|
-
return {
|
|
35554
|
-
ok: false,
|
|
35555
|
-
url: url2,
|
|
35556
|
-
error: ((_a3 = result.error) == null ? void 0 : _a3.message) || `open command exited with status ${result.status ?? "unknown"}`
|
|
35557
|
-
};
|
|
35558
|
-
}
|
|
35559
|
-
return { ok: true, url: url2 };
|
|
35564
|
+
const url2 = new URL(`${getMakerWebUrl(makerEnv)}/app/${encodeURIComponent(projectId)}`);
|
|
35565
|
+
url2.searchParams.set("localDev", "1");
|
|
35566
|
+
return url2.toString();
|
|
35560
35567
|
}
|
|
35561
35568
|
var RemoteBuildFailedError = class extends Error {
|
|
35562
35569
|
constructor(buildResult) {
|
|
@@ -35603,17 +35610,33 @@ async function buildCurrentDirectory(options) {
|
|
|
35603
35610
|
buildFailure: toMakerBuildFailure(error2)
|
|
35604
35611
|
};
|
|
35605
35612
|
}
|
|
35613
|
+
if (buildResult.mode === "remote_build_async_started") {
|
|
35614
|
+
try {
|
|
35615
|
+
return {
|
|
35616
|
+
...await attachAndWaitAsyncBuildResult(buildResult, options),
|
|
35617
|
+
submitResult
|
|
35618
|
+
};
|
|
35619
|
+
} catch (error2) {
|
|
35620
|
+
return {
|
|
35621
|
+
mode: "build_failed_after_submit",
|
|
35622
|
+
projectRoot: localChanges.projectRoot,
|
|
35623
|
+
projectId: (config2 == null ? void 0 : config2.project_id) || "unknown",
|
|
35624
|
+
submitResult,
|
|
35625
|
+
buildFailure: toMakerBuildFailure(error2)
|
|
35626
|
+
};
|
|
35627
|
+
}
|
|
35628
|
+
}
|
|
35606
35629
|
return {
|
|
35607
35630
|
...buildResult,
|
|
35608
35631
|
submitResult
|
|
35609
35632
|
};
|
|
35610
35633
|
}
|
|
35611
|
-
const makerPageOpen = openRemoteBuildMakerPage(options);
|
|
35612
35634
|
try {
|
|
35613
|
-
|
|
35614
|
-
|
|
35615
|
-
|
|
35616
|
-
}
|
|
35635
|
+
const buildResult = await runRemoteBuildCurrentDirectory(options, options.targetDir);
|
|
35636
|
+
if (buildResult.mode === "remote_build_async_started") {
|
|
35637
|
+
return await attachAndWaitAsyncBuildResult(buildResult, options);
|
|
35638
|
+
}
|
|
35639
|
+
return buildResult;
|
|
35617
35640
|
} catch (error2) {
|
|
35618
35641
|
if (error2 instanceof RemoteBuildFailedError) {
|
|
35619
35642
|
return {
|
|
@@ -35621,8 +35644,7 @@ async function buildCurrentDirectory(options) {
|
|
|
35621
35644
|
projectRoot: error2.buildResult.projectRoot,
|
|
35622
35645
|
projectId: error2.buildResult.projectId,
|
|
35623
35646
|
buildResult: error2.buildResult,
|
|
35624
|
-
buildFailure: toMakerBuildFailure(error2)
|
|
35625
|
-
makerPageOpen
|
|
35647
|
+
buildFailure: toMakerBuildFailure(error2)
|
|
35626
35648
|
};
|
|
35627
35649
|
}
|
|
35628
35650
|
throw error2;
|
|
@@ -35630,7 +35652,11 @@ async function buildCurrentDirectory(options) {
|
|
|
35630
35652
|
}
|
|
35631
35653
|
async function runRemoteBuildCurrentDirectory(options, targetDir) {
|
|
35632
35654
|
if (options.callRemoteBuild) {
|
|
35633
|
-
|
|
35655
|
+
const injectedResult = await options.callRemoteBuild(targetDir);
|
|
35656
|
+
if (injectedResult.mode === "remote_build_async_started") {
|
|
35657
|
+
return injectedResult;
|
|
35658
|
+
}
|
|
35659
|
+
return attachBuildSuccessSideEffects(injectedResult, {
|
|
35634
35660
|
refreshPreview: options.refreshPreview || skipPreviewRefresh,
|
|
35635
35661
|
startRuntimeLogWatch: options.startRuntimeLogWatch
|
|
35636
35662
|
});
|
|
@@ -35641,6 +35667,7 @@ async function runRemoteBuildCurrentDirectory(options, targetDir) {
|
|
|
35641
35667
|
env: options.env
|
|
35642
35668
|
});
|
|
35643
35669
|
const buildArgs = createBuildArgs(proxy.projectRoot, options);
|
|
35670
|
+
const asyncBuildForwarded = shouldForwardAsyncBuild(options.asyncBuild);
|
|
35644
35671
|
const timeoutMs = options.timeoutMs || DEFAULT_BUILD_TIMEOUT_MS;
|
|
35645
35672
|
const result = await retryMakerProxyOperation(
|
|
35646
35673
|
async () => {
|
|
@@ -35703,24 +35730,225 @@ async function runRemoteBuildCurrentDirectory(options, targetDir) {
|
|
|
35703
35730
|
if (isRemoteToolError(result)) {
|
|
35704
35731
|
throw new Error(formatRemoteToolResult(result));
|
|
35705
35732
|
}
|
|
35706
|
-
|
|
35733
|
+
const resultText = formatRemoteToolResult(result);
|
|
35734
|
+
const buildCallResult = createRemoteBuildCallResult({
|
|
35735
|
+
projectRoot: proxy.projectRoot,
|
|
35736
|
+
projectId: proxy.projectId,
|
|
35737
|
+
projectPath: proxy.projectPath,
|
|
35738
|
+
serverUrl: proxy.serverUrl,
|
|
35739
|
+
env: proxy.env,
|
|
35740
|
+
timeoutMs,
|
|
35741
|
+
buildArgs,
|
|
35742
|
+
resultText,
|
|
35743
|
+
asyncBuild: asyncBuildForwarded
|
|
35744
|
+
});
|
|
35745
|
+
if (buildCallResult.mode === "remote_build_async_started") {
|
|
35746
|
+
return buildCallResult;
|
|
35747
|
+
}
|
|
35748
|
+
return attachBuildSuccessSideEffects(buildCallResult, {
|
|
35749
|
+
refreshPreview: options.refreshPreview,
|
|
35750
|
+
startRuntimeLogWatch: options.startRuntimeLogWatch || startRuntimeLogWatch
|
|
35751
|
+
});
|
|
35752
|
+
}
|
|
35753
|
+
function createRemoteBuildCallResult(options) {
|
|
35754
|
+
const asyncReceipt = options.asyncBuild ? extractAsyncBuildReceipt(options.resultText) : void 0;
|
|
35755
|
+
const taskId = asyncReceipt == null ? void 0 : asyncReceipt.taskId;
|
|
35756
|
+
if (taskId) {
|
|
35757
|
+
return {
|
|
35758
|
+
mode: "remote_build_async_started",
|
|
35759
|
+
projectRoot: options.projectRoot,
|
|
35760
|
+
projectId: options.projectId,
|
|
35761
|
+
projectPath: options.projectPath,
|
|
35762
|
+
serverUrl: options.serverUrl,
|
|
35763
|
+
env: options.env,
|
|
35764
|
+
makerUrl: formatMakerAppWebUrl(options.projectId, options.env),
|
|
35765
|
+
timeoutMs: options.timeoutMs,
|
|
35766
|
+
buildArgs: options.buildArgs,
|
|
35767
|
+
taskId,
|
|
35768
|
+
reused: asyncReceipt.reused,
|
|
35769
|
+
resultText: options.resultText
|
|
35770
|
+
};
|
|
35771
|
+
}
|
|
35772
|
+
return {
|
|
35773
|
+
mode: "remote_build",
|
|
35774
|
+
projectRoot: options.projectRoot,
|
|
35775
|
+
projectId: options.projectId,
|
|
35776
|
+
projectPath: options.projectPath,
|
|
35777
|
+
serverUrl: options.serverUrl,
|
|
35778
|
+
env: options.env,
|
|
35779
|
+
makerUrl: formatMakerAppWebUrl(options.projectId, options.env),
|
|
35780
|
+
timeoutMs: options.timeoutMs,
|
|
35781
|
+
buildArgs: options.buildArgs,
|
|
35782
|
+
resultText: options.resultText
|
|
35783
|
+
};
|
|
35784
|
+
}
|
|
35785
|
+
function extractAsyncBuildReceipt(resultText) {
|
|
35786
|
+
const parsed = parseJsonObjectFromText(resultText);
|
|
35787
|
+
const taskId = (parsed == null ? void 0 : parsed.build_id) || (parsed == null ? void 0 : parsed.buildId) || (parsed == null ? void 0 : parsed.task_id) || (parsed == null ? void 0 : parsed.taskId) || (parsed == null ? void 0 : parsed.build_task_id) || (parsed == null ? void 0 : parsed.buildTaskId);
|
|
35788
|
+
if (typeof taskId !== "string" || !taskId.trim()) {
|
|
35789
|
+
return void 0;
|
|
35790
|
+
}
|
|
35791
|
+
return {
|
|
35792
|
+
taskId: taskId.trim(),
|
|
35793
|
+
...typeof (parsed == null ? void 0 : parsed.reused) === "boolean" ? { reused: parsed.reused } : {}
|
|
35794
|
+
};
|
|
35795
|
+
}
|
|
35796
|
+
function parseJsonObjectFromText(text) {
|
|
35797
|
+
const trimmed = text.trim();
|
|
35798
|
+
if (!trimmed) {
|
|
35799
|
+
return void 0;
|
|
35800
|
+
}
|
|
35801
|
+
try {
|
|
35802
|
+
const parsed = JSON.parse(trimmed);
|
|
35803
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : void 0;
|
|
35804
|
+
} catch {
|
|
35805
|
+
return void 0;
|
|
35806
|
+
}
|
|
35807
|
+
}
|
|
35808
|
+
function attachAsyncBuildWatcher(buildResult, options) {
|
|
35809
|
+
const remoteQueryRunner = options.queryAsyncBuildResult ? void 0 : createRemoteAsyncBuildQueryRunner(buildResult);
|
|
35810
|
+
const queryBuildResult = options.queryAsyncBuildResult || ((taskId) => (remoteQueryRunner == null ? void 0 : remoteQueryRunner.query(taskId)) || Promise.reject(new Error("Async build query runner is not available")));
|
|
35811
|
+
return {
|
|
35812
|
+
...buildResult,
|
|
35813
|
+
asyncBuildWatch: startAsyncBuildResultWatcher({
|
|
35814
|
+
projectRoot: buildResult.projectRoot,
|
|
35815
|
+
projectId: buildResult.projectId,
|
|
35816
|
+
projectPath: buildResult.projectPath,
|
|
35817
|
+
serverUrl: buildResult.serverUrl,
|
|
35818
|
+
env: buildResult.env,
|
|
35819
|
+
taskId: buildResult.taskId,
|
|
35820
|
+
reused: buildResult.reused,
|
|
35821
|
+
sourceBuildResult: buildResult,
|
|
35822
|
+
queryBuildResult: () => queryBuildResult(buildResult.taskId),
|
|
35823
|
+
refreshPreview: options.refreshPreview || refreshMakerPreview,
|
|
35824
|
+
startRuntimeLogWatch: options.startRuntimeLogWatch || startRuntimeLogWatch,
|
|
35825
|
+
pollIntervalMs: options.asyncBuildPollIntervalMs,
|
|
35826
|
+
onProgress: options.onProgress,
|
|
35827
|
+
onStop: () => remoteQueryRunner == null ? void 0 : remoteQueryRunner.close()
|
|
35828
|
+
})
|
|
35829
|
+
};
|
|
35830
|
+
}
|
|
35831
|
+
async function attachAndWaitAsyncBuildResult(buildResult, options) {
|
|
35832
|
+
var _a3, _b;
|
|
35833
|
+
const watched = attachAsyncBuildWatcher(buildResult, options);
|
|
35834
|
+
const activeFile = (_a3 = watched.asyncBuildWatch) == null ? void 0 : _a3.activeFile;
|
|
35835
|
+
const completion = activeFile ? (_b = activeAsyncBuildWatchers.get(activeFile)) == null ? void 0 : _b.completion : void 0;
|
|
35836
|
+
if (!completion) {
|
|
35837
|
+
throw new Error("Async build watcher did not start");
|
|
35838
|
+
}
|
|
35839
|
+
const finalState = await completion;
|
|
35840
|
+
const finalResult = asyncWatcherStateToRemoteBuildResult(finalState, buildResult);
|
|
35841
|
+
if (finalState.status === "succeeded") {
|
|
35842
|
+
return finalResult;
|
|
35843
|
+
}
|
|
35844
|
+
if (finalState.status === "failed") {
|
|
35845
|
+
throw new RemoteBuildFailedError(finalResult);
|
|
35846
|
+
}
|
|
35847
|
+
throw new Error(
|
|
35848
|
+
`Async Maker build did not finish successfully: ${finalState.status}${finalState.error ? `: ${formatAsyncBuildDiagnostic(finalState.error)}` : ""}`
|
|
35849
|
+
);
|
|
35850
|
+
}
|
|
35851
|
+
function formatAsyncBuildDiagnostic(value) {
|
|
35852
|
+
if (typeof value === "string") {
|
|
35853
|
+
return value;
|
|
35854
|
+
}
|
|
35855
|
+
try {
|
|
35856
|
+
return JSON.stringify(value);
|
|
35857
|
+
} catch {
|
|
35858
|
+
return String(value);
|
|
35859
|
+
}
|
|
35860
|
+
}
|
|
35861
|
+
function createRemoteAsyncBuildQueryRunner(buildResult) {
|
|
35862
|
+
var _a3, _b;
|
|
35863
|
+
const proxy = createRemoteProxyContext({
|
|
35864
|
+
targetDir: buildResult.projectRoot,
|
|
35865
|
+
serverUrl: buildResult.serverUrl,
|
|
35866
|
+
env: buildResult.env === "rnd" || buildResult.env === "production" ? buildResult.env : void 0
|
|
35867
|
+
});
|
|
35868
|
+
const queryToolName = ((_a3 = process.env.TAPTAP_MAKER_REMOTE_ASYNC_BUILD_QUERY_TOOL) == null ? void 0 : _a3.trim()) || DEFAULT_REMOTE_ASYNC_BUILD_QUERY_TOOL;
|
|
35869
|
+
const taskIdParam = ((_b = process.env.TAPTAP_MAKER_REMOTE_ASYNC_BUILD_QUERY_TASK_ID_PARAM) == null ? void 0 : _b.trim()) || DEFAULT_REMOTE_ASYNC_BUILD_QUERY_TASK_ID_PARAM;
|
|
35870
|
+
const transport = trackMakerChildTransport(
|
|
35871
|
+
new HiddenStdioClientTransport({
|
|
35872
|
+
command: proxy.command,
|
|
35873
|
+
args: proxy.args,
|
|
35874
|
+
env: mergeStringEnv(process.env, proxy.envVars),
|
|
35875
|
+
stderr: "pipe"
|
|
35876
|
+
})
|
|
35877
|
+
);
|
|
35878
|
+
const client = new Client(
|
|
35707
35879
|
{
|
|
35708
|
-
|
|
35709
|
-
|
|
35710
|
-
projectId: proxy.projectId,
|
|
35711
|
-
projectPath: proxy.projectPath,
|
|
35712
|
-
serverUrl: proxy.serverUrl,
|
|
35713
|
-
env: proxy.env,
|
|
35714
|
-
makerUrl: formatMakerAppWebUrl(proxy.projectId, proxy.env),
|
|
35715
|
-
timeoutMs,
|
|
35716
|
-
buildArgs,
|
|
35717
|
-
resultText: formatRemoteToolResult(result)
|
|
35880
|
+
name: "taptap-maker-async-build-query-forwarder",
|
|
35881
|
+
version: VERSION
|
|
35718
35882
|
},
|
|
35719
35883
|
{
|
|
35720
|
-
|
|
35721
|
-
startRuntimeLogWatch: options.startRuntimeLogWatch || startRuntimeLogWatch
|
|
35884
|
+
capabilities: {}
|
|
35722
35885
|
}
|
|
35723
35886
|
);
|
|
35887
|
+
let connectPromise;
|
|
35888
|
+
const ensureConnected = async () => {
|
|
35889
|
+
if (!connectPromise) {
|
|
35890
|
+
connectPromise = client.connect(transport);
|
|
35891
|
+
}
|
|
35892
|
+
await connectPromise;
|
|
35893
|
+
};
|
|
35894
|
+
return {
|
|
35895
|
+
query: async (taskId) => {
|
|
35896
|
+
await ensureConnected();
|
|
35897
|
+
const result = await client.callTool(
|
|
35898
|
+
{
|
|
35899
|
+
name: queryToolName,
|
|
35900
|
+
arguments: { [taskIdParam]: taskId }
|
|
35901
|
+
},
|
|
35902
|
+
void 0,
|
|
35903
|
+
{
|
|
35904
|
+
timeout: DEFAULT_BUILD_TIMEOUT_MS
|
|
35905
|
+
}
|
|
35906
|
+
);
|
|
35907
|
+
return normalizeAsyncBuildQueryResult(result);
|
|
35908
|
+
},
|
|
35909
|
+
close: async () => {
|
|
35910
|
+
await client.close().catch(() => {
|
|
35911
|
+
});
|
|
35912
|
+
}
|
|
35913
|
+
};
|
|
35914
|
+
}
|
|
35915
|
+
function normalizeAsyncBuildQueryResult(result) {
|
|
35916
|
+
const resultText = formatRemoteToolResult(result);
|
|
35917
|
+
const parsed = parseJsonObjectFromText(resultText);
|
|
35918
|
+
const status = normalizeAsyncBuildStatus((parsed == null ? void 0 : parsed.status) || (parsed == null ? void 0 : parsed.state) || (parsed == null ? void 0 : parsed.phase));
|
|
35919
|
+
if (status) {
|
|
35920
|
+
return {
|
|
35921
|
+
status,
|
|
35922
|
+
resultText,
|
|
35923
|
+
result: parsed,
|
|
35924
|
+
error: parsed == null ? void 0 : parsed.error
|
|
35925
|
+
};
|
|
35926
|
+
}
|
|
35927
|
+
return {
|
|
35928
|
+
status: isRemoteToolError(result) ? "failed" : "running",
|
|
35929
|
+
resultText,
|
|
35930
|
+
result: parsed || result,
|
|
35931
|
+
...isRemoteToolError(result) ? { error: resultText } : {}
|
|
35932
|
+
};
|
|
35933
|
+
}
|
|
35934
|
+
function normalizeAsyncBuildStatus(status) {
|
|
35935
|
+
if (typeof status !== "string") {
|
|
35936
|
+
return void 0;
|
|
35937
|
+
}
|
|
35938
|
+
const normalized = status.trim().toLowerCase();
|
|
35939
|
+
if (["queued", "pending", "created"].includes(normalized)) {
|
|
35940
|
+
return "queued";
|
|
35941
|
+
}
|
|
35942
|
+
if (["running", "building", "in_progress", "processing"].includes(normalized)) {
|
|
35943
|
+
return "running";
|
|
35944
|
+
}
|
|
35945
|
+
if (["succeeded", "success", "done", "completed", "finished"].includes(normalized)) {
|
|
35946
|
+
return "succeeded";
|
|
35947
|
+
}
|
|
35948
|
+
if (["failed", "failure", "error", "cancelled", "canceled"].includes(normalized)) {
|
|
35949
|
+
return "failed";
|
|
35950
|
+
}
|
|
35951
|
+
return void 0;
|
|
35724
35952
|
}
|
|
35725
35953
|
async function attachBuildSuccessSideEffects(buildResult, options) {
|
|
35726
35954
|
if (isRemoteBuildFailureResult(buildResult)) {
|
|
@@ -35861,6 +36089,311 @@ async function startRuntimeLogWatch(buildResult) {
|
|
|
35861
36089
|
fs14.closeSync(errFd);
|
|
35862
36090
|
}
|
|
35863
36091
|
}
|
|
36092
|
+
function startAsyncBuildResultWatcher(options) {
|
|
36093
|
+
const pollIntervalMs = options.pollIntervalMs || ASYNC_BUILD_POLL_INTERVAL_MS;
|
|
36094
|
+
const timeoutMs = options.timeoutMs || ASYNC_BUILD_TIMEOUT_MS;
|
|
36095
|
+
const paths = getAsyncBuildWatcherPaths(options.projectRoot, options.taskId);
|
|
36096
|
+
const previous = stopExistingAsyncBuildResultWatcher(
|
|
36097
|
+
options.projectRoot,
|
|
36098
|
+
"cancelled_by_new_build"
|
|
36099
|
+
);
|
|
36100
|
+
const now = /* @__PURE__ */ new Date();
|
|
36101
|
+
const state = {
|
|
36102
|
+
mode: "remote_build_async",
|
|
36103
|
+
taskId: options.taskId,
|
|
36104
|
+
reused: options.reused,
|
|
36105
|
+
projectId: options.projectId,
|
|
36106
|
+
projectPath: options.projectPath,
|
|
36107
|
+
projectRoot: options.projectRoot,
|
|
36108
|
+
serverUrl: options.serverUrl,
|
|
36109
|
+
env: options.env,
|
|
36110
|
+
status: "queued",
|
|
36111
|
+
startedAt: now.toISOString(),
|
|
36112
|
+
updatedAt: now.toISOString(),
|
|
36113
|
+
deadlineAt: new Date(now.getTime() + timeoutMs).toISOString(),
|
|
36114
|
+
pollIntervalMs
|
|
36115
|
+
};
|
|
36116
|
+
let completeWatcher = () => {
|
|
36117
|
+
};
|
|
36118
|
+
const completion = new Promise((resolve) => {
|
|
36119
|
+
completeWatcher = resolve;
|
|
36120
|
+
});
|
|
36121
|
+
const watcher = {
|
|
36122
|
+
state,
|
|
36123
|
+
sourceBuildResult: options.sourceBuildResult,
|
|
36124
|
+
activeFile: paths.activeFile,
|
|
36125
|
+
stateFile: paths.stateFile,
|
|
36126
|
+
onStop: options.onStop,
|
|
36127
|
+
completion,
|
|
36128
|
+
complete: completeWatcher
|
|
36129
|
+
};
|
|
36130
|
+
fs14.mkdirSync(path15.dirname(paths.activeFile), { recursive: true });
|
|
36131
|
+
writeJsonFile2(paths.stateFile, state);
|
|
36132
|
+
writeJsonFile2(paths.activeFile, {
|
|
36133
|
+
taskId: options.taskId,
|
|
36134
|
+
reused: options.reused,
|
|
36135
|
+
projectId: options.projectId,
|
|
36136
|
+
pid: process.pid,
|
|
36137
|
+
startedAt: state.startedAt,
|
|
36138
|
+
deadlineAt: state.deadlineAt,
|
|
36139
|
+
stateFile: paths.stateFile
|
|
36140
|
+
});
|
|
36141
|
+
activeAsyncBuildWatchers.set(paths.activeFile, watcher);
|
|
36142
|
+
const poll = async () => {
|
|
36143
|
+
var _a3, _b, _c;
|
|
36144
|
+
if (!activeAsyncBuildWatchers.has(paths.activeFile)) {
|
|
36145
|
+
return;
|
|
36146
|
+
}
|
|
36147
|
+
try {
|
|
36148
|
+
const result = await options.queryBuildResult();
|
|
36149
|
+
updateAsyncBuildWatcherState(watcher, {
|
|
36150
|
+
status: result.status,
|
|
36151
|
+
resultText: result.resultText,
|
|
36152
|
+
result: result.result,
|
|
36153
|
+
error: result.error,
|
|
36154
|
+
lastPollError: void 0
|
|
36155
|
+
});
|
|
36156
|
+
emitAsyncBuildPollProgress(watcher, result, options.onProgress);
|
|
36157
|
+
if (result.status === "succeeded" || result.status === "failed") {
|
|
36158
|
+
if (result.status === "succeeded") {
|
|
36159
|
+
await finishAsyncBuildSuccessSideEffects(watcher, options);
|
|
36160
|
+
}
|
|
36161
|
+
stopAsyncBuildWatcherRuntime(watcher);
|
|
36162
|
+
(_a3 = watcher.complete) == null ? void 0 : _a3.call(watcher, watcher.state);
|
|
36163
|
+
return;
|
|
36164
|
+
}
|
|
36165
|
+
} catch (error2) {
|
|
36166
|
+
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
36167
|
+
if (isAsyncBuildExpiredErrorMessage(message)) {
|
|
36168
|
+
updateAsyncBuildWatcherState(watcher, {
|
|
36169
|
+
status: "expired",
|
|
36170
|
+
error: message,
|
|
36171
|
+
lastPollError: message
|
|
36172
|
+
});
|
|
36173
|
+
stopAsyncBuildWatcherRuntime(watcher);
|
|
36174
|
+
(_b = watcher.complete) == null ? void 0 : _b.call(watcher, watcher.state);
|
|
36175
|
+
return;
|
|
36176
|
+
}
|
|
36177
|
+
const nextStatus = "running";
|
|
36178
|
+
updateAsyncBuildWatcherState(watcher, {
|
|
36179
|
+
status: nextStatus,
|
|
36180
|
+
lastPollError: message
|
|
36181
|
+
});
|
|
36182
|
+
emitAsyncBuildPollProgress(
|
|
36183
|
+
watcher,
|
|
36184
|
+
{ status: nextStatus, error: message },
|
|
36185
|
+
options.onProgress
|
|
36186
|
+
);
|
|
36187
|
+
}
|
|
36188
|
+
if (Date.now() >= Date.parse(watcher.state.deadlineAt)) {
|
|
36189
|
+
updateAsyncBuildWatcherState(watcher, { status: "timeout" });
|
|
36190
|
+
stopAsyncBuildWatcherRuntime(watcher);
|
|
36191
|
+
(_c = watcher.complete) == null ? void 0 : _c.call(watcher, watcher.state);
|
|
36192
|
+
return;
|
|
36193
|
+
}
|
|
36194
|
+
watcher.timer = setTimeout(() => {
|
|
36195
|
+
void poll();
|
|
36196
|
+
}, pollIntervalMs);
|
|
36197
|
+
};
|
|
36198
|
+
watcher.timer = setTimeout(() => {
|
|
36199
|
+
void poll();
|
|
36200
|
+
}, pollIntervalMs);
|
|
36201
|
+
return {
|
|
36202
|
+
started: true,
|
|
36203
|
+
taskId: options.taskId,
|
|
36204
|
+
reused: options.reused,
|
|
36205
|
+
activeFile: paths.activeFile,
|
|
36206
|
+
stateFile: paths.stateFile,
|
|
36207
|
+
pollIntervalMs,
|
|
36208
|
+
timeoutMs,
|
|
36209
|
+
previousTaskId: previous.previousTaskId,
|
|
36210
|
+
previousStopped: previous.previousStopped
|
|
36211
|
+
};
|
|
36212
|
+
}
|
|
36213
|
+
function stopAsyncBuildWatcherRuntime(watcher) {
|
|
36214
|
+
var _a3;
|
|
36215
|
+
if (watcher.stopped) {
|
|
36216
|
+
return;
|
|
36217
|
+
}
|
|
36218
|
+
watcher.stopped = true;
|
|
36219
|
+
if (watcher.timer) {
|
|
36220
|
+
clearTimeout(watcher.timer);
|
|
36221
|
+
watcher.timer = void 0;
|
|
36222
|
+
}
|
|
36223
|
+
activeAsyncBuildWatchers.delete(watcher.activeFile);
|
|
36224
|
+
fs14.rmSync(watcher.activeFile, { force: true });
|
|
36225
|
+
void Promise.resolve((_a3 = watcher.onStop) == null ? void 0 : _a3.call(watcher)).catch((error2) => {
|
|
36226
|
+
updateAsyncBuildWatcherState(watcher, {
|
|
36227
|
+
sideEffectError: `async query runner close failed: ${error2 instanceof Error ? error2.message : String(error2)}`
|
|
36228
|
+
});
|
|
36229
|
+
});
|
|
36230
|
+
}
|
|
36231
|
+
function isAsyncBuildExpiredErrorMessage(message) {
|
|
36232
|
+
const normalized = message.trim().toLowerCase();
|
|
36233
|
+
return [
|
|
36234
|
+
"not found",
|
|
36235
|
+
"not_found",
|
|
36236
|
+
"not exist",
|
|
36237
|
+
"unknown build",
|
|
36238
|
+
"unknown build_id",
|
|
36239
|
+
"expired",
|
|
36240
|
+
"restart",
|
|
36241
|
+
"restarted",
|
|
36242
|
+
"未找到",
|
|
36243
|
+
"不存在",
|
|
36244
|
+
"过期",
|
|
36245
|
+
"服务重启"
|
|
36246
|
+
].some((pattern) => normalized.includes(pattern));
|
|
36247
|
+
}
|
|
36248
|
+
function emitAsyncBuildPollProgress(watcher, result, onProgress) {
|
|
36249
|
+
if (!onProgress) {
|
|
36250
|
+
return;
|
|
36251
|
+
}
|
|
36252
|
+
const payload = result.result && typeof result.result === "object" && !Array.isArray(result.result) ? result.result : {};
|
|
36253
|
+
const remoteProgress = typeof payload.progress === "number" ? payload.progress : void 0;
|
|
36254
|
+
const remotePhase = typeof payload.phase === "string" && payload.phase.trim() ? payload.phase.trim() : void 0;
|
|
36255
|
+
const elapsedSeconds = typeof payload.elapsed_seconds === "number" ? payload.elapsed_seconds : void 0;
|
|
36256
|
+
onProgress({
|
|
36257
|
+
progress: remoteProgress,
|
|
36258
|
+
total: remoteProgress === void 0 ? void 0 : 100,
|
|
36259
|
+
phase: "async_build_poll",
|
|
36260
|
+
message: [
|
|
36261
|
+
`build_id=${watcher.state.taskId}`,
|
|
36262
|
+
`status=${result.status}`,
|
|
36263
|
+
remotePhase ? `phase=${remotePhase}` : "",
|
|
36264
|
+
elapsedSeconds !== void 0 ? `elapsed=${elapsedSeconds}s` : "",
|
|
36265
|
+
result.error ? `error=${formatAsyncBuildDiagnostic(result.error)}` : ""
|
|
36266
|
+
].filter(Boolean).join(" ")
|
|
36267
|
+
});
|
|
36268
|
+
}
|
|
36269
|
+
function stopExistingAsyncBuildResultWatcher(projectRoot, reason = "cancelled") {
|
|
36270
|
+
var _a3;
|
|
36271
|
+
const activeFile = getAsyncBuildWatcherPaths(projectRoot, "unused").activeFile;
|
|
36272
|
+
const active = readJsonFile2(activeFile);
|
|
36273
|
+
const watcher = activeAsyncBuildWatchers.get(activeFile);
|
|
36274
|
+
if (!active && !watcher) {
|
|
36275
|
+
return {};
|
|
36276
|
+
}
|
|
36277
|
+
const stateFile = (active == null ? void 0 : active.stateFile) || (watcher == null ? void 0 : watcher.stateFile);
|
|
36278
|
+
const taskId = (active == null ? void 0 : active.taskId) || (watcher == null ? void 0 : watcher.state.taskId);
|
|
36279
|
+
if (stateFile && fs14.existsSync(stateFile)) {
|
|
36280
|
+
const existing = readJsonFile2(stateFile) || {};
|
|
36281
|
+
writeJsonFile2(stateFile, {
|
|
36282
|
+
...existing,
|
|
36283
|
+
status: reason,
|
|
36284
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
36285
|
+
});
|
|
36286
|
+
}
|
|
36287
|
+
if (watcher) {
|
|
36288
|
+
updateAsyncBuildWatcherState(watcher, {
|
|
36289
|
+
status: reason,
|
|
36290
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
36291
|
+
});
|
|
36292
|
+
stopAsyncBuildWatcherRuntime(watcher);
|
|
36293
|
+
(_a3 = watcher.complete) == null ? void 0 : _a3.call(watcher, watcher.state);
|
|
36294
|
+
} else {
|
|
36295
|
+
fs14.rmSync(activeFile, { force: true });
|
|
36296
|
+
}
|
|
36297
|
+
return {
|
|
36298
|
+
previousTaskId: taskId,
|
|
36299
|
+
previousStopped: Boolean(taskId)
|
|
36300
|
+
};
|
|
36301
|
+
}
|
|
36302
|
+
async function finishAsyncBuildSuccessSideEffects(watcher, options) {
|
|
36303
|
+
const buildResult = asyncWatcherStateToRemoteBuildResult(
|
|
36304
|
+
watcher.state,
|
|
36305
|
+
watcher.sourceBuildResult
|
|
36306
|
+
);
|
|
36307
|
+
if (options.refreshPreview) {
|
|
36308
|
+
try {
|
|
36309
|
+
updateAsyncBuildWatcherState(watcher, {
|
|
36310
|
+
previewRefresh: await options.refreshPreview(buildResult)
|
|
36311
|
+
});
|
|
36312
|
+
} catch (error2) {
|
|
36313
|
+
updateAsyncBuildWatcherState(watcher, {
|
|
36314
|
+
previewRefresh: {
|
|
36315
|
+
ok: false,
|
|
36316
|
+
status: 0,
|
|
36317
|
+
url: "",
|
|
36318
|
+
error: error2 instanceof Error ? error2.message : String(error2)
|
|
36319
|
+
}
|
|
36320
|
+
});
|
|
36321
|
+
}
|
|
36322
|
+
}
|
|
36323
|
+
if (options.startRuntimeLogWatch) {
|
|
36324
|
+
try {
|
|
36325
|
+
updateAsyncBuildWatcherState(watcher, {
|
|
36326
|
+
runtimeLogWatch: await options.startRuntimeLogWatch(buildResult)
|
|
36327
|
+
});
|
|
36328
|
+
} catch (error2) {
|
|
36329
|
+
updateAsyncBuildWatcherState(watcher, {
|
|
36330
|
+
runtimeLogWatch: {
|
|
36331
|
+
started: false,
|
|
36332
|
+
command: "",
|
|
36333
|
+
runtimeLog: "",
|
|
36334
|
+
error: error2 instanceof Error ? error2.message : String(error2)
|
|
36335
|
+
}
|
|
36336
|
+
});
|
|
36337
|
+
}
|
|
36338
|
+
}
|
|
36339
|
+
}
|
|
36340
|
+
function asyncWatcherStateToRemoteBuildResult(state, originalBuildResult) {
|
|
36341
|
+
return {
|
|
36342
|
+
mode: "remote_build",
|
|
36343
|
+
projectRoot: state.projectRoot,
|
|
36344
|
+
projectId: state.projectId,
|
|
36345
|
+
projectPath: state.projectPath,
|
|
36346
|
+
serverUrl: state.serverUrl,
|
|
36347
|
+
env: state.env,
|
|
36348
|
+
makerUrl: formatMakerAppWebUrl(state.projectId, state.env),
|
|
36349
|
+
timeoutMs: (originalBuildResult == null ? void 0 : originalBuildResult.timeoutMs) || DEFAULT_BUILD_TIMEOUT_MS,
|
|
36350
|
+
buildArgs: (originalBuildResult == null ? void 0 : originalBuildResult.buildArgs) || {},
|
|
36351
|
+
resultText: state.resultText || "",
|
|
36352
|
+
previewRefresh: state.previewRefresh,
|
|
36353
|
+
runtimeLogWatch: state.runtimeLogWatch
|
|
36354
|
+
};
|
|
36355
|
+
}
|
|
36356
|
+
function updateAsyncBuildWatcherState(watcher, patch) {
|
|
36357
|
+
watcher.state = {
|
|
36358
|
+
...watcher.state,
|
|
36359
|
+
...patch,
|
|
36360
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
36361
|
+
};
|
|
36362
|
+
writeJsonFile2(watcher.stateFile, watcher.state);
|
|
36363
|
+
}
|
|
36364
|
+
function getAsyncBuildWatcherPaths(projectRoot, taskId) {
|
|
36365
|
+
const normalizedProjectRoot = normalizeExistingProjectPath(projectRoot);
|
|
36366
|
+
const buildDir = path15.join(normalizedProjectRoot, ".maker", "builds");
|
|
36367
|
+
return {
|
|
36368
|
+
activeFile: path15.join(buildDir, "active-build.json"),
|
|
36369
|
+
stateFile: path15.join(buildDir, `${sanitizeAsyncBuildTaskId(taskId)}.json`)
|
|
36370
|
+
};
|
|
36371
|
+
}
|
|
36372
|
+
function normalizeExistingProjectPath(projectRoot) {
|
|
36373
|
+
try {
|
|
36374
|
+
return fs14.realpathSync(projectRoot);
|
|
36375
|
+
} catch {
|
|
36376
|
+
return path15.resolve(projectRoot);
|
|
36377
|
+
}
|
|
36378
|
+
}
|
|
36379
|
+
function sanitizeAsyncBuildTaskId(taskId) {
|
|
36380
|
+
return taskId.replace(/[^A-Za-z0-9_.-]/g, "_") || "unknown-task";
|
|
36381
|
+
}
|
|
36382
|
+
function writeJsonFile2(filePath, value) {
|
|
36383
|
+
fs14.mkdirSync(path15.dirname(filePath), { recursive: true });
|
|
36384
|
+
fs14.writeFileSync(filePath, `${JSON.stringify(value, null, 2)}
|
|
36385
|
+
`, "utf8");
|
|
36386
|
+
}
|
|
36387
|
+
function readJsonFile2(filePath) {
|
|
36388
|
+
if (!fs14.existsSync(filePath)) {
|
|
36389
|
+
return void 0;
|
|
36390
|
+
}
|
|
36391
|
+
try {
|
|
36392
|
+
return JSON.parse(fs14.readFileSync(filePath, "utf8"));
|
|
36393
|
+
} catch {
|
|
36394
|
+
return void 0;
|
|
36395
|
+
}
|
|
36396
|
+
}
|
|
35864
36397
|
function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
|
|
35865
36398
|
if (!fs14.existsSync(pidFile)) {
|
|
35866
36399
|
return {};
|
|
@@ -36135,7 +36668,8 @@ function toMakerBuildFailure(error2) {
|
|
|
36135
36668
|
return {
|
|
36136
36669
|
name: error2 instanceof Error ? error2.name : typeof error2,
|
|
36137
36670
|
message: error2 instanceof Error ? error2.message : String(error2),
|
|
36138
|
-
...error2 instanceof Error && error2.stack ? { stack: error2.stack } : {}
|
|
36671
|
+
...error2 instanceof Error && error2.stack ? { stack: error2.stack } : {},
|
|
36672
|
+
...error2 instanceof Error ? errorOwnDiagnosticFields(error2) : {}
|
|
36139
36673
|
};
|
|
36140
36674
|
}
|
|
36141
36675
|
function createBuildArgs(projectRoot, options) {
|
|
@@ -36161,8 +36695,41 @@ function createBuildArgs(projectRoot, options) {
|
|
|
36161
36695
|
} else if (!fs14.existsSync(path15.join(projectRoot, ".project", "settings.json"))) {
|
|
36162
36696
|
buildArgs.multiplayer = { enabled: false };
|
|
36163
36697
|
}
|
|
36698
|
+
if (shouldForwardAsyncBuild(options.asyncBuild, options.clientIde)) {
|
|
36699
|
+
buildArgs[getRemoteAsyncBuildParamName()] = getRemoteAsyncBuildParamValue();
|
|
36700
|
+
}
|
|
36164
36701
|
return buildArgs;
|
|
36165
36702
|
}
|
|
36703
|
+
function shouldForwardAsyncBuild(asyncBuild, clientIde) {
|
|
36704
|
+
if (asyncBuild === true) {
|
|
36705
|
+
return true;
|
|
36706
|
+
}
|
|
36707
|
+
if (asyncBuild === false) {
|
|
36708
|
+
return false;
|
|
36709
|
+
}
|
|
36710
|
+
return normalizeClientIde(clientIde || process.env.TAPTAP_MCP_CLIENT_IDE) === "workbuddy";
|
|
36711
|
+
}
|
|
36712
|
+
function normalizeClientIde(clientIde) {
|
|
36713
|
+
return (clientIde || "").trim().toLowerCase();
|
|
36714
|
+
}
|
|
36715
|
+
function getRemoteAsyncBuildParamName() {
|
|
36716
|
+
var _a3;
|
|
36717
|
+
const paramName = (_a3 = process.env.TAPTAP_MAKER_REMOTE_ASYNC_BUILD_PARAM) == null ? void 0 : _a3.trim();
|
|
36718
|
+
return paramName || DEFAULT_REMOTE_ASYNC_BUILD_PARAM;
|
|
36719
|
+
}
|
|
36720
|
+
function getRemoteAsyncBuildParamValue() {
|
|
36721
|
+
const rawValue = process.env.TAPTAP_MAKER_REMOTE_ASYNC_BUILD_VALUE_JSON;
|
|
36722
|
+
if (!rawValue) {
|
|
36723
|
+
return true;
|
|
36724
|
+
}
|
|
36725
|
+
try {
|
|
36726
|
+
return JSON.parse(rawValue);
|
|
36727
|
+
} catch (error2) {
|
|
36728
|
+
throw new Error(
|
|
36729
|
+
`Invalid TAPTAP_MAKER_REMOTE_ASYNC_BUILD_VALUE_JSON: ${error2 instanceof Error ? error2.message : String(error2)}`
|
|
36730
|
+
);
|
|
36731
|
+
}
|
|
36732
|
+
}
|
|
36166
36733
|
function mergeStringEnv(...sources) {
|
|
36167
36734
|
const result = {};
|
|
36168
36735
|
for (const source of sources) {
|
|
@@ -36193,13 +36760,13 @@ function formatRemoteToolResult(result) {
|
|
|
36193
36760
|
}).join("\n");
|
|
36194
36761
|
}
|
|
36195
36762
|
function formatBuildResult(result, progressSummary) {
|
|
36763
|
+
var _a3, _b;
|
|
36196
36764
|
if (result.mode === "remote_build_failed") {
|
|
36197
36765
|
return [
|
|
36198
36766
|
"✗ Remote Maker build failed",
|
|
36199
36767
|
"",
|
|
36200
36768
|
`- project_root: ${result.projectRoot}`,
|
|
36201
36769
|
`- project_id: ${result.projectId}`,
|
|
36202
|
-
...formatMakerPageOpenLines(result.makerPageOpen),
|
|
36203
36770
|
`- maker_url: ${result.buildResult.makerUrl || formatMakerAppWebUrl(result.buildResult.projectId, result.buildResult.env)}`,
|
|
36204
36771
|
`- project_path: ${result.buildResult.projectPath}`,
|
|
36205
36772
|
`- server_url: ${result.buildResult.serverUrl}`,
|
|
@@ -36256,6 +36823,35 @@ function formatBuildResult(result, progressSummary) {
|
|
|
36256
36823
|
...formatMakerBuildFailureLines(result.buildFailure)
|
|
36257
36824
|
].filter(Boolean).join("\n");
|
|
36258
36825
|
}
|
|
36826
|
+
if (result.mode === "remote_build_async_started") {
|
|
36827
|
+
return [
|
|
36828
|
+
result.submitResult ? "✓ Maker project submitted, then remote Maker async build started" : "✓ Remote Maker async build started",
|
|
36829
|
+
"",
|
|
36830
|
+
`- project_root: ${result.projectRoot}`,
|
|
36831
|
+
`- project_id: ${result.projectId}`,
|
|
36832
|
+
`- maker_url: ${result.makerUrl || formatMakerAppWebUrl(result.projectId, result.env)}`,
|
|
36833
|
+
`- project_path: ${result.projectPath}`,
|
|
36834
|
+
`- server_url: ${result.serverUrl}`,
|
|
36835
|
+
`- env: ${result.env}`,
|
|
36836
|
+
`- build_id: ${result.taskId}`,
|
|
36837
|
+
result.reused !== void 0 ? `- reused: ${result.reused ? "yes" : "no"}` : "",
|
|
36838
|
+
`- timeout_ms: ${result.timeoutMs}`,
|
|
36839
|
+
`- build_args: ${JSON.stringify(result.buildArgs)}`,
|
|
36840
|
+
result.asyncBuildWatch ? `- async_watch_started: ${result.asyncBuildWatch.started ? "yes" : "no"}` : "",
|
|
36841
|
+
result.asyncBuildWatch ? `- async_watch_state_file: ${result.asyncBuildWatch.stateFile}` : "",
|
|
36842
|
+
result.asyncBuildWatch ? `- async_watch_active_file: ${result.asyncBuildWatch.activeFile}` : "",
|
|
36843
|
+
result.asyncBuildWatch ? `- async_watch_poll_interval_ms: ${result.asyncBuildWatch.pollIntervalMs}` : "",
|
|
36844
|
+
result.asyncBuildWatch ? `- async_watch_timeout_ms: ${result.asyncBuildWatch.timeoutMs}` : "",
|
|
36845
|
+
((_a3 = result.asyncBuildWatch) == null ? void 0 : _a3.previousTaskId) ? `- previous_async_build_id: ${result.asyncBuildWatch.previousTaskId}` : "",
|
|
36846
|
+
((_b = result.asyncBuildWatch) == null ? void 0 : _b.previousStopped) !== void 0 ? `- previous_async_watch_stopped: ${result.asyncBuildWatch.previousStopped ? "yes" : "no"}` : "",
|
|
36847
|
+
...formatProgressSummary(progressSummary),
|
|
36848
|
+
"",
|
|
36849
|
+
"note: 远端异步构建已启动;本地每 5 秒查询一次结果,最多轮询 30 分钟。",
|
|
36850
|
+
"note: 如果同一 Maker 项目再次触发构建,上一轮异步轮询会被取消。",
|
|
36851
|
+
"remote_result:",
|
|
36852
|
+
indent2(result.resultText)
|
|
36853
|
+
].filter(Boolean).join("\n");
|
|
36854
|
+
}
|
|
36259
36855
|
const submitLines = result.submitResult ? [
|
|
36260
36856
|
"submit_result:",
|
|
36261
36857
|
` - branch: ${result.submitResult.branch}`,
|
|
@@ -36273,7 +36869,6 @@ function formatBuildResult(result, progressSummary) {
|
|
|
36273
36869
|
`- project_root: ${result.projectRoot}`,
|
|
36274
36870
|
`- project_id: ${result.projectId}`,
|
|
36275
36871
|
`- maker_url: ${result.makerUrl || formatMakerAppWebUrl(result.projectId, result.env)}`,
|
|
36276
|
-
...formatMakerPageOpenLines(result.makerPageOpen),
|
|
36277
36872
|
`- project_path: ${result.projectPath}`,
|
|
36278
36873
|
`- server_url: ${result.serverUrl}`,
|
|
36279
36874
|
`- env: ${result.env}`
|
|
@@ -36304,17 +36899,6 @@ function formatPreviewRefreshLines(result) {
|
|
|
36304
36899
|
result.error ? `- preview_refresh_error: ${result.error}` : ""
|
|
36305
36900
|
].filter(Boolean);
|
|
36306
36901
|
}
|
|
36307
|
-
function formatMakerPageOpenLines(result) {
|
|
36308
|
-
if (!result) {
|
|
36309
|
-
return [];
|
|
36310
|
-
}
|
|
36311
|
-
return [
|
|
36312
|
-
`- maker_page_open: ${result.ok ? "ok" : "failed"}`,
|
|
36313
|
-
`- maker_page_url: ${result.url}`,
|
|
36314
|
-
result.error ? `- maker_page_error: ${result.error}` : "",
|
|
36315
|
-
"- next_action: 已按“不提交,只构建云端版本”打开 Maker 远端页面;如果没有自动弹出,请手动打开 maker_page_url 后再查看构建结果。"
|
|
36316
|
-
].filter(Boolean);
|
|
36317
|
-
}
|
|
36318
36902
|
function formatRuntimeLogWatchNextActionLines(result) {
|
|
36319
36903
|
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
36320
36904
|
const command = formatLocalShellCommand([
|
|
@@ -36376,14 +36960,27 @@ function pushRecoveryUserMessage(failure) {
|
|
|
36376
36960
|
}
|
|
36377
36961
|
}
|
|
36378
36962
|
function formatMakerBuildFailureLines(failure) {
|
|
36963
|
+
const details = buildFailureDiagnosticFields(failure);
|
|
36379
36964
|
return [
|
|
36380
36965
|
"build_failure:",
|
|
36381
36966
|
`- error_name: ${failure.name}`,
|
|
36382
36967
|
`- message: ${failure.message}`,
|
|
36968
|
+
Object.keys(details).length > 0 ? `- error_details:
|
|
36969
|
+
${indent2(formatDiagnosticJson(details))}` : "",
|
|
36383
36970
|
failure.stack ? `- stack:
|
|
36384
36971
|
${indent2(failure.stack)}` : ""
|
|
36385
36972
|
].filter(Boolean);
|
|
36386
36973
|
}
|
|
36974
|
+
function buildFailureDiagnosticFields(failure) {
|
|
36975
|
+
const details = {};
|
|
36976
|
+
for (const [key, value] of Object.entries(failure)) {
|
|
36977
|
+
if (key === "name" || key === "message" || key === "stack") {
|
|
36978
|
+
continue;
|
|
36979
|
+
}
|
|
36980
|
+
details[key] = sanitizeDiagnosticValue(value);
|
|
36981
|
+
}
|
|
36982
|
+
return details;
|
|
36983
|
+
}
|
|
36387
36984
|
function formatMakerFailureLines(failure) {
|
|
36388
36985
|
return [
|
|
36389
36986
|
"failure:",
|
|
@@ -36513,7 +37110,7 @@ function indent2(value) {
|
|
|
36513
37110
|
}
|
|
36514
37111
|
|
|
36515
37112
|
// src/maker/cli/commands.ts
|
|
36516
|
-
import { spawnSync as
|
|
37113
|
+
import { spawnSync as spawnSync7 } from "node:child_process";
|
|
36517
37114
|
import crypto3 from "node:crypto";
|
|
36518
37115
|
import fs15 from "node:fs";
|
|
36519
37116
|
import os4 from "node:os";
|
|
@@ -36522,7 +37119,7 @@ import readline from "node:readline/promises";
|
|
|
36522
37119
|
import { stdin as input, stdout as output } from "node:process";
|
|
36523
37120
|
|
|
36524
37121
|
// src/maker/auth/cliLogin.ts
|
|
36525
|
-
import { spawnSync as
|
|
37122
|
+
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
36526
37123
|
import crypto2 from "node:crypto";
|
|
36527
37124
|
var DEFAULT_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
36528
37125
|
var DEFAULT_POLL_INTERVAL_MS = 1e3;
|
|
@@ -36641,7 +37238,7 @@ async function readJsonResponse(response) {
|
|
|
36641
37238
|
function openBrowser(url2) {
|
|
36642
37239
|
const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
|
|
36643
37240
|
const args = process.platform === "win32" ? ["/c", "start", "", url2] : [url2];
|
|
36644
|
-
const result =
|
|
37241
|
+
const result = spawnSync6(command, args, {
|
|
36645
37242
|
stdio: "ignore",
|
|
36646
37243
|
windowsHide: true
|
|
36647
37244
|
});
|
|
@@ -36663,7 +37260,7 @@ function formatError2(error2) {
|
|
|
36663
37260
|
}
|
|
36664
37261
|
|
|
36665
37262
|
// src/maker/cli/commands.ts
|
|
36666
|
-
var VERSION2 = true ? "0.0.
|
|
37263
|
+
var VERSION2 = true ? "0.0.22-beta.1" : "dev";
|
|
36667
37264
|
var DEFAULT_MCP_NAME = "taptap-maker";
|
|
36668
37265
|
var MAKER_NPM_PACKAGE = "@taptap/maker";
|
|
36669
37266
|
var TWO_PART_COMMANDS = /* @__PURE__ */ new Set(["pat", "mcp", "dev-kit", "logs", "python", "lua-lsp", "agents"]);
|
|
@@ -37031,7 +37628,7 @@ function inspectMakerOrphanProcesses() {
|
|
|
37031
37628
|
if (process.platform === "win32") {
|
|
37032
37629
|
return { status: "not_supported_on_windows", processes: [] };
|
|
37033
37630
|
}
|
|
37034
|
-
const result =
|
|
37631
|
+
const result = spawnSync7("ps", ["-axo", "pid,ppid,pcpu,etime,command"], {
|
|
37035
37632
|
encoding: "utf8"
|
|
37036
37633
|
});
|
|
37037
37634
|
if (result.status !== 0 || typeof result.stdout !== "string") {
|
|
@@ -37384,7 +37981,7 @@ async function runMcpVerify(parsed, ctx) {
|
|
|
37384
37981
|
rejectPackageOption(parsed);
|
|
37385
37982
|
const mode = mcpVerifyModeOption(parsed);
|
|
37386
37983
|
const command = mode === "npx" ? getNpxCliCommand(MAKER_NPM_PACKAGE) : getCurrentCliCommand();
|
|
37387
|
-
const result =
|
|
37984
|
+
const result = spawnSync7(command.command, [...command.args, "help"], {
|
|
37388
37985
|
encoding: "utf8"
|
|
37389
37986
|
});
|
|
37390
37987
|
const failureType = classifyMcpVerifyFailure(result);
|
|
@@ -37905,17 +38502,18 @@ function installMcpConfig(ide, options) {
|
|
|
37905
38502
|
function installMcpConfigUnsafe(ide, options) {
|
|
37906
38503
|
if (ide === "codex") {
|
|
37907
38504
|
const configPath = path16.join(os4.homedir(), ".codex", "config.toml");
|
|
37908
|
-
const write = mergeCodexMcpConfig(configPath, options);
|
|
38505
|
+
const write = mergeCodexMcpConfig(configPath, withClientIde(options, "codex"));
|
|
37909
38506
|
return [createMcpInstallResult(ide, "Codex", configPath, write)];
|
|
37910
38507
|
}
|
|
37911
38508
|
if (ide === "cursor") {
|
|
37912
38509
|
const configPath = path16.join(os4.homedir(), ".cursor", "mcp.json");
|
|
37913
|
-
const write = mergeJsonMcpConfig(configPath, options);
|
|
38510
|
+
const write = mergeJsonMcpConfig(configPath, withClientIde(options, "cursor"));
|
|
37914
38511
|
return [createMcpInstallResult(ide, "Cursor", configPath, write)];
|
|
37915
38512
|
}
|
|
37916
38513
|
if (ide === "claude") {
|
|
38514
|
+
const claudeOptions = withClientIde(options, "claude");
|
|
37917
38515
|
if (!options.cwd) {
|
|
37918
|
-
const claudeResult = tryClaudeMcpAdd(
|
|
38516
|
+
const claudeResult = tryClaudeMcpAdd(claudeOptions);
|
|
37919
38517
|
if (claudeResult.ok) {
|
|
37920
38518
|
return [
|
|
37921
38519
|
{
|
|
@@ -37927,20 +38525,25 @@ function installMcpConfigUnsafe(ide, options) {
|
|
|
37927
38525
|
}
|
|
37928
38526
|
}
|
|
37929
38527
|
const configPath = path16.join(os4.homedir(), ".claude.json");
|
|
37930
|
-
const write = mergeJsonMcpConfig(configPath,
|
|
38528
|
+
const write = mergeJsonMcpConfig(configPath, claudeOptions);
|
|
37931
38529
|
return [createMcpInstallResult(ide, "Claude fallback", configPath, write)];
|
|
37932
38530
|
}
|
|
37933
38531
|
if (ide === "trae") {
|
|
37934
|
-
return installJsonMcpConfigTargets(
|
|
38532
|
+
return installJsonMcpConfigTargets(
|
|
38533
|
+
ide,
|
|
38534
|
+
getTraeMcpInstallPaths(),
|
|
38535
|
+
"Trae",
|
|
38536
|
+
withClientIde(options, "trae")
|
|
38537
|
+
);
|
|
37935
38538
|
}
|
|
37936
38539
|
if (ide === "opencode") {
|
|
37937
38540
|
const configPath = getOpenCodeMcpConfigPath();
|
|
37938
38541
|
if (!fs15.existsSync(configPath)) {
|
|
37939
38542
|
return [{ ide, ok: false, message: "Skipped OpenCode: no supported config file found" }];
|
|
37940
38543
|
}
|
|
37941
|
-
const write = mergeOpenCodeMcpConfig(configPath, options);
|
|
38544
|
+
const write = mergeOpenCodeMcpConfig(configPath, withClientIde(options, "opencode"));
|
|
37942
38545
|
const result = createMcpInstallResult(ide, "OpenCode", configPath, write);
|
|
37943
|
-
if (write.
|
|
38546
|
+
if (write.rewroteJsonc) {
|
|
37944
38547
|
result.message += "\n Note: OpenCode config was rewritten as standard JSON.";
|
|
37945
38548
|
}
|
|
37946
38549
|
return [result];
|
|
@@ -37948,13 +38551,19 @@ function installMcpConfigUnsafe(ide, options) {
|
|
|
37948
38551
|
if (ide === "workbuddy") {
|
|
37949
38552
|
return installJsonMcpConfigTargets(
|
|
37950
38553
|
ide,
|
|
37951
|
-
getWorkBuddyMcpInstallPaths(
|
|
38554
|
+
getWorkBuddyMcpInstallPaths({ createPrimary: true }),
|
|
37952
38555
|
"WorkBuddy",
|
|
37953
|
-
|
|
38556
|
+
{
|
|
38557
|
+
...options,
|
|
38558
|
+
clientIde: "workbuddy"
|
|
38559
|
+
}
|
|
37954
38560
|
);
|
|
37955
38561
|
}
|
|
37956
38562
|
return [{ ide, ok: false, message: `Skipped unknown IDE: ${ide}` }];
|
|
37957
38563
|
}
|
|
38564
|
+
function withClientIde(options, clientIde) {
|
|
38565
|
+
return { ...options, clientIde };
|
|
38566
|
+
}
|
|
37958
38567
|
function installJsonMcpConfigTargets(ide, configPaths, label, options) {
|
|
37959
38568
|
if (configPaths.length === 0) {
|
|
37960
38569
|
return [{ ide, ok: false, message: `Skipped ${label}: no supported config file found` }];
|
|
@@ -37991,7 +38600,7 @@ function getDefaultMcpInstallIdes() {
|
|
|
37991
38600
|
if (fs15.existsSync(getOpenCodeMcpConfigPath())) {
|
|
37992
38601
|
ides.push("opencode");
|
|
37993
38602
|
}
|
|
37994
|
-
if (getWorkBuddyMcpInstallPaths(
|
|
38603
|
+
if (getWorkBuddyMcpInstallPaths().length > 0) {
|
|
37995
38604
|
ides.push("workbuddy");
|
|
37996
38605
|
}
|
|
37997
38606
|
return ides;
|
|
@@ -38060,19 +38669,16 @@ function getTraeUnverifiedMcpConfigPaths() {
|
|
|
38060
38669
|
function getOpenCodeMcpConfigPath() {
|
|
38061
38670
|
return path16.join(os4.homedir(), ".config", "opencode", "opencode.jsonc");
|
|
38062
38671
|
}
|
|
38063
|
-
function getWorkBuddyMcpInstallPaths(
|
|
38672
|
+
function getWorkBuddyMcpInstallPaths(options = {}) {
|
|
38064
38673
|
const primary = path16.join(os4.homedir(), ".workbuddy", "mcp.json");
|
|
38065
|
-
|
|
38066
|
-
|
|
38067
|
-
const fallback = process.platform === "win32" ? runtime : primary;
|
|
38068
|
-
const paths = [];
|
|
38069
|
-
if (fs15.existsSync(preferred)) {
|
|
38070
|
-
paths.push(preferred);
|
|
38674
|
+
if (fs15.existsSync(primary) || options.createPrimary) {
|
|
38675
|
+
return [primary];
|
|
38071
38676
|
}
|
|
38072
|
-
|
|
38073
|
-
|
|
38677
|
+
const legacy = path16.join(os4.homedir(), ".workbuddy", ".mcp.json");
|
|
38678
|
+
if (fs15.existsSync(legacy)) {
|
|
38679
|
+
return [legacy];
|
|
38074
38680
|
}
|
|
38075
|
-
return
|
|
38681
|
+
return [];
|
|
38076
38682
|
}
|
|
38077
38683
|
function mergeJsonMcpConfig(configPath, options) {
|
|
38078
38684
|
const existing = readJsonObject(configPath);
|
|
@@ -38087,6 +38693,8 @@ function mergeJsonMcpConfig(configPath, options) {
|
|
|
38087
38693
|
);
|
|
38088
38694
|
}
|
|
38089
38695
|
function mergeOpenCodeMcpConfig(configPath, options) {
|
|
38696
|
+
const rawContent = fs15.readFileSync(configPath, "utf8");
|
|
38697
|
+
const rewroteJsonc = normalizeJsonConfigContent(rawContent, { jsonc: true }) !== rawContent;
|
|
38090
38698
|
const existing = readJsonObject(configPath, { jsonc: true });
|
|
38091
38699
|
const mcp = asObject(existing.mcp);
|
|
38092
38700
|
mcp[options.mcpName] = createOpenCodeMcpServerConfig(options);
|
|
@@ -38103,19 +38711,25 @@ function mergeOpenCodeMcpConfig(configPath, options) {
|
|
|
38103
38711
|
if (!existing.$schema) {
|
|
38104
38712
|
existing.$schema = "https://opencode.ai/config.json";
|
|
38105
38713
|
}
|
|
38106
|
-
|
|
38714
|
+
const write = writeConfigWithTapTapBackupIfChanged(
|
|
38107
38715
|
configPath,
|
|
38108
38716
|
`${JSON.stringify(existing, null, 2)}
|
|
38109
38717
|
`,
|
|
38110
38718
|
(updated) => validateOpenCodeMcpConfig(updated, options)
|
|
38111
38719
|
);
|
|
38720
|
+
return { ...write, rewroteJsonc: write.changed && rewroteJsonc };
|
|
38112
38721
|
}
|
|
38113
38722
|
function mergeCodexMcpConfig(configPath, options) {
|
|
38114
38723
|
const existing = fs15.existsSync(configPath) ? fs15.readFileSync(configPath, "utf8") : "";
|
|
38115
38724
|
const sectionPattern = createCodexMcpSectionPattern(options.mcpName);
|
|
38116
38725
|
const withoutOld = existing.replace(sectionPattern, "").trimEnd();
|
|
38117
38726
|
const launch = getNpxCliCommand(options.pkg);
|
|
38118
|
-
const
|
|
38727
|
+
const envValues = createMcpEnvironmentValues(options.env, options.clientIde);
|
|
38728
|
+
const envSection = Object.keys(envValues).length === 0 ? [] : [
|
|
38729
|
+
"",
|
|
38730
|
+
`[mcp_servers."${options.mcpName}".env]`,
|
|
38731
|
+
...Object.entries(envValues).map(([key, value]) => `${key} = "${escapeToml(value)}"`)
|
|
38732
|
+
];
|
|
38119
38733
|
const section = [
|
|
38120
38734
|
`[mcp_servers."${options.mcpName}"]`,
|
|
38121
38735
|
`command = "${escapeToml(launch.command)}"`,
|
|
@@ -38189,12 +38803,13 @@ function tryClaudeMcpAdd(options) {
|
|
|
38189
38803
|
"--transport",
|
|
38190
38804
|
"stdio",
|
|
38191
38805
|
...options.env === "production" ? [] : ["--env", `TAPTAP_MCP_ENV=${options.env}`],
|
|
38806
|
+
...options.clientIde ? ["--env", `TAPTAP_MCP_CLIENT_IDE=${options.clientIde}`] : [],
|
|
38192
38807
|
options.mcpName,
|
|
38193
38808
|
"--",
|
|
38194
38809
|
...npxLaunch.commandAndArgs
|
|
38195
38810
|
];
|
|
38196
38811
|
const claude = getWindowsCmdLaunchCommand("claude.cmd", claudeArgs);
|
|
38197
|
-
const result =
|
|
38812
|
+
const result = spawnSync7(
|
|
38198
38813
|
process.platform === "win32" ? claude.command : "claude",
|
|
38199
38814
|
process.platform === "win32" ? claude.args : claudeArgs,
|
|
38200
38815
|
{ encoding: "utf8" }
|
|
@@ -38207,7 +38822,7 @@ function createJsonMcpServerConfig(options) {
|
|
|
38207
38822
|
command: launch.command,
|
|
38208
38823
|
args: launch.args,
|
|
38209
38824
|
...options.cwd ? { cwd: options.cwd } : {},
|
|
38210
|
-
...createOptionalMcpEnvironment(options.env, "env")
|
|
38825
|
+
...createOptionalMcpEnvironment(options.env, "env", options.clientIde)
|
|
38211
38826
|
};
|
|
38212
38827
|
}
|
|
38213
38828
|
function createOpenCodeMcpServerConfig(options) {
|
|
@@ -38215,19 +38830,29 @@ function createOpenCodeMcpServerConfig(options) {
|
|
|
38215
38830
|
type: "local",
|
|
38216
38831
|
command: getOpenCodeNpxCliCommand(options.pkg),
|
|
38217
38832
|
...options.cwd ? { cwd: options.cwd } : {},
|
|
38833
|
+
...createOptionalMcpEnvironment(options.env, "environment", options.clientIde),
|
|
38218
38834
|
enabled: true
|
|
38219
38835
|
};
|
|
38220
38836
|
}
|
|
38221
|
-
function createOptionalMcpEnvironment(env, key) {
|
|
38222
|
-
|
|
38837
|
+
function createOptionalMcpEnvironment(env, key, clientIde) {
|
|
38838
|
+
const values = createMcpEnvironmentValues(env, clientIde);
|
|
38839
|
+
if (Object.keys(values).length === 0) {
|
|
38223
38840
|
return {};
|
|
38224
38841
|
}
|
|
38225
38842
|
return {
|
|
38226
|
-
[key]:
|
|
38227
|
-
TAPTAP_MCP_ENV: env
|
|
38228
|
-
}
|
|
38843
|
+
[key]: values
|
|
38229
38844
|
};
|
|
38230
38845
|
}
|
|
38846
|
+
function createMcpEnvironmentValues(env, clientIde) {
|
|
38847
|
+
const values = {};
|
|
38848
|
+
if (env !== "production") {
|
|
38849
|
+
values.TAPTAP_MCP_ENV = env;
|
|
38850
|
+
}
|
|
38851
|
+
if (clientIde) {
|
|
38852
|
+
values.TAPTAP_MCP_CLIENT_IDE = clientIde;
|
|
38853
|
+
}
|
|
38854
|
+
return values;
|
|
38855
|
+
}
|
|
38231
38856
|
function getOpenCodeNpxCliCommand(pkg) {
|
|
38232
38857
|
const executable = process.platform === "win32" ? "npx.cmd" : "npx";
|
|
38233
38858
|
return [executable, "-y", "-p", pkg, "taptap-maker"];
|
|
@@ -40922,6 +41547,9 @@ var TapTapMCPProxy = class {
|
|
|
40922
41547
|
if (!(error2 instanceof Error)) return false;
|
|
40923
41548
|
const errorMsg = error2.message.toLowerCase();
|
|
40924
41549
|
const errorCode = error2.code;
|
|
41550
|
+
if (this.isMcpApplicationError(error2)) {
|
|
41551
|
+
return false;
|
|
41552
|
+
}
|
|
40925
41553
|
const networkErrorCodes = [
|
|
40926
41554
|
"ECONNREFUSED",
|
|
40927
41555
|
// 连接拒绝
|
|
@@ -40959,6 +41587,11 @@ var TapTapMCPProxy = class {
|
|
|
40959
41587
|
}
|
|
40960
41588
|
return this.isSessionInvalidError(error2);
|
|
40961
41589
|
}
|
|
41590
|
+
isMcpApplicationError(error2) {
|
|
41591
|
+
const message = error2.message.toLowerCase();
|
|
41592
|
+
const code = error2.code;
|
|
41593
|
+
return typeof code === "number" && code < 0 || /\bmcp error -\d+/.test(message);
|
|
41594
|
+
}
|
|
40962
41595
|
/**
|
|
40963
41596
|
* 处理待处理的请求队列
|
|
40964
41597
|
*/
|
package/package.json
CHANGED
|
@@ -43,13 +43,17 @@ asks and understands they are local environment files.
|
|
|
43
43
|
|
|
44
44
|
Keep validation simple for Maker users. 用户可以直接说“提交”或“构建”:
|
|
45
45
|
|
|
46
|
-
- If the user says “提交”, “推送”, “构建”,
|
|
46
|
+
- If the current workspace is a bound Maker project and the user says “提交”, “推送”, “构建”,
|
|
47
|
+
“预览”, “跑一下”, “查看结果”, “看看效果”, or “验证游戏效果”, use
|
|
47
48
|
`maker_build_current_directory`. The tool commits when needed, pushes to Maker remote, and then
|
|
48
49
|
runs the remote build.
|
|
50
|
+
- Do not treat generic code checks like “验证代码”, “跑测试”, “lint”, or “检查实现” as Maker
|
|
51
|
+
remote build unless the user explicitly asks to build, run, or preview the Maker game.
|
|
49
52
|
- If push fails, do not start a separate build or generic Git push. Explain the returned recovery
|
|
50
53
|
details, follow the returned classification-specific recovery (`remote_rejected`,
|
|
51
54
|
`branch_not_allowed`, `forbidden_path`, or `auth`), then retry `maker_build_current_directory`.
|
|
52
|
-
- After submit or build finishes,
|
|
55
|
+
- After submit or build finishes, report the returned Maker URL, build status, and runtime log file
|
|
56
|
+
path when available. Do not auto-open TapMaker pages.
|
|
53
57
|
|
|
54
58
|
Do not create local-only test scripts just to verify Maker changes. The expected validation path is
|
|
55
|
-
chat request -> Maker MCP submit/build tool ->
|
|
59
|
+
chat request -> Maker MCP submit/build tool -> returned build result, Maker URL, and runtime logs.
|
|
@@ -52,7 +52,8 @@ exists.
|
|
|
52
52
|
| submit / commit / push to Maker | Inspect local Git state, summarize changed files, then call `maker_build_current_directory` unless blocked. |
|
|
53
53
|
| pull / update from remote | Inspect local changes first; if dirty, explain options before pulling. |
|
|
54
54
|
| conflict / merge failed | Explain why the conflict happened, list conflict files, inspect conflict hunks, propose a resolution plan, and ask before editing. |
|
|
55
|
-
| build / preview / run /
|
|
55
|
+
| build / preview / run / check game result | Use `maker_build_current_directory`; it starts the local runtime log watcher after a successful remote build result. |
|
|
56
|
+
| generic code validation / tests / lint | Do not use Maker remote build unless the user explicitly asks to build, run, or preview the Maker game. |
|
|
56
57
|
|
|
57
58
|
## Create New Maker Project Intent
|
|
58
59
|
|
|
@@ -97,7 +98,10 @@ This policy overrides generic local Git skills and generic Git workflows wheneve
|
|
|
97
98
|
directory is a Maker project, which means `.maker-mcp/config.json` exists in the project or one of
|
|
98
99
|
its parents.
|
|
99
100
|
|
|
100
|
-
Use `maker_build_current_directory` for submit, push, build, preview, run, and
|
|
101
|
+
Use `maker_build_current_directory` for submit, push, build, preview, run, and game result
|
|
102
|
+
verification requests in a bound Maker project.
|
|
103
|
+
Do not treat generic code checks like "验证代码", "跑测试", "lint", or "检查实现" as Maker
|
|
104
|
+
remote build unless the user explicitly asks to build, run, or preview the Maker game.
|
|
101
105
|
Do not create feature branches, task branches, PR/MR. Do not create task-id based Git flows for
|
|
102
106
|
Maker project submit/build work. Do not run generic Git commit/push helpers as a replacement for
|
|
103
107
|
the Maker MCP tool.
|
|
@@ -515,7 +519,7 @@ unless the user asks. Summaries should be understandable to non-programmers:
|
|
|
515
519
|
- why these files are being submitted
|
|
516
520
|
- whether any generated or suspicious files are included
|
|
517
521
|
|
|
518
|
-
For normal build/preview/
|
|
522
|
+
For normal build/preview/game-result verification requests, a clean workspace still goes through
|
|
519
523
|
`maker_build_current_directory`; Maker MCP creates and pushes an empty
|
|
520
524
|
`chore: wake maker build server` commit before remote build to wake the Maker server.
|
|
521
525
|
Only skip submit/push when the user explicitly asks to build the committed remote version.
|
|
@@ -578,8 +582,7 @@ them before build.
|
|
|
578
582
|
|
|
579
583
|
If the user explicitly asks "不提交", "直接构建", or "构建云端版本", call
|
|
580
584
|
`maker_build_current_directory` with `confirm_remote_build_without_submit=true`. In that mode, Maker
|
|
581
|
-
MCP
|
|
582
|
-
user if the browser did not open automatically.
|
|
585
|
+
MCP builds the committed remote version only and does not auto-open Maker pages.
|
|
583
586
|
|
|
584
587
|
For push failures, use the returned `classification`, `retryable`, `retry_reason`, and
|
|
585
588
|
`retry_attempts` fields. Temporary 5xx/network/timeout failures may be retried with the Maker build
|