@taptap/maker 0.0.21 → 0.0.22
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 +818 -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" : "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(getAsyncBuildActiveFilePath(projectRoot));
|
|
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,295 @@ 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
|
+
for (const candidate of extractJsonObjectCandidates(trimmed)) {
|
|
35802
|
+
try {
|
|
35803
|
+
const parsed = JSON.parse(candidate);
|
|
35804
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
35805
|
+
return parsed;
|
|
35806
|
+
}
|
|
35807
|
+
} catch {
|
|
35808
|
+
}
|
|
35809
|
+
}
|
|
35810
|
+
return void 0;
|
|
35811
|
+
}
|
|
35812
|
+
function extractJsonObjectCandidates(text) {
|
|
35813
|
+
var _a3;
|
|
35814
|
+
const candidates = /* @__PURE__ */ new Set([text]);
|
|
35815
|
+
const fencedJsonPattern = /```(?:json)?\s*([\s\S]*?)```/gi;
|
|
35816
|
+
let fencedMatch;
|
|
35817
|
+
while ((fencedMatch = fencedJsonPattern.exec(text)) !== null) {
|
|
35818
|
+
const candidate = (_a3 = fencedMatch[1]) == null ? void 0 : _a3.trim();
|
|
35819
|
+
if (candidate) {
|
|
35820
|
+
candidates.add(candidate);
|
|
35821
|
+
}
|
|
35822
|
+
}
|
|
35823
|
+
let start = -1;
|
|
35824
|
+
let depth = 0;
|
|
35825
|
+
let inString = false;
|
|
35826
|
+
let escaping = false;
|
|
35827
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
35828
|
+
const char = text[index];
|
|
35829
|
+
if (inString) {
|
|
35830
|
+
if (escaping) {
|
|
35831
|
+
escaping = false;
|
|
35832
|
+
} else if (char === "\\") {
|
|
35833
|
+
escaping = true;
|
|
35834
|
+
} else if (char === '"') {
|
|
35835
|
+
inString = false;
|
|
35836
|
+
}
|
|
35837
|
+
continue;
|
|
35838
|
+
}
|
|
35839
|
+
if (char === '"') {
|
|
35840
|
+
inString = true;
|
|
35841
|
+
continue;
|
|
35842
|
+
}
|
|
35843
|
+
if (char === "{") {
|
|
35844
|
+
if (depth === 0) {
|
|
35845
|
+
start = index;
|
|
35846
|
+
}
|
|
35847
|
+
depth += 1;
|
|
35848
|
+
continue;
|
|
35849
|
+
}
|
|
35850
|
+
if (char === "}" && depth > 0) {
|
|
35851
|
+
depth -= 1;
|
|
35852
|
+
if (depth === 0 && start >= 0) {
|
|
35853
|
+
candidates.add(text.slice(start, index + 1));
|
|
35854
|
+
start = -1;
|
|
35855
|
+
}
|
|
35856
|
+
}
|
|
35857
|
+
}
|
|
35858
|
+
return [...candidates].map((candidate) => candidate.trim()).filter(Boolean);
|
|
35859
|
+
}
|
|
35860
|
+
function attachAsyncBuildWatcher(buildResult, options) {
|
|
35861
|
+
const remoteQueryRunner = options.queryAsyncBuildResult ? void 0 : createRemoteAsyncBuildQueryRunner(buildResult);
|
|
35862
|
+
const queryBuildResult = options.queryAsyncBuildResult || ((taskId) => (remoteQueryRunner == null ? void 0 : remoteQueryRunner.query(taskId)) || Promise.reject(new Error("Async build query runner is not available")));
|
|
35863
|
+
return {
|
|
35864
|
+
...buildResult,
|
|
35865
|
+
asyncBuildWatch: startAsyncBuildResultWatcher({
|
|
35866
|
+
projectRoot: buildResult.projectRoot,
|
|
35867
|
+
projectId: buildResult.projectId,
|
|
35868
|
+
projectPath: buildResult.projectPath,
|
|
35869
|
+
serverUrl: buildResult.serverUrl,
|
|
35870
|
+
env: buildResult.env,
|
|
35871
|
+
taskId: buildResult.taskId,
|
|
35872
|
+
reused: buildResult.reused,
|
|
35873
|
+
sourceBuildResult: buildResult,
|
|
35874
|
+
queryBuildResult: () => queryBuildResult(buildResult.taskId),
|
|
35875
|
+
refreshPreview: options.refreshPreview || refreshMakerPreview,
|
|
35876
|
+
startRuntimeLogWatch: options.startRuntimeLogWatch || startRuntimeLogWatch,
|
|
35877
|
+
pollIntervalMs: options.asyncBuildPollIntervalMs,
|
|
35878
|
+
onProgress: options.onProgress,
|
|
35879
|
+
onStop: () => remoteQueryRunner == null ? void 0 : remoteQueryRunner.close()
|
|
35880
|
+
})
|
|
35881
|
+
};
|
|
35882
|
+
}
|
|
35883
|
+
async function attachAndWaitAsyncBuildResult(buildResult, options) {
|
|
35884
|
+
var _a3, _b;
|
|
35885
|
+
const watched = attachAsyncBuildWatcher(buildResult, options);
|
|
35886
|
+
const activeFile = (_a3 = watched.asyncBuildWatch) == null ? void 0 : _a3.activeFile;
|
|
35887
|
+
const completion = activeFile ? (_b = activeAsyncBuildWatchers.get(activeFile)) == null ? void 0 : _b.completion : void 0;
|
|
35888
|
+
if (!completion) {
|
|
35889
|
+
throw new Error("Async build watcher did not start");
|
|
35890
|
+
}
|
|
35891
|
+
const finalState = await completion;
|
|
35892
|
+
const finalResult = asyncWatcherStateToRemoteBuildResult(finalState, buildResult);
|
|
35893
|
+
if (finalState.status === "succeeded") {
|
|
35894
|
+
return finalResult;
|
|
35895
|
+
}
|
|
35896
|
+
if (finalState.status === "failed") {
|
|
35897
|
+
throw new RemoteBuildFailedError(finalResult);
|
|
35898
|
+
}
|
|
35899
|
+
throw new RemoteBuildFailedError({
|
|
35900
|
+
...finalResult,
|
|
35901
|
+
resultText: finalResult.resultText || `Async Maker build did not finish successfully: ${finalState.status}${finalState.error ? `: ${formatAsyncBuildDiagnostic(finalState.error)}` : ""}`
|
|
35902
|
+
});
|
|
35903
|
+
}
|
|
35904
|
+
function formatAsyncBuildDiagnostic(value) {
|
|
35905
|
+
if (typeof value === "string") {
|
|
35906
|
+
return value;
|
|
35907
|
+
}
|
|
35908
|
+
try {
|
|
35909
|
+
return JSON.stringify(value);
|
|
35910
|
+
} catch {
|
|
35911
|
+
return String(value);
|
|
35912
|
+
}
|
|
35913
|
+
}
|
|
35914
|
+
function createRemoteAsyncBuildQueryRunner(buildResult, options = {}) {
|
|
35915
|
+
var _a3, _b;
|
|
35916
|
+
const proxy = createRemoteProxyContext({
|
|
35917
|
+
targetDir: buildResult.projectRoot,
|
|
35918
|
+
serverUrl: buildResult.serverUrl,
|
|
35919
|
+
env: buildResult.env === "rnd" || buildResult.env === "production" ? buildResult.env : void 0
|
|
35920
|
+
});
|
|
35921
|
+
const queryToolName = ((_a3 = process.env.TAPTAP_MAKER_REMOTE_ASYNC_BUILD_QUERY_TOOL) == null ? void 0 : _a3.trim()) || DEFAULT_REMOTE_ASYNC_BUILD_QUERY_TOOL;
|
|
35922
|
+
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;
|
|
35923
|
+
let client;
|
|
35924
|
+
const createTransport = options.createTransport || (() => trackMakerChildTransport(
|
|
35925
|
+
new HiddenStdioClientTransport({
|
|
35926
|
+
command: proxy.command,
|
|
35927
|
+
args: proxy.args,
|
|
35928
|
+
env: mergeStringEnv(process.env, proxy.envVars),
|
|
35929
|
+
stderr: "pipe"
|
|
35930
|
+
})
|
|
35931
|
+
));
|
|
35932
|
+
const createClient = options.createClient || (() => new Client(
|
|
35707
35933
|
{
|
|
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)
|
|
35934
|
+
name: "taptap-maker-async-build-query-forwarder",
|
|
35935
|
+
version: VERSION
|
|
35718
35936
|
},
|
|
35719
35937
|
{
|
|
35720
|
-
|
|
35721
|
-
startRuntimeLogWatch: options.startRuntimeLogWatch || startRuntimeLogWatch
|
|
35938
|
+
capabilities: {}
|
|
35722
35939
|
}
|
|
35723
|
-
);
|
|
35940
|
+
));
|
|
35941
|
+
const ensureClient = async () => {
|
|
35942
|
+
if (client) {
|
|
35943
|
+
return client;
|
|
35944
|
+
}
|
|
35945
|
+
const nextClient = createClient();
|
|
35946
|
+
await nextClient.connect(createTransport());
|
|
35947
|
+
client = nextClient;
|
|
35948
|
+
return nextClient;
|
|
35949
|
+
};
|
|
35950
|
+
const close = async () => {
|
|
35951
|
+
const activeClient = client;
|
|
35952
|
+
client = void 0;
|
|
35953
|
+
if (activeClient) {
|
|
35954
|
+
await activeClient.close();
|
|
35955
|
+
}
|
|
35956
|
+
};
|
|
35957
|
+
return {
|
|
35958
|
+
query: async (taskId) => {
|
|
35959
|
+
const activeClient = await ensureClient();
|
|
35960
|
+
let result;
|
|
35961
|
+
try {
|
|
35962
|
+
result = await activeClient.callTool(
|
|
35963
|
+
{
|
|
35964
|
+
name: queryToolName,
|
|
35965
|
+
arguments: { [taskIdParam]: taskId }
|
|
35966
|
+
},
|
|
35967
|
+
void 0,
|
|
35968
|
+
{
|
|
35969
|
+
timeout: DEFAULT_BUILD_TIMEOUT_MS
|
|
35970
|
+
}
|
|
35971
|
+
);
|
|
35972
|
+
} catch (error2) {
|
|
35973
|
+
await close().catch(() => {
|
|
35974
|
+
});
|
|
35975
|
+
throw error2;
|
|
35976
|
+
}
|
|
35977
|
+
return normalizeAsyncBuildQueryResult(result);
|
|
35978
|
+
},
|
|
35979
|
+
close: async () => {
|
|
35980
|
+
await close().catch(() => {
|
|
35981
|
+
});
|
|
35982
|
+
}
|
|
35983
|
+
};
|
|
35984
|
+
}
|
|
35985
|
+
function normalizeAsyncBuildQueryResult(result) {
|
|
35986
|
+
const resultText = formatRemoteToolResult(result);
|
|
35987
|
+
const parsed = parseJsonObjectFromText(resultText);
|
|
35988
|
+
const status = normalizeAsyncBuildStatus((parsed == null ? void 0 : parsed.status) || (parsed == null ? void 0 : parsed.state) || (parsed == null ? void 0 : parsed.phase));
|
|
35989
|
+
if (status) {
|
|
35990
|
+
return {
|
|
35991
|
+
status,
|
|
35992
|
+
resultText,
|
|
35993
|
+
result: parsed,
|
|
35994
|
+
error: parsed == null ? void 0 : parsed.error
|
|
35995
|
+
};
|
|
35996
|
+
}
|
|
35997
|
+
return {
|
|
35998
|
+
status: isRemoteToolError(result) ? "failed" : "running",
|
|
35999
|
+
resultText,
|
|
36000
|
+
result: parsed || result,
|
|
36001
|
+
...isRemoteToolError(result) ? { error: resultText } : {}
|
|
36002
|
+
};
|
|
36003
|
+
}
|
|
36004
|
+
function normalizeAsyncBuildStatus(status) {
|
|
36005
|
+
if (typeof status !== "string") {
|
|
36006
|
+
return void 0;
|
|
36007
|
+
}
|
|
36008
|
+
const normalized = status.trim().toLowerCase();
|
|
36009
|
+
if (["queued", "pending", "created"].includes(normalized)) {
|
|
36010
|
+
return "queued";
|
|
36011
|
+
}
|
|
36012
|
+
if (["running", "building", "in_progress", "processing"].includes(normalized)) {
|
|
36013
|
+
return "running";
|
|
36014
|
+
}
|
|
36015
|
+
if (["succeeded", "success", "done", "completed", "finished"].includes(normalized)) {
|
|
36016
|
+
return "succeeded";
|
|
36017
|
+
}
|
|
36018
|
+
if (["failed", "failure", "error", "cancelled", "canceled"].includes(normalized)) {
|
|
36019
|
+
return "failed";
|
|
36020
|
+
}
|
|
36021
|
+
return void 0;
|
|
35724
36022
|
}
|
|
35725
36023
|
async function attachBuildSuccessSideEffects(buildResult, options) {
|
|
35726
36024
|
if (isRemoteBuildFailureResult(buildResult)) {
|
|
@@ -35861,6 +36159,315 @@ async function startRuntimeLogWatch(buildResult) {
|
|
|
35861
36159
|
fs14.closeSync(errFd);
|
|
35862
36160
|
}
|
|
35863
36161
|
}
|
|
36162
|
+
function startAsyncBuildResultWatcher(options) {
|
|
36163
|
+
const pollIntervalMs = options.pollIntervalMs || ASYNC_BUILD_POLL_INTERVAL_MS;
|
|
36164
|
+
const timeoutMs = options.timeoutMs || ASYNC_BUILD_TIMEOUT_MS;
|
|
36165
|
+
const paths = getAsyncBuildWatcherPaths(options.projectRoot, options.taskId);
|
|
36166
|
+
const previous = stopExistingAsyncBuildResultWatcher(
|
|
36167
|
+
options.projectRoot,
|
|
36168
|
+
"cancelled_by_new_build"
|
|
36169
|
+
);
|
|
36170
|
+
const now = /* @__PURE__ */ new Date();
|
|
36171
|
+
const state = {
|
|
36172
|
+
mode: "remote_build_async",
|
|
36173
|
+
taskId: options.taskId,
|
|
36174
|
+
reused: options.reused,
|
|
36175
|
+
projectId: options.projectId,
|
|
36176
|
+
projectPath: options.projectPath,
|
|
36177
|
+
projectRoot: options.projectRoot,
|
|
36178
|
+
serverUrl: options.serverUrl,
|
|
36179
|
+
env: options.env,
|
|
36180
|
+
status: "queued",
|
|
36181
|
+
startedAt: now.toISOString(),
|
|
36182
|
+
updatedAt: now.toISOString(),
|
|
36183
|
+
deadlineAt: new Date(now.getTime() + timeoutMs).toISOString(),
|
|
36184
|
+
pollIntervalMs
|
|
36185
|
+
};
|
|
36186
|
+
let completeWatcher = () => {
|
|
36187
|
+
};
|
|
36188
|
+
const completion = new Promise((resolve) => {
|
|
36189
|
+
completeWatcher = resolve;
|
|
36190
|
+
});
|
|
36191
|
+
const watcher = {
|
|
36192
|
+
state,
|
|
36193
|
+
sourceBuildResult: options.sourceBuildResult,
|
|
36194
|
+
activeFile: paths.activeFile,
|
|
36195
|
+
stateFile: paths.stateFile,
|
|
36196
|
+
onStop: options.onStop,
|
|
36197
|
+
completion,
|
|
36198
|
+
complete: completeWatcher
|
|
36199
|
+
};
|
|
36200
|
+
fs14.mkdirSync(path15.dirname(paths.activeFile), { recursive: true });
|
|
36201
|
+
writeJsonFile2(paths.stateFile, state);
|
|
36202
|
+
writeJsonFile2(paths.activeFile, {
|
|
36203
|
+
taskId: options.taskId,
|
|
36204
|
+
reused: options.reused,
|
|
36205
|
+
projectId: options.projectId,
|
|
36206
|
+
pid: process.pid,
|
|
36207
|
+
startedAt: state.startedAt,
|
|
36208
|
+
deadlineAt: state.deadlineAt,
|
|
36209
|
+
stateFile: paths.stateFile
|
|
36210
|
+
});
|
|
36211
|
+
activeAsyncBuildWatchers.set(paths.activeFile, watcher);
|
|
36212
|
+
const poll = async () => {
|
|
36213
|
+
var _a3, _b, _c;
|
|
36214
|
+
if (!activeAsyncBuildWatchers.has(paths.activeFile)) {
|
|
36215
|
+
return;
|
|
36216
|
+
}
|
|
36217
|
+
try {
|
|
36218
|
+
const result = await options.queryBuildResult();
|
|
36219
|
+
updateAsyncBuildWatcherState(watcher, {
|
|
36220
|
+
status: result.status,
|
|
36221
|
+
resultText: result.resultText,
|
|
36222
|
+
result: result.result,
|
|
36223
|
+
error: result.error,
|
|
36224
|
+
lastPollError: void 0
|
|
36225
|
+
});
|
|
36226
|
+
emitAsyncBuildPollProgress(watcher, result, options.onProgress);
|
|
36227
|
+
if (result.status === "succeeded" || result.status === "failed") {
|
|
36228
|
+
if (result.status === "succeeded") {
|
|
36229
|
+
await finishAsyncBuildSuccessSideEffects(watcher, options);
|
|
36230
|
+
}
|
|
36231
|
+
stopAsyncBuildWatcherRuntime(watcher);
|
|
36232
|
+
(_a3 = watcher.complete) == null ? void 0 : _a3.call(watcher, watcher.state);
|
|
36233
|
+
return;
|
|
36234
|
+
}
|
|
36235
|
+
} catch (error2) {
|
|
36236
|
+
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
36237
|
+
if (isAsyncBuildExpiredErrorMessage(message)) {
|
|
36238
|
+
updateAsyncBuildWatcherState(watcher, {
|
|
36239
|
+
status: "expired",
|
|
36240
|
+
error: message,
|
|
36241
|
+
lastPollError: message
|
|
36242
|
+
});
|
|
36243
|
+
stopAsyncBuildWatcherRuntime(watcher);
|
|
36244
|
+
(_b = watcher.complete) == null ? void 0 : _b.call(watcher, watcher.state);
|
|
36245
|
+
return;
|
|
36246
|
+
}
|
|
36247
|
+
const nextStatus = "running";
|
|
36248
|
+
updateAsyncBuildWatcherState(watcher, {
|
|
36249
|
+
status: nextStatus,
|
|
36250
|
+
lastPollError: message
|
|
36251
|
+
});
|
|
36252
|
+
emitAsyncBuildPollProgress(
|
|
36253
|
+
watcher,
|
|
36254
|
+
{ status: nextStatus, error: message },
|
|
36255
|
+
options.onProgress
|
|
36256
|
+
);
|
|
36257
|
+
}
|
|
36258
|
+
if (Date.now() >= Date.parse(watcher.state.deadlineAt)) {
|
|
36259
|
+
updateAsyncBuildWatcherState(watcher, { status: "timeout" });
|
|
36260
|
+
stopAsyncBuildWatcherRuntime(watcher);
|
|
36261
|
+
(_c = watcher.complete) == null ? void 0 : _c.call(watcher, watcher.state);
|
|
36262
|
+
return;
|
|
36263
|
+
}
|
|
36264
|
+
watcher.timer = setTimeout(() => {
|
|
36265
|
+
void poll();
|
|
36266
|
+
}, pollIntervalMs);
|
|
36267
|
+
};
|
|
36268
|
+
watcher.timer = setTimeout(() => {
|
|
36269
|
+
void poll();
|
|
36270
|
+
}, pollIntervalMs);
|
|
36271
|
+
return {
|
|
36272
|
+
started: true,
|
|
36273
|
+
taskId: options.taskId,
|
|
36274
|
+
reused: options.reused,
|
|
36275
|
+
activeFile: paths.activeFile,
|
|
36276
|
+
stateFile: paths.stateFile,
|
|
36277
|
+
pollIntervalMs,
|
|
36278
|
+
timeoutMs,
|
|
36279
|
+
previousTaskId: previous.previousTaskId,
|
|
36280
|
+
previousStopped: previous.previousStopped
|
|
36281
|
+
};
|
|
36282
|
+
}
|
|
36283
|
+
function stopAsyncBuildWatcherRuntime(watcher) {
|
|
36284
|
+
var _a3;
|
|
36285
|
+
if (watcher.stopped) {
|
|
36286
|
+
return;
|
|
36287
|
+
}
|
|
36288
|
+
watcher.stopped = true;
|
|
36289
|
+
if (watcher.timer) {
|
|
36290
|
+
clearTimeout(watcher.timer);
|
|
36291
|
+
watcher.timer = void 0;
|
|
36292
|
+
}
|
|
36293
|
+
activeAsyncBuildWatchers.delete(watcher.activeFile);
|
|
36294
|
+
fs14.rmSync(watcher.activeFile, { force: true });
|
|
36295
|
+
void Promise.resolve((_a3 = watcher.onStop) == null ? void 0 : _a3.call(watcher)).catch((error2) => {
|
|
36296
|
+
updateAsyncBuildWatcherState(watcher, {
|
|
36297
|
+
sideEffectError: `async query runner close failed: ${error2 instanceof Error ? error2.message : String(error2)}`
|
|
36298
|
+
});
|
|
36299
|
+
});
|
|
36300
|
+
}
|
|
36301
|
+
function isAsyncBuildExpiredErrorMessage(message) {
|
|
36302
|
+
const normalized = message.trim().toLowerCase();
|
|
36303
|
+
return [
|
|
36304
|
+
"not found",
|
|
36305
|
+
"not_found",
|
|
36306
|
+
"not exist",
|
|
36307
|
+
"unknown build",
|
|
36308
|
+
"unknown build_id",
|
|
36309
|
+
"expired",
|
|
36310
|
+
"restart",
|
|
36311
|
+
"restarted",
|
|
36312
|
+
"未找到",
|
|
36313
|
+
"不存在",
|
|
36314
|
+
"过期",
|
|
36315
|
+
"服务重启"
|
|
36316
|
+
].some((pattern) => normalized.includes(pattern));
|
|
36317
|
+
}
|
|
36318
|
+
function emitAsyncBuildPollProgress(watcher, result, onProgress) {
|
|
36319
|
+
if (!onProgress) {
|
|
36320
|
+
return;
|
|
36321
|
+
}
|
|
36322
|
+
const payload = result.result && typeof result.result === "object" && !Array.isArray(result.result) ? result.result : {};
|
|
36323
|
+
const remoteProgress = typeof payload.progress === "number" ? payload.progress : void 0;
|
|
36324
|
+
const remotePhase = typeof payload.phase === "string" && payload.phase.trim() ? payload.phase.trim() : void 0;
|
|
36325
|
+
const elapsedSeconds = typeof payload.elapsed_seconds === "number" ? payload.elapsed_seconds : void 0;
|
|
36326
|
+
onProgress({
|
|
36327
|
+
progress: remoteProgress,
|
|
36328
|
+
total: remoteProgress === void 0 ? void 0 : 100,
|
|
36329
|
+
phase: "async_build_poll",
|
|
36330
|
+
message: [
|
|
36331
|
+
`build_id=${watcher.state.taskId}`,
|
|
36332
|
+
`status=${result.status}`,
|
|
36333
|
+
remotePhase ? `phase=${remotePhase}` : "",
|
|
36334
|
+
elapsedSeconds !== void 0 ? `elapsed=${elapsedSeconds}s` : "",
|
|
36335
|
+
result.error ? `error=${formatAsyncBuildDiagnostic(result.error)}` : ""
|
|
36336
|
+
].filter(Boolean).join(" ")
|
|
36337
|
+
});
|
|
36338
|
+
}
|
|
36339
|
+
function stopExistingAsyncBuildResultWatcher(projectRoot, reason = "cancelled") {
|
|
36340
|
+
var _a3;
|
|
36341
|
+
const activeFile = getAsyncBuildActiveFilePath(projectRoot);
|
|
36342
|
+
const active = readJsonFile2(activeFile);
|
|
36343
|
+
const watcher = activeAsyncBuildWatchers.get(activeFile);
|
|
36344
|
+
if (!active && !watcher) {
|
|
36345
|
+
return {};
|
|
36346
|
+
}
|
|
36347
|
+
const stateFile = (active == null ? void 0 : active.stateFile) || (watcher == null ? void 0 : watcher.stateFile);
|
|
36348
|
+
const taskId = (active == null ? void 0 : active.taskId) || (watcher == null ? void 0 : watcher.state.taskId);
|
|
36349
|
+
if (stateFile && fs14.existsSync(stateFile)) {
|
|
36350
|
+
const existing = readJsonFile2(stateFile) || {};
|
|
36351
|
+
writeJsonFile2(stateFile, {
|
|
36352
|
+
...existing,
|
|
36353
|
+
status: reason,
|
|
36354
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
36355
|
+
});
|
|
36356
|
+
}
|
|
36357
|
+
if (watcher) {
|
|
36358
|
+
updateAsyncBuildWatcherState(watcher, {
|
|
36359
|
+
status: reason,
|
|
36360
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
36361
|
+
});
|
|
36362
|
+
stopAsyncBuildWatcherRuntime(watcher);
|
|
36363
|
+
(_a3 = watcher.complete) == null ? void 0 : _a3.call(watcher, watcher.state);
|
|
36364
|
+
} else {
|
|
36365
|
+
fs14.rmSync(activeFile, { force: true });
|
|
36366
|
+
}
|
|
36367
|
+
return {
|
|
36368
|
+
previousTaskId: taskId,
|
|
36369
|
+
previousStopped: Boolean(taskId)
|
|
36370
|
+
};
|
|
36371
|
+
}
|
|
36372
|
+
async function finishAsyncBuildSuccessSideEffects(watcher, options) {
|
|
36373
|
+
const buildResult = asyncWatcherStateToRemoteBuildResult(
|
|
36374
|
+
watcher.state,
|
|
36375
|
+
watcher.sourceBuildResult
|
|
36376
|
+
);
|
|
36377
|
+
if (options.refreshPreview) {
|
|
36378
|
+
try {
|
|
36379
|
+
updateAsyncBuildWatcherState(watcher, {
|
|
36380
|
+
previewRefresh: await options.refreshPreview(buildResult)
|
|
36381
|
+
});
|
|
36382
|
+
} catch (error2) {
|
|
36383
|
+
updateAsyncBuildWatcherState(watcher, {
|
|
36384
|
+
previewRefresh: {
|
|
36385
|
+
ok: false,
|
|
36386
|
+
status: 0,
|
|
36387
|
+
url: "",
|
|
36388
|
+
error: error2 instanceof Error ? error2.message : String(error2)
|
|
36389
|
+
}
|
|
36390
|
+
});
|
|
36391
|
+
}
|
|
36392
|
+
}
|
|
36393
|
+
if (options.startRuntimeLogWatch) {
|
|
36394
|
+
try {
|
|
36395
|
+
updateAsyncBuildWatcherState(watcher, {
|
|
36396
|
+
runtimeLogWatch: await options.startRuntimeLogWatch(buildResult)
|
|
36397
|
+
});
|
|
36398
|
+
} catch (error2) {
|
|
36399
|
+
updateAsyncBuildWatcherState(watcher, {
|
|
36400
|
+
runtimeLogWatch: {
|
|
36401
|
+
started: false,
|
|
36402
|
+
command: "",
|
|
36403
|
+
runtimeLog: "",
|
|
36404
|
+
error: error2 instanceof Error ? error2.message : String(error2)
|
|
36405
|
+
}
|
|
36406
|
+
});
|
|
36407
|
+
}
|
|
36408
|
+
}
|
|
36409
|
+
}
|
|
36410
|
+
function asyncWatcherStateToRemoteBuildResult(state, originalBuildResult) {
|
|
36411
|
+
return {
|
|
36412
|
+
mode: "remote_build",
|
|
36413
|
+
projectRoot: state.projectRoot,
|
|
36414
|
+
projectId: state.projectId,
|
|
36415
|
+
projectPath: state.projectPath,
|
|
36416
|
+
serverUrl: state.serverUrl,
|
|
36417
|
+
env: state.env,
|
|
36418
|
+
makerUrl: formatMakerAppWebUrl(state.projectId, state.env),
|
|
36419
|
+
timeoutMs: (originalBuildResult == null ? void 0 : originalBuildResult.timeoutMs) || DEFAULT_BUILD_TIMEOUT_MS,
|
|
36420
|
+
buildArgs: (originalBuildResult == null ? void 0 : originalBuildResult.buildArgs) || {},
|
|
36421
|
+
resultText: state.resultText || "",
|
|
36422
|
+
previewRefresh: state.previewRefresh,
|
|
36423
|
+
runtimeLogWatch: state.runtimeLogWatch
|
|
36424
|
+
};
|
|
36425
|
+
}
|
|
36426
|
+
function updateAsyncBuildWatcherState(watcher, patch) {
|
|
36427
|
+
watcher.state = {
|
|
36428
|
+
...watcher.state,
|
|
36429
|
+
...patch,
|
|
36430
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
36431
|
+
};
|
|
36432
|
+
writeJsonFile2(watcher.stateFile, watcher.state);
|
|
36433
|
+
}
|
|
36434
|
+
function getAsyncBuildWatcherPaths(projectRoot, taskId) {
|
|
36435
|
+
const normalizedProjectRoot = normalizeExistingProjectPath(projectRoot);
|
|
36436
|
+
const buildDir = path15.join(normalizedProjectRoot, ".maker", "builds");
|
|
36437
|
+
return {
|
|
36438
|
+
activeFile: getAsyncBuildActiveFilePath(projectRoot),
|
|
36439
|
+
stateFile: path15.join(buildDir, `${sanitizeAsyncBuildTaskId(taskId)}.json`)
|
|
36440
|
+
};
|
|
36441
|
+
}
|
|
36442
|
+
function getAsyncBuildActiveFilePath(projectRoot) {
|
|
36443
|
+
const normalizedProjectRoot = normalizeExistingProjectPath(projectRoot);
|
|
36444
|
+
return path15.join(normalizedProjectRoot, ".maker", "builds", "active-build.json");
|
|
36445
|
+
}
|
|
36446
|
+
function normalizeExistingProjectPath(projectRoot) {
|
|
36447
|
+
try {
|
|
36448
|
+
return fs14.realpathSync(projectRoot);
|
|
36449
|
+
} catch {
|
|
36450
|
+
return path15.resolve(projectRoot);
|
|
36451
|
+
}
|
|
36452
|
+
}
|
|
36453
|
+
function sanitizeAsyncBuildTaskId(taskId) {
|
|
36454
|
+
return taskId.replace(/[^A-Za-z0-9_.-]/g, "_") || "unknown-task";
|
|
36455
|
+
}
|
|
36456
|
+
function writeJsonFile2(filePath, value) {
|
|
36457
|
+
fs14.mkdirSync(path15.dirname(filePath), { recursive: true });
|
|
36458
|
+
fs14.writeFileSync(filePath, `${JSON.stringify(value, null, 2)}
|
|
36459
|
+
`, "utf8");
|
|
36460
|
+
}
|
|
36461
|
+
function readJsonFile2(filePath) {
|
|
36462
|
+
if (!fs14.existsSync(filePath)) {
|
|
36463
|
+
return void 0;
|
|
36464
|
+
}
|
|
36465
|
+
try {
|
|
36466
|
+
return JSON.parse(fs14.readFileSync(filePath, "utf8"));
|
|
36467
|
+
} catch {
|
|
36468
|
+
return void 0;
|
|
36469
|
+
}
|
|
36470
|
+
}
|
|
35864
36471
|
function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
|
|
35865
36472
|
if (!fs14.existsSync(pidFile)) {
|
|
35866
36473
|
return {};
|
|
@@ -36135,7 +36742,8 @@ function toMakerBuildFailure(error2) {
|
|
|
36135
36742
|
return {
|
|
36136
36743
|
name: error2 instanceof Error ? error2.name : typeof error2,
|
|
36137
36744
|
message: error2 instanceof Error ? error2.message : String(error2),
|
|
36138
|
-
...error2 instanceof Error && error2.stack ? { stack: error2.stack } : {}
|
|
36745
|
+
...error2 instanceof Error && error2.stack ? { stack: error2.stack } : {},
|
|
36746
|
+
...error2 instanceof Error ? errorOwnDiagnosticFields(error2) : {}
|
|
36139
36747
|
};
|
|
36140
36748
|
}
|
|
36141
36749
|
function createBuildArgs(projectRoot, options) {
|
|
@@ -36161,8 +36769,41 @@ function createBuildArgs(projectRoot, options) {
|
|
|
36161
36769
|
} else if (!fs14.existsSync(path15.join(projectRoot, ".project", "settings.json"))) {
|
|
36162
36770
|
buildArgs.multiplayer = { enabled: false };
|
|
36163
36771
|
}
|
|
36772
|
+
if (shouldForwardAsyncBuild(options.asyncBuild, options.clientIde)) {
|
|
36773
|
+
buildArgs[getRemoteAsyncBuildParamName()] = getRemoteAsyncBuildParamValue();
|
|
36774
|
+
}
|
|
36164
36775
|
return buildArgs;
|
|
36165
36776
|
}
|
|
36777
|
+
function shouldForwardAsyncBuild(asyncBuild, clientIde) {
|
|
36778
|
+
if (asyncBuild === true) {
|
|
36779
|
+
return true;
|
|
36780
|
+
}
|
|
36781
|
+
if (asyncBuild === false) {
|
|
36782
|
+
return false;
|
|
36783
|
+
}
|
|
36784
|
+
return normalizeClientIde(clientIde || process.env.TAPTAP_MCP_CLIENT_IDE) === "workbuddy";
|
|
36785
|
+
}
|
|
36786
|
+
function normalizeClientIde(clientIde) {
|
|
36787
|
+
return (clientIde || "").trim().toLowerCase();
|
|
36788
|
+
}
|
|
36789
|
+
function getRemoteAsyncBuildParamName() {
|
|
36790
|
+
var _a3;
|
|
36791
|
+
const paramName = (_a3 = process.env.TAPTAP_MAKER_REMOTE_ASYNC_BUILD_PARAM) == null ? void 0 : _a3.trim();
|
|
36792
|
+
return paramName || DEFAULT_REMOTE_ASYNC_BUILD_PARAM;
|
|
36793
|
+
}
|
|
36794
|
+
function getRemoteAsyncBuildParamValue() {
|
|
36795
|
+
const rawValue = process.env.TAPTAP_MAKER_REMOTE_ASYNC_BUILD_VALUE_JSON;
|
|
36796
|
+
if (!rawValue) {
|
|
36797
|
+
return true;
|
|
36798
|
+
}
|
|
36799
|
+
try {
|
|
36800
|
+
return JSON.parse(rawValue);
|
|
36801
|
+
} catch (error2) {
|
|
36802
|
+
throw new Error(
|
|
36803
|
+
`Invalid TAPTAP_MAKER_REMOTE_ASYNC_BUILD_VALUE_JSON: ${error2 instanceof Error ? error2.message : String(error2)}`
|
|
36804
|
+
);
|
|
36805
|
+
}
|
|
36806
|
+
}
|
|
36166
36807
|
function mergeStringEnv(...sources) {
|
|
36167
36808
|
const result = {};
|
|
36168
36809
|
for (const source of sources) {
|
|
@@ -36193,13 +36834,13 @@ function formatRemoteToolResult(result) {
|
|
|
36193
36834
|
}).join("\n");
|
|
36194
36835
|
}
|
|
36195
36836
|
function formatBuildResult(result, progressSummary) {
|
|
36837
|
+
var _a3, _b;
|
|
36196
36838
|
if (result.mode === "remote_build_failed") {
|
|
36197
36839
|
return [
|
|
36198
36840
|
"✗ Remote Maker build failed",
|
|
36199
36841
|
"",
|
|
36200
36842
|
`- project_root: ${result.projectRoot}`,
|
|
36201
36843
|
`- project_id: ${result.projectId}`,
|
|
36202
|
-
...formatMakerPageOpenLines(result.makerPageOpen),
|
|
36203
36844
|
`- maker_url: ${result.buildResult.makerUrl || formatMakerAppWebUrl(result.buildResult.projectId, result.buildResult.env)}`,
|
|
36204
36845
|
`- project_path: ${result.buildResult.projectPath}`,
|
|
36205
36846
|
`- server_url: ${result.buildResult.serverUrl}`,
|
|
@@ -36256,6 +36897,35 @@ function formatBuildResult(result, progressSummary) {
|
|
|
36256
36897
|
...formatMakerBuildFailureLines(result.buildFailure)
|
|
36257
36898
|
].filter(Boolean).join("\n");
|
|
36258
36899
|
}
|
|
36900
|
+
if (result.mode === "remote_build_async_started") {
|
|
36901
|
+
return [
|
|
36902
|
+
result.submitResult ? "✓ Maker project submitted, then remote Maker async build started" : "✓ Remote Maker async build started",
|
|
36903
|
+
"",
|
|
36904
|
+
`- project_root: ${result.projectRoot}`,
|
|
36905
|
+
`- project_id: ${result.projectId}`,
|
|
36906
|
+
`- maker_url: ${result.makerUrl || formatMakerAppWebUrl(result.projectId, result.env)}`,
|
|
36907
|
+
`- project_path: ${result.projectPath}`,
|
|
36908
|
+
`- server_url: ${result.serverUrl}`,
|
|
36909
|
+
`- env: ${result.env}`,
|
|
36910
|
+
`- build_id: ${result.taskId}`,
|
|
36911
|
+
result.reused !== void 0 ? `- reused: ${result.reused ? "yes" : "no"}` : "",
|
|
36912
|
+
`- timeout_ms: ${result.timeoutMs}`,
|
|
36913
|
+
`- build_args: ${JSON.stringify(result.buildArgs)}`,
|
|
36914
|
+
result.asyncBuildWatch ? `- async_watch_started: ${result.asyncBuildWatch.started ? "yes" : "no"}` : "",
|
|
36915
|
+
result.asyncBuildWatch ? `- async_watch_state_file: ${result.asyncBuildWatch.stateFile}` : "",
|
|
36916
|
+
result.asyncBuildWatch ? `- async_watch_active_file: ${result.asyncBuildWatch.activeFile}` : "",
|
|
36917
|
+
result.asyncBuildWatch ? `- async_watch_poll_interval_ms: ${result.asyncBuildWatch.pollIntervalMs}` : "",
|
|
36918
|
+
result.asyncBuildWatch ? `- async_watch_timeout_ms: ${result.asyncBuildWatch.timeoutMs}` : "",
|
|
36919
|
+
((_a3 = result.asyncBuildWatch) == null ? void 0 : _a3.previousTaskId) ? `- previous_async_build_id: ${result.asyncBuildWatch.previousTaskId}` : "",
|
|
36920
|
+
((_b = result.asyncBuildWatch) == null ? void 0 : _b.previousStopped) !== void 0 ? `- previous_async_watch_stopped: ${result.asyncBuildWatch.previousStopped ? "yes" : "no"}` : "",
|
|
36921
|
+
...formatProgressSummary(progressSummary),
|
|
36922
|
+
"",
|
|
36923
|
+
"note: 远端异步构建已启动;本地每 5 秒查询一次结果,最多轮询 30 分钟。",
|
|
36924
|
+
"note: 如果同一 Maker 项目再次触发构建,上一轮异步轮询会被取消。",
|
|
36925
|
+
"remote_result:",
|
|
36926
|
+
indent2(result.resultText)
|
|
36927
|
+
].filter(Boolean).join("\n");
|
|
36928
|
+
}
|
|
36259
36929
|
const submitLines = result.submitResult ? [
|
|
36260
36930
|
"submit_result:",
|
|
36261
36931
|
` - branch: ${result.submitResult.branch}`,
|
|
@@ -36273,7 +36943,6 @@ function formatBuildResult(result, progressSummary) {
|
|
|
36273
36943
|
`- project_root: ${result.projectRoot}`,
|
|
36274
36944
|
`- project_id: ${result.projectId}`,
|
|
36275
36945
|
`- maker_url: ${result.makerUrl || formatMakerAppWebUrl(result.projectId, result.env)}`,
|
|
36276
|
-
...formatMakerPageOpenLines(result.makerPageOpen),
|
|
36277
36946
|
`- project_path: ${result.projectPath}`,
|
|
36278
36947
|
`- server_url: ${result.serverUrl}`,
|
|
36279
36948
|
`- env: ${result.env}`
|
|
@@ -36304,17 +36973,6 @@ function formatPreviewRefreshLines(result) {
|
|
|
36304
36973
|
result.error ? `- preview_refresh_error: ${result.error}` : ""
|
|
36305
36974
|
].filter(Boolean);
|
|
36306
36975
|
}
|
|
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
36976
|
function formatRuntimeLogWatchNextActionLines(result) {
|
|
36319
36977
|
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
36320
36978
|
const command = formatLocalShellCommand([
|
|
@@ -36376,14 +37034,27 @@ function pushRecoveryUserMessage(failure) {
|
|
|
36376
37034
|
}
|
|
36377
37035
|
}
|
|
36378
37036
|
function formatMakerBuildFailureLines(failure) {
|
|
37037
|
+
const details = buildFailureDiagnosticFields(failure);
|
|
36379
37038
|
return [
|
|
36380
37039
|
"build_failure:",
|
|
36381
37040
|
`- error_name: ${failure.name}`,
|
|
36382
37041
|
`- message: ${failure.message}`,
|
|
37042
|
+
Object.keys(details).length > 0 ? `- error_details:
|
|
37043
|
+
${indent2(formatDiagnosticJson(details))}` : "",
|
|
36383
37044
|
failure.stack ? `- stack:
|
|
36384
37045
|
${indent2(failure.stack)}` : ""
|
|
36385
37046
|
].filter(Boolean);
|
|
36386
37047
|
}
|
|
37048
|
+
function buildFailureDiagnosticFields(failure) {
|
|
37049
|
+
const details = {};
|
|
37050
|
+
for (const [key, value] of Object.entries(failure)) {
|
|
37051
|
+
if (key === "name" || key === "message" || key === "stack") {
|
|
37052
|
+
continue;
|
|
37053
|
+
}
|
|
37054
|
+
details[key] = sanitizeDiagnosticValue(value);
|
|
37055
|
+
}
|
|
37056
|
+
return details;
|
|
37057
|
+
}
|
|
36387
37058
|
function formatMakerFailureLines(failure) {
|
|
36388
37059
|
return [
|
|
36389
37060
|
"failure:",
|
|
@@ -36513,7 +37184,7 @@ function indent2(value) {
|
|
|
36513
37184
|
}
|
|
36514
37185
|
|
|
36515
37186
|
// src/maker/cli/commands.ts
|
|
36516
|
-
import { spawnSync as
|
|
37187
|
+
import { spawnSync as spawnSync7 } from "node:child_process";
|
|
36517
37188
|
import crypto3 from "node:crypto";
|
|
36518
37189
|
import fs15 from "node:fs";
|
|
36519
37190
|
import os4 from "node:os";
|
|
@@ -36522,7 +37193,7 @@ import readline from "node:readline/promises";
|
|
|
36522
37193
|
import { stdin as input, stdout as output } from "node:process";
|
|
36523
37194
|
|
|
36524
37195
|
// src/maker/auth/cliLogin.ts
|
|
36525
|
-
import { spawnSync as
|
|
37196
|
+
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
36526
37197
|
import crypto2 from "node:crypto";
|
|
36527
37198
|
var DEFAULT_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
36528
37199
|
var DEFAULT_POLL_INTERVAL_MS = 1e3;
|
|
@@ -36641,7 +37312,7 @@ async function readJsonResponse(response) {
|
|
|
36641
37312
|
function openBrowser(url2) {
|
|
36642
37313
|
const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
|
|
36643
37314
|
const args = process.platform === "win32" ? ["/c", "start", "", url2] : [url2];
|
|
36644
|
-
const result =
|
|
37315
|
+
const result = spawnSync6(command, args, {
|
|
36645
37316
|
stdio: "ignore",
|
|
36646
37317
|
windowsHide: true
|
|
36647
37318
|
});
|
|
@@ -36663,7 +37334,7 @@ function formatError2(error2) {
|
|
|
36663
37334
|
}
|
|
36664
37335
|
|
|
36665
37336
|
// src/maker/cli/commands.ts
|
|
36666
|
-
var VERSION2 = true ? "0.0.
|
|
37337
|
+
var VERSION2 = true ? "0.0.22" : "dev";
|
|
36667
37338
|
var DEFAULT_MCP_NAME = "taptap-maker";
|
|
36668
37339
|
var MAKER_NPM_PACKAGE = "@taptap/maker";
|
|
36669
37340
|
var TWO_PART_COMMANDS = /* @__PURE__ */ new Set(["pat", "mcp", "dev-kit", "logs", "python", "lua-lsp", "agents"]);
|
|
@@ -37031,7 +37702,7 @@ function inspectMakerOrphanProcesses() {
|
|
|
37031
37702
|
if (process.platform === "win32") {
|
|
37032
37703
|
return { status: "not_supported_on_windows", processes: [] };
|
|
37033
37704
|
}
|
|
37034
|
-
const result =
|
|
37705
|
+
const result = spawnSync7("ps", ["-axo", "pid,ppid,pcpu,etime,command"], {
|
|
37035
37706
|
encoding: "utf8"
|
|
37036
37707
|
});
|
|
37037
37708
|
if (result.status !== 0 || typeof result.stdout !== "string") {
|
|
@@ -37384,7 +38055,7 @@ async function runMcpVerify(parsed, ctx) {
|
|
|
37384
38055
|
rejectPackageOption(parsed);
|
|
37385
38056
|
const mode = mcpVerifyModeOption(parsed);
|
|
37386
38057
|
const command = mode === "npx" ? getNpxCliCommand(MAKER_NPM_PACKAGE) : getCurrentCliCommand();
|
|
37387
|
-
const result =
|
|
38058
|
+
const result = spawnSync7(command.command, [...command.args, "help"], {
|
|
37388
38059
|
encoding: "utf8"
|
|
37389
38060
|
});
|
|
37390
38061
|
const failureType = classifyMcpVerifyFailure(result);
|
|
@@ -37905,17 +38576,18 @@ function installMcpConfig(ide, options) {
|
|
|
37905
38576
|
function installMcpConfigUnsafe(ide, options) {
|
|
37906
38577
|
if (ide === "codex") {
|
|
37907
38578
|
const configPath = path16.join(os4.homedir(), ".codex", "config.toml");
|
|
37908
|
-
const write = mergeCodexMcpConfig(configPath, options);
|
|
38579
|
+
const write = mergeCodexMcpConfig(configPath, withClientIde(options, "codex"));
|
|
37909
38580
|
return [createMcpInstallResult(ide, "Codex", configPath, write)];
|
|
37910
38581
|
}
|
|
37911
38582
|
if (ide === "cursor") {
|
|
37912
38583
|
const configPath = path16.join(os4.homedir(), ".cursor", "mcp.json");
|
|
37913
|
-
const write = mergeJsonMcpConfig(configPath, options);
|
|
38584
|
+
const write = mergeJsonMcpConfig(configPath, withClientIde(options, "cursor"));
|
|
37914
38585
|
return [createMcpInstallResult(ide, "Cursor", configPath, write)];
|
|
37915
38586
|
}
|
|
37916
38587
|
if (ide === "claude") {
|
|
38588
|
+
const claudeOptions = withClientIde(options, "claude");
|
|
37917
38589
|
if (!options.cwd) {
|
|
37918
|
-
const claudeResult = tryClaudeMcpAdd(
|
|
38590
|
+
const claudeResult = tryClaudeMcpAdd(claudeOptions);
|
|
37919
38591
|
if (claudeResult.ok) {
|
|
37920
38592
|
return [
|
|
37921
38593
|
{
|
|
@@ -37927,18 +38599,23 @@ function installMcpConfigUnsafe(ide, options) {
|
|
|
37927
38599
|
}
|
|
37928
38600
|
}
|
|
37929
38601
|
const configPath = path16.join(os4.homedir(), ".claude.json");
|
|
37930
|
-
const write = mergeJsonMcpConfig(configPath,
|
|
38602
|
+
const write = mergeJsonMcpConfig(configPath, claudeOptions);
|
|
37931
38603
|
return [createMcpInstallResult(ide, "Claude fallback", configPath, write)];
|
|
37932
38604
|
}
|
|
37933
38605
|
if (ide === "trae") {
|
|
37934
|
-
return installJsonMcpConfigTargets(
|
|
38606
|
+
return installJsonMcpConfigTargets(
|
|
38607
|
+
ide,
|
|
38608
|
+
getTraeMcpInstallPaths(),
|
|
38609
|
+
"Trae",
|
|
38610
|
+
withClientIde(options, "trae")
|
|
38611
|
+
);
|
|
37935
38612
|
}
|
|
37936
38613
|
if (ide === "opencode") {
|
|
37937
38614
|
const configPath = getOpenCodeMcpConfigPath();
|
|
37938
38615
|
if (!fs15.existsSync(configPath)) {
|
|
37939
38616
|
return [{ ide, ok: false, message: "Skipped OpenCode: no supported config file found" }];
|
|
37940
38617
|
}
|
|
37941
|
-
const write = mergeOpenCodeMcpConfig(configPath, options);
|
|
38618
|
+
const write = mergeOpenCodeMcpConfig(configPath, withClientIde(options, "opencode"));
|
|
37942
38619
|
const result = createMcpInstallResult(ide, "OpenCode", configPath, write);
|
|
37943
38620
|
if (write.rewroteJsonc) {
|
|
37944
38621
|
result.message += "\n Note: OpenCode config was rewritten as standard JSON.";
|
|
@@ -37946,10 +38623,21 @@ function installMcpConfigUnsafe(ide, options) {
|
|
|
37946
38623
|
return [result];
|
|
37947
38624
|
}
|
|
37948
38625
|
if (ide === "workbuddy") {
|
|
37949
|
-
return installJsonMcpConfigTargets(
|
|
38626
|
+
return installJsonMcpConfigTargets(
|
|
38627
|
+
ide,
|
|
38628
|
+
getWorkBuddyMcpInstallPaths({ createPrimary: true }),
|
|
38629
|
+
"WorkBuddy",
|
|
38630
|
+
{
|
|
38631
|
+
...options,
|
|
38632
|
+
clientIde: "workbuddy"
|
|
38633
|
+
}
|
|
38634
|
+
);
|
|
37950
38635
|
}
|
|
37951
38636
|
return [{ ide, ok: false, message: `Skipped unknown IDE: ${ide}` }];
|
|
37952
38637
|
}
|
|
38638
|
+
function withClientIde(options, clientIde) {
|
|
38639
|
+
return { ...options, clientIde };
|
|
38640
|
+
}
|
|
37953
38641
|
function installJsonMcpConfigTargets(ide, configPaths, label, options) {
|
|
37954
38642
|
if (configPaths.length === 0) {
|
|
37955
38643
|
return [{ ide, ok: false, message: `Skipped ${label}: no supported config file found` }];
|
|
@@ -38055,19 +38743,16 @@ function getTraeUnverifiedMcpConfigPaths() {
|
|
|
38055
38743
|
function getOpenCodeMcpConfigPath() {
|
|
38056
38744
|
return path16.join(os4.homedir(), ".config", "opencode", "opencode.jsonc");
|
|
38057
38745
|
}
|
|
38058
|
-
function getWorkBuddyMcpInstallPaths() {
|
|
38746
|
+
function getWorkBuddyMcpInstallPaths(options = {}) {
|
|
38059
38747
|
const primary = path16.join(os4.homedir(), ".workbuddy", "mcp.json");
|
|
38060
|
-
|
|
38061
|
-
|
|
38062
|
-
const fallback = process.platform === "win32" ? runtime : primary;
|
|
38063
|
-
const paths = [];
|
|
38064
|
-
if (fs15.existsSync(preferred)) {
|
|
38065
|
-
paths.push(preferred);
|
|
38748
|
+
if (fs15.existsSync(primary) || options.createPrimary) {
|
|
38749
|
+
return [primary];
|
|
38066
38750
|
}
|
|
38067
|
-
|
|
38068
|
-
|
|
38751
|
+
const legacy = path16.join(os4.homedir(), ".workbuddy", ".mcp.json");
|
|
38752
|
+
if (fs15.existsSync(legacy)) {
|
|
38753
|
+
return [legacy];
|
|
38069
38754
|
}
|
|
38070
|
-
return
|
|
38755
|
+
return [];
|
|
38071
38756
|
}
|
|
38072
38757
|
function mergeJsonMcpConfig(configPath, options) {
|
|
38073
38758
|
const existing = readJsonObject(configPath);
|
|
@@ -38113,7 +38798,12 @@ function mergeCodexMcpConfig(configPath, options) {
|
|
|
38113
38798
|
const sectionPattern = createCodexMcpSectionPattern(options.mcpName);
|
|
38114
38799
|
const withoutOld = existing.replace(sectionPattern, "").trimEnd();
|
|
38115
38800
|
const launch = getNpxCliCommand(options.pkg);
|
|
38116
|
-
const
|
|
38801
|
+
const envValues = createMcpEnvironmentValues(options.env, options.clientIde);
|
|
38802
|
+
const envSection = Object.keys(envValues).length === 0 ? [] : [
|
|
38803
|
+
"",
|
|
38804
|
+
`[mcp_servers."${options.mcpName}".env]`,
|
|
38805
|
+
...Object.entries(envValues).map(([key, value]) => `${key} = "${escapeToml(value)}"`)
|
|
38806
|
+
];
|
|
38117
38807
|
const section = [
|
|
38118
38808
|
`[mcp_servers."${options.mcpName}"]`,
|
|
38119
38809
|
`command = "${escapeToml(launch.command)}"`,
|
|
@@ -38187,12 +38877,13 @@ function tryClaudeMcpAdd(options) {
|
|
|
38187
38877
|
"--transport",
|
|
38188
38878
|
"stdio",
|
|
38189
38879
|
...options.env === "production" ? [] : ["--env", `TAPTAP_MCP_ENV=${options.env}`],
|
|
38880
|
+
...options.clientIde ? ["--env", `TAPTAP_MCP_CLIENT_IDE=${options.clientIde}`] : [],
|
|
38190
38881
|
options.mcpName,
|
|
38191
38882
|
"--",
|
|
38192
38883
|
...npxLaunch.commandAndArgs
|
|
38193
38884
|
];
|
|
38194
38885
|
const claude = getWindowsCmdLaunchCommand("claude.cmd", claudeArgs);
|
|
38195
|
-
const result =
|
|
38886
|
+
const result = spawnSync7(
|
|
38196
38887
|
process.platform === "win32" ? claude.command : "claude",
|
|
38197
38888
|
process.platform === "win32" ? claude.args : claudeArgs,
|
|
38198
38889
|
{ encoding: "utf8" }
|
|
@@ -38205,7 +38896,7 @@ function createJsonMcpServerConfig(options) {
|
|
|
38205
38896
|
command: launch.command,
|
|
38206
38897
|
args: launch.args,
|
|
38207
38898
|
...options.cwd ? { cwd: options.cwd } : {},
|
|
38208
|
-
...createOptionalMcpEnvironment(options.env, "env")
|
|
38899
|
+
...createOptionalMcpEnvironment(options.env, "env", options.clientIde)
|
|
38209
38900
|
};
|
|
38210
38901
|
}
|
|
38211
38902
|
function createOpenCodeMcpServerConfig(options) {
|
|
@@ -38213,19 +38904,29 @@ function createOpenCodeMcpServerConfig(options) {
|
|
|
38213
38904
|
type: "local",
|
|
38214
38905
|
command: getOpenCodeNpxCliCommand(options.pkg),
|
|
38215
38906
|
...options.cwd ? { cwd: options.cwd } : {},
|
|
38907
|
+
...createOptionalMcpEnvironment(options.env, "environment", options.clientIde),
|
|
38216
38908
|
enabled: true
|
|
38217
38909
|
};
|
|
38218
38910
|
}
|
|
38219
|
-
function createOptionalMcpEnvironment(env, key) {
|
|
38220
|
-
|
|
38911
|
+
function createOptionalMcpEnvironment(env, key, clientIde) {
|
|
38912
|
+
const values = createMcpEnvironmentValues(env, clientIde);
|
|
38913
|
+
if (Object.keys(values).length === 0) {
|
|
38221
38914
|
return {};
|
|
38222
38915
|
}
|
|
38223
38916
|
return {
|
|
38224
|
-
[key]:
|
|
38225
|
-
TAPTAP_MCP_ENV: env
|
|
38226
|
-
}
|
|
38917
|
+
[key]: values
|
|
38227
38918
|
};
|
|
38228
38919
|
}
|
|
38920
|
+
function createMcpEnvironmentValues(env, clientIde) {
|
|
38921
|
+
const values = {};
|
|
38922
|
+
if (env !== "production") {
|
|
38923
|
+
values.TAPTAP_MCP_ENV = env;
|
|
38924
|
+
}
|
|
38925
|
+
if (clientIde) {
|
|
38926
|
+
values.TAPTAP_MCP_CLIENT_IDE = clientIde;
|
|
38927
|
+
}
|
|
38928
|
+
return values;
|
|
38929
|
+
}
|
|
38229
38930
|
function getOpenCodeNpxCliCommand(pkg) {
|
|
38230
38931
|
const executable = process.platform === "win32" ? "npx.cmd" : "npx";
|
|
38231
38932
|
return [executable, "-y", "-p", pkg, "taptap-maker"];
|
|
@@ -40941,6 +41642,12 @@ var TapTapMCPProxy = class {
|
|
|
40941
41642
|
if (errorCode && networkErrorCodes.includes(errorCode)) {
|
|
40942
41643
|
return true;
|
|
40943
41644
|
}
|
|
41645
|
+
if (errorMsg.includes("not connected") || this.isSessionInvalidError(error2)) {
|
|
41646
|
+
return true;
|
|
41647
|
+
}
|
|
41648
|
+
if (this.isMcpApplicationError(error2)) {
|
|
41649
|
+
return false;
|
|
41650
|
+
}
|
|
40944
41651
|
const networkErrorKeywords = [
|
|
40945
41652
|
"fetch failed",
|
|
40946
41653
|
"socket hang up",
|
|
@@ -40948,15 +41655,18 @@ var TapTapMCPProxy = class {
|
|
|
40948
41655
|
"connection refused",
|
|
40949
41656
|
"connection reset",
|
|
40950
41657
|
"timeout",
|
|
40951
|
-
"dns"
|
|
40952
|
-
"not connected"
|
|
40953
|
-
// 连接断开
|
|
41658
|
+
"dns"
|
|
40954
41659
|
];
|
|
40955
41660
|
if (networkErrorKeywords.some((keyword) => errorMsg.includes(keyword))) {
|
|
40956
41661
|
return true;
|
|
40957
41662
|
}
|
|
40958
41663
|
return this.isSessionInvalidError(error2);
|
|
40959
41664
|
}
|
|
41665
|
+
isMcpApplicationError(error2) {
|
|
41666
|
+
const message = error2.message.toLowerCase();
|
|
41667
|
+
const code = error2.code;
|
|
41668
|
+
return typeof code === "number" && code < 0 || /\bmcp error -\d+/.test(message);
|
|
41669
|
+
}
|
|
40960
41670
|
/**
|
|
40961
41671
|
* 处理待处理的请求队列
|
|
40962
41672
|
*/
|
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
|