@taptap/maker 0.0.17-beta.1 → 0.0.17-beta.2
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 +679 -365
- package/package.json +1 -1
package/dist/maker.js
CHANGED
|
@@ -13003,8 +13003,8 @@ var require_cross_spawn = __commonJS({
|
|
|
13003
13003
|
|
|
13004
13004
|
// src/maker/server/mcp.ts
|
|
13005
13005
|
import { execFileSync, spawn as spawn4, spawnSync as spawnSync6 } from "node:child_process";
|
|
13006
|
-
import
|
|
13007
|
-
import
|
|
13006
|
+
import fs12 from "node:fs";
|
|
13007
|
+
import path13 from "node:path";
|
|
13008
13008
|
|
|
13009
13009
|
// node_modules/zod/v3/helpers/util.js
|
|
13010
13010
|
var util;
|
|
@@ -28305,17 +28305,177 @@ var HiddenStdioClientTransport = class {
|
|
|
28305
28305
|
}
|
|
28306
28306
|
};
|
|
28307
28307
|
|
|
28308
|
+
// src/maker/server/childTransports.ts
|
|
28309
|
+
var activeMakerChildTransports = /* @__PURE__ */ new Set();
|
|
28310
|
+
function trackMakerChildTransport(transport) {
|
|
28311
|
+
activeMakerChildTransports.add(transport);
|
|
28312
|
+
const originalClose = transport.close.bind(transport);
|
|
28313
|
+
let closed = false;
|
|
28314
|
+
transport.close = async () => {
|
|
28315
|
+
if (closed) {
|
|
28316
|
+
return;
|
|
28317
|
+
}
|
|
28318
|
+
closed = true;
|
|
28319
|
+
activeMakerChildTransports.delete(transport);
|
|
28320
|
+
await originalClose();
|
|
28321
|
+
};
|
|
28322
|
+
return transport;
|
|
28323
|
+
}
|
|
28324
|
+
async function closeTrackedMakerChildTransports() {
|
|
28325
|
+
const transports = [...activeMakerChildTransports];
|
|
28326
|
+
activeMakerChildTransports.clear();
|
|
28327
|
+
await Promise.all(transports.map((transport) => transport.close().catch(() => {
|
|
28328
|
+
})));
|
|
28329
|
+
}
|
|
28330
|
+
|
|
28331
|
+
// src/maker/crashLog.ts
|
|
28332
|
+
import fs3 from "node:fs";
|
|
28333
|
+
import path3 from "node:path";
|
|
28334
|
+
var DEFAULT_MAX_BYTES = 1024 * 1024;
|
|
28335
|
+
var DEFAULT_MAX_ENTRY_BYTES = 16 * 1024;
|
|
28336
|
+
function appendMakerCrashLog(source, error2, options = {}) {
|
|
28337
|
+
const makerHome = getMakerHome();
|
|
28338
|
+
fs3.mkdirSync(makerHome, { recursive: true });
|
|
28339
|
+
const logPath = path3.join(makerHome, "mcp-crash.log");
|
|
28340
|
+
const maxBytes = positiveInteger(options.maxBytes) || resolveEnvBytes("TAPTAP_MAKER_CRASH_LOG_MAX_BYTES", DEFAULT_MAX_BYTES);
|
|
28341
|
+
const maxEntryBytes = positiveInteger(options.maxEntryBytes) || resolveEnvBytes("TAPTAP_MAKER_CRASH_LOG_MAX_ENTRY_BYTES", DEFAULT_MAX_ENTRY_BYTES);
|
|
28342
|
+
const message = error2 instanceof Error ? error2.stack || error2.message : String(error2);
|
|
28343
|
+
const entry = truncateUtf8(
|
|
28344
|
+
[`[${(/* @__PURE__ */ new Date()).toISOString()}] ${source}`, message, ""].join("\n"),
|
|
28345
|
+
Math.min(maxEntryBytes, maxBytes)
|
|
28346
|
+
);
|
|
28347
|
+
const entryBytes = Buffer.byteLength(entry, "utf8");
|
|
28348
|
+
rotateIfNeeded(logPath, maxBytes, entryBytes);
|
|
28349
|
+
fs3.appendFileSync(logPath, entry, "utf8");
|
|
28350
|
+
}
|
|
28351
|
+
function rotateIfNeeded(logPath, maxBytes, incomingBytes) {
|
|
28352
|
+
if (!fs3.existsSync(logPath)) {
|
|
28353
|
+
return;
|
|
28354
|
+
}
|
|
28355
|
+
const currentBytes = fs3.statSync(logPath).size;
|
|
28356
|
+
if (currentBytes + incomingBytes <= maxBytes) {
|
|
28357
|
+
return;
|
|
28358
|
+
}
|
|
28359
|
+
const rotatedPath = `${logPath}.1`;
|
|
28360
|
+
writeFileTail(logPath, rotatedPath, maxBytes);
|
|
28361
|
+
fs3.writeFileSync(logPath, "", "utf8");
|
|
28362
|
+
}
|
|
28363
|
+
function writeFileTail(sourcePath, targetPath, maxBytes) {
|
|
28364
|
+
const size = fs3.statSync(sourcePath).size;
|
|
28365
|
+
const bytesToRead = Math.min(size, maxBytes);
|
|
28366
|
+
const start = Math.max(0, size - bytesToRead);
|
|
28367
|
+
const fd = fs3.openSync(sourcePath, "r");
|
|
28368
|
+
try {
|
|
28369
|
+
const buffer = Buffer.alloc(bytesToRead);
|
|
28370
|
+
fs3.readSync(fd, buffer, 0, bytesToRead, start);
|
|
28371
|
+
fs3.writeFileSync(targetPath, buffer);
|
|
28372
|
+
} finally {
|
|
28373
|
+
fs3.closeSync(fd);
|
|
28374
|
+
}
|
|
28375
|
+
}
|
|
28376
|
+
function truncateUtf8(value, maxBytes) {
|
|
28377
|
+
if (Buffer.byteLength(value, "utf8") <= maxBytes) {
|
|
28378
|
+
return value;
|
|
28379
|
+
}
|
|
28380
|
+
const suffix = `
|
|
28381
|
+
[truncated to ${maxBytes} bytes]
|
|
28382
|
+
`;
|
|
28383
|
+
const suffixBytes = Buffer.byteLength(suffix, "utf8");
|
|
28384
|
+
const prefixBytes = Math.max(0, maxBytes - suffixBytes);
|
|
28385
|
+
return `${Buffer.from(value, "utf8").subarray(0, prefixBytes).toString("utf8")}${suffix}`;
|
|
28386
|
+
}
|
|
28387
|
+
function resolveEnvBytes(key, fallback) {
|
|
28388
|
+
return positiveInteger(Number(process.env[key])) || fallback;
|
|
28389
|
+
}
|
|
28390
|
+
function positiveInteger(value) {
|
|
28391
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.floor(value) : void 0;
|
|
28392
|
+
}
|
|
28393
|
+
|
|
28394
|
+
// src/maker/lifecycle.ts
|
|
28395
|
+
var DISCONNECTED_STDIO_CODES = /* @__PURE__ */ new Set(["EPIPE", "ERR_STREAM_DESTROYED", "ECONNRESET"]);
|
|
28396
|
+
function isDisconnectedStdioError(error2) {
|
|
28397
|
+
if (!error2 || typeof error2 !== "object") {
|
|
28398
|
+
return false;
|
|
28399
|
+
}
|
|
28400
|
+
const code = error2.code;
|
|
28401
|
+
if (typeof code === "string" && DISCONNECTED_STDIO_CODES.has(code)) {
|
|
28402
|
+
return true;
|
|
28403
|
+
}
|
|
28404
|
+
const message = error2 instanceof Error ? error2.message.toLowerCase() : "";
|
|
28405
|
+
return message.includes("epipe") || message.includes("stream destroyed");
|
|
28406
|
+
}
|
|
28407
|
+
function shouldExitForParentDeath(options) {
|
|
28408
|
+
if ((options.platform === "darwin" || options.platform === "linux") && options.initialPpid > 1 && options.currentPpid === 1) {
|
|
28409
|
+
return true;
|
|
28410
|
+
}
|
|
28411
|
+
try {
|
|
28412
|
+
options.probeParent();
|
|
28413
|
+
return false;
|
|
28414
|
+
} catch (error2) {
|
|
28415
|
+
return Boolean(
|
|
28416
|
+
error2 && typeof error2 === "object" && error2.code === "ESRCH" && options.initialPpid > 1
|
|
28417
|
+
);
|
|
28418
|
+
}
|
|
28419
|
+
}
|
|
28420
|
+
function installProxyStdinExitHandler(proxy, stdin = process.stdin, exit = (code) => process.exit(code)) {
|
|
28421
|
+
let exiting = false;
|
|
28422
|
+
const exitOnStdinClosed = () => {
|
|
28423
|
+
if (exiting) {
|
|
28424
|
+
return;
|
|
28425
|
+
}
|
|
28426
|
+
exiting = true;
|
|
28427
|
+
logLifecycleEvent("proxy-stdin-closed", "Embedded Maker proxy stdin closed; exiting.");
|
|
28428
|
+
proxy.cleanup();
|
|
28429
|
+
exit(0);
|
|
28430
|
+
};
|
|
28431
|
+
stdin.once("end", exitOnStdinClosed);
|
|
28432
|
+
stdin.once("close", exitOnStdinClosed);
|
|
28433
|
+
}
|
|
28434
|
+
function installParentDeathWatchdog(proxy, options = {}) {
|
|
28435
|
+
var _a3;
|
|
28436
|
+
const initialPpid = options.initialPpid ?? process.ppid;
|
|
28437
|
+
const getCurrentPpid = options.getCurrentPpid ?? (() => process.ppid);
|
|
28438
|
+
const exit = options.exit ?? ((code) => process.exit(code));
|
|
28439
|
+
let exiting = false;
|
|
28440
|
+
const timer = setInterval(() => {
|
|
28441
|
+
if (exiting) {
|
|
28442
|
+
return;
|
|
28443
|
+
}
|
|
28444
|
+
const shouldExit = shouldExitForParentDeath({
|
|
28445
|
+
initialPpid,
|
|
28446
|
+
currentPpid: getCurrentPpid(),
|
|
28447
|
+
platform: process.platform,
|
|
28448
|
+
probeParent: () => process.kill(initialPpid, 0)
|
|
28449
|
+
});
|
|
28450
|
+
if (!shouldExit) {
|
|
28451
|
+
return;
|
|
28452
|
+
}
|
|
28453
|
+
exiting = true;
|
|
28454
|
+
logLifecycleEvent("proxy-parent-dead", "Embedded Maker proxy parent process is gone; exiting.");
|
|
28455
|
+
proxy.cleanup();
|
|
28456
|
+
exit(0);
|
|
28457
|
+
}, options.intervalMs ?? 15e3);
|
|
28458
|
+
(_a3 = timer.unref) == null ? void 0 : _a3.call(timer);
|
|
28459
|
+
return timer;
|
|
28460
|
+
}
|
|
28461
|
+
function logLifecycleEvent(source, message) {
|
|
28462
|
+
try {
|
|
28463
|
+
appendMakerCrashLog(`lifecycle:${source}`, message);
|
|
28464
|
+
} catch {
|
|
28465
|
+
}
|
|
28466
|
+
}
|
|
28467
|
+
|
|
28308
28468
|
// src/maker/cli/projects.ts
|
|
28309
28469
|
import { spawn as spawn3, spawnSync as spawnSync3 } from "node:child_process";
|
|
28310
|
-
import
|
|
28311
|
-
import
|
|
28470
|
+
import fs6 from "node:fs";
|
|
28471
|
+
import path7 from "node:path";
|
|
28312
28472
|
|
|
28313
28473
|
// src/maker/config.ts
|
|
28314
|
-
import
|
|
28315
|
-
import
|
|
28474
|
+
import fs4 from "node:fs";
|
|
28475
|
+
import path5 from "node:path";
|
|
28316
28476
|
|
|
28317
28477
|
// src/core/utils/env.ts
|
|
28318
|
-
import * as
|
|
28478
|
+
import * as path4 from "node:path";
|
|
28319
28479
|
import * as os2 from "node:os";
|
|
28320
28480
|
import process5 from "node:process";
|
|
28321
28481
|
var ENVIRONMENT_ENDPOINTS = {
|
|
@@ -28411,11 +28571,11 @@ var EnvConfig = class {
|
|
|
28411
28571
|
// --------------------------------------------------------------------------
|
|
28412
28572
|
/** 缓存目录 */
|
|
28413
28573
|
static get cacheDir() {
|
|
28414
|
-
return getEnv("TAPTAP_MCP_CACHE_DIR",
|
|
28574
|
+
return getEnv("TAPTAP_MCP_CACHE_DIR", path4.join(os2.tmpdir(), "taptap-mcp", "cache"));
|
|
28415
28575
|
}
|
|
28416
28576
|
/** 临时文件目录 */
|
|
28417
28577
|
static get tempDir() {
|
|
28418
|
-
return getEnv("TAPTAP_MCP_TEMP_DIR",
|
|
28578
|
+
return getEnv("TAPTAP_MCP_TEMP_DIR", path4.join(os2.tmpdir(), "taptap-mcp", "temp"));
|
|
28419
28579
|
}
|
|
28420
28580
|
/** 工作区根目录 */
|
|
28421
28581
|
static get workspaceRoot() {
|
|
@@ -28556,7 +28716,7 @@ var MAKER_ENDPOINTS = {
|
|
|
28556
28716
|
remoteMcpServerUrl: "https://fuping.agnt.xd.com/mcp/v1"
|
|
28557
28717
|
}
|
|
28558
28718
|
};
|
|
28559
|
-
var MAKER_PROJECT_ENV_CONFIG_FILE =
|
|
28719
|
+
var MAKER_PROJECT_ENV_CONFIG_FILE = path5.join(".maker", "taptap-maker.local.json");
|
|
28560
28720
|
var makerEnvironmentOverride;
|
|
28561
28721
|
var MAKER_ENV_OVERRIDES = {
|
|
28562
28722
|
apiBase: {
|
|
@@ -28621,13 +28781,13 @@ function getMakerApiBaseUrl(environment) {
|
|
|
28621
28781
|
return requireMakerEndpoint("apiBase", endpoints.apiBase, environment).replace(/\/$/, "");
|
|
28622
28782
|
}
|
|
28623
28783
|
function getMakerProjectEnvironmentConfigPath(cwd = process.cwd()) {
|
|
28624
|
-
let current =
|
|
28784
|
+
let current = path5.resolve(cwd);
|
|
28625
28785
|
for (; ; ) {
|
|
28626
|
-
const candidate =
|
|
28627
|
-
if (
|
|
28786
|
+
const candidate = path5.join(current, MAKER_PROJECT_ENV_CONFIG_FILE);
|
|
28787
|
+
if (fs4.existsSync(candidate)) {
|
|
28628
28788
|
return candidate;
|
|
28629
28789
|
}
|
|
28630
|
-
const parent =
|
|
28790
|
+
const parent = path5.dirname(current);
|
|
28631
28791
|
if (parent === current) {
|
|
28632
28792
|
return void 0;
|
|
28633
28793
|
}
|
|
@@ -28658,7 +28818,7 @@ function getProjectLocalEnvironment(cwd) {
|
|
|
28658
28818
|
return void 0;
|
|
28659
28819
|
}
|
|
28660
28820
|
try {
|
|
28661
|
-
const raw =
|
|
28821
|
+
const raw = fs4.readFileSync(configPath, "utf8");
|
|
28662
28822
|
const data = JSON.parse(raw);
|
|
28663
28823
|
const env = data.env || data.environment;
|
|
28664
28824
|
return env === "rnd" || env === "production" ? env : void 0;
|
|
@@ -28924,9 +29084,9 @@ function formatGitMissingMessage(environment) {
|
|
|
28924
29084
|
|
|
28925
29085
|
// src/maker/cli/devKit.ts
|
|
28926
29086
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
28927
|
-
import
|
|
29087
|
+
import fs5 from "node:fs";
|
|
28928
29088
|
import os3 from "node:os";
|
|
28929
|
-
import
|
|
29089
|
+
import path6 from "node:path";
|
|
28930
29090
|
|
|
28931
29091
|
// src/maker/fetchTimeout.ts
|
|
28932
29092
|
var DEFAULT_SHORT_FETCH_TIMEOUT_MS = 10 * 1e3;
|
|
@@ -28957,7 +29117,7 @@ var AI_DEV_KIT_URLS = {
|
|
|
28957
29117
|
rnd: "https://urhox-demo-platform.spark.xd.com/ai-dev-kit/rnd/latest/ai-dev-kit.zip"
|
|
28958
29118
|
};
|
|
28959
29119
|
var DEFAULT_AI_DEV_KIT_URL = AI_DEV_KIT_URLS.production;
|
|
28960
|
-
var AI_DEV_KIT_VERSION_METADATA_FILE =
|
|
29120
|
+
var AI_DEV_KIT_VERSION_METADATA_FILE = path6.join(".maker", "ai-dev-kit-version.json");
|
|
28961
29121
|
var AI_DEV_KIT_DOWNLOAD_ENV = {
|
|
28962
29122
|
production: "pd",
|
|
28963
29123
|
rnd: "rnd"
|
|
@@ -28995,9 +29155,9 @@ var DEV_KIT_MANAGED_ENTRY_CANDIDATES = [
|
|
|
28995
29155
|
var SKIPPED_TOP_LEVEL_ENTRIES = /* @__PURE__ */ new Set(["scripts", ".DS_Store", "ai-dev-kit.zip"]);
|
|
28996
29156
|
var SKILL_INSTALLER_OUTPUT_ENTRIES = [".claude", ".codex", ".cursor", ".gemini"];
|
|
28997
29157
|
function inspectAiDevKit(targetDir) {
|
|
28998
|
-
const resolvedTargetDir =
|
|
29158
|
+
const resolvedTargetDir = path6.resolve(targetDir);
|
|
28999
29159
|
const presentEntries = DEV_KIT_REQUIRED_ENTRIES.filter(
|
|
29000
|
-
(entry) =>
|
|
29160
|
+
(entry) => fs5.existsSync(path6.join(resolvedTargetDir, entry))
|
|
29001
29161
|
);
|
|
29002
29162
|
const missingEntries = DEV_KIT_REQUIRED_ENTRIES.filter(
|
|
29003
29163
|
(entry) => !presentEntries.includes(entry)
|
|
@@ -29012,16 +29172,16 @@ function inspectAiDevKit(targetDir) {
|
|
|
29012
29172
|
};
|
|
29013
29173
|
}
|
|
29014
29174
|
function getAiDevKitVersionMetadataPath(targetDir) {
|
|
29015
|
-
return
|
|
29175
|
+
return path6.join(path6.resolve(targetDir), AI_DEV_KIT_VERSION_METADATA_FILE);
|
|
29016
29176
|
}
|
|
29017
29177
|
function readAiDevKitVersionMetadata(targetDir) {
|
|
29018
29178
|
const metadataPath = getAiDevKitVersionMetadataPath(targetDir);
|
|
29019
|
-
if (!
|
|
29179
|
+
if (!fs5.existsSync(metadataPath)) {
|
|
29020
29180
|
return void 0;
|
|
29021
29181
|
}
|
|
29022
29182
|
try {
|
|
29023
29183
|
const data = JSON.parse(
|
|
29024
|
-
|
|
29184
|
+
fs5.readFileSync(metadataPath, "utf8")
|
|
29025
29185
|
);
|
|
29026
29186
|
if (data.env !== "production" && data.env !== "rnd" || !isValidDevKitVersion(data.version) || typeof data.source_url !== "string" || typeof data.installed_at !== "string") {
|
|
29027
29187
|
return void 0;
|
|
@@ -29033,8 +29193,8 @@ function readAiDevKitVersionMetadata(targetDir) {
|
|
|
29033
29193
|
}
|
|
29034
29194
|
function writeAiDevKitVersionMetadata(targetDir, metadata) {
|
|
29035
29195
|
const metadataPath = getAiDevKitVersionMetadataPath(targetDir);
|
|
29036
|
-
|
|
29037
|
-
|
|
29196
|
+
fs5.mkdirSync(path6.dirname(metadataPath), { recursive: true });
|
|
29197
|
+
fs5.writeFileSync(metadataPath, `${JSON.stringify(metadata, null, 2)}
|
|
29038
29198
|
`, "utf8");
|
|
29039
29199
|
}
|
|
29040
29200
|
async function fetchAiDevKitVersions(options = {}) {
|
|
@@ -29089,7 +29249,7 @@ async function resolveAiDevKitDownload(options = {}) {
|
|
|
29089
29249
|
}
|
|
29090
29250
|
async function checkAiDevKitUpdate(targetDir, options = {}) {
|
|
29091
29251
|
var _a3;
|
|
29092
|
-
const resolvedTargetDir =
|
|
29252
|
+
const resolvedTargetDir = path6.resolve(targetDir);
|
|
29093
29253
|
const installed = readAiDevKitVersionMetadata(resolvedTargetDir);
|
|
29094
29254
|
const download = await resolveAiDevKitDownload({
|
|
29095
29255
|
environment: options.environment,
|
|
@@ -29107,24 +29267,24 @@ async function checkAiDevKitUpdate(targetDir, options = {}) {
|
|
|
29107
29267
|
};
|
|
29108
29268
|
}
|
|
29109
29269
|
function listPresentDevKitManagedEntries(targetDir) {
|
|
29110
|
-
const resolvedTargetDir =
|
|
29270
|
+
const resolvedTargetDir = path6.resolve(targetDir);
|
|
29111
29271
|
return DEV_KIT_MANAGED_ENTRY_CANDIDATES.filter(
|
|
29112
|
-
(entry) =>
|
|
29272
|
+
(entry) => fs5.existsSync(path6.join(resolvedTargetDir, entry))
|
|
29113
29273
|
);
|
|
29114
29274
|
}
|
|
29115
29275
|
async function installAiDevKit(options = {}) {
|
|
29116
29276
|
var _a3;
|
|
29117
|
-
const targetDir =
|
|
29118
|
-
|
|
29277
|
+
const targetDir = path6.resolve(options.targetDir || ".");
|
|
29278
|
+
fs5.mkdirSync(targetDir, { recursive: true });
|
|
29119
29279
|
const download = options.sourceDir ? void 0 : options.url ? void 0 : await resolveAiDevKitDownload({
|
|
29120
29280
|
environment: options.environment,
|
|
29121
29281
|
fetchImpl: options.fetchImpl,
|
|
29122
29282
|
versionCheckTimeoutMs: options.versionCheckTimeoutMs
|
|
29123
29283
|
});
|
|
29124
29284
|
const downloadUrl = options.url || (download == null ? void 0 : download.url) || resolveDefaultAiDevKitUrl(options.environment);
|
|
29125
|
-
const preparedSource = options.sourceDir ?
|
|
29285
|
+
const preparedSource = options.sourceDir ? path6.resolve(options.sourceDir) : await downloadAndExtractDevKit(downloadUrl, options.fetchImpl, options.downloadTimeoutMs);
|
|
29126
29286
|
const sourceDir = resolveDevKitRoot(preparedSource);
|
|
29127
|
-
const entries =
|
|
29287
|
+
const entries = fs5.readdirSync(sourceDir, { withFileTypes: true });
|
|
29128
29288
|
const installedEntries = [];
|
|
29129
29289
|
const skippedEntries = [];
|
|
29130
29290
|
if (options.replaceManagedEntries) {
|
|
@@ -29138,7 +29298,7 @@ async function installAiDevKit(options = {}) {
|
|
|
29138
29298
|
skippedEntries.push(entry.name);
|
|
29139
29299
|
continue;
|
|
29140
29300
|
}
|
|
29141
|
-
copyEntry(
|
|
29301
|
+
copyEntry(path6.join(sourceDir, entry.name), path6.join(targetDir, entry.name), {
|
|
29142
29302
|
preserveExisting: options.preserveExisting
|
|
29143
29303
|
});
|
|
29144
29304
|
installedEntries.push(entry.name);
|
|
@@ -29152,7 +29312,7 @@ async function installAiDevKit(options = {}) {
|
|
|
29152
29312
|
installedEntries.push(entry);
|
|
29153
29313
|
}
|
|
29154
29314
|
}
|
|
29155
|
-
const stagedGitignorePath =
|
|
29315
|
+
const stagedGitignorePath = path6.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE);
|
|
29156
29316
|
writeDevKitStagedGitignore(stagedGitignorePath, [
|
|
29157
29317
|
...installedEntries,
|
|
29158
29318
|
...listPresentSkillInstallerOutputEntries(targetDir)
|
|
@@ -29168,7 +29328,7 @@ async function installAiDevKit(options = {}) {
|
|
|
29168
29328
|
sourceDir,
|
|
29169
29329
|
installedEntries: installedEntries.sort(),
|
|
29170
29330
|
skippedEntries: skippedEntries.sort(),
|
|
29171
|
-
gitignorePath:
|
|
29331
|
+
gitignorePath: path6.join(targetDir, ".gitignore"),
|
|
29172
29332
|
stagedGitignorePath,
|
|
29173
29333
|
skillInstaller,
|
|
29174
29334
|
download,
|
|
@@ -29176,11 +29336,11 @@ async function installAiDevKit(options = {}) {
|
|
|
29176
29336
|
};
|
|
29177
29337
|
}
|
|
29178
29338
|
function inspectAiDevKitSkillInstallStatus(targetDir) {
|
|
29179
|
-
const resolvedTargetDir =
|
|
29339
|
+
const resolvedTargetDir = path6.resolve(targetDir);
|
|
29180
29340
|
const targets = SKILL_INSTALLER_OUTPUT_ENTRIES.map((entry) => {
|
|
29181
|
-
const skillsDir =
|
|
29182
|
-
const present =
|
|
29183
|
-
const skillCount = present ?
|
|
29341
|
+
const skillsDir = path6.join(resolvedTargetDir, entry, "skills");
|
|
29342
|
+
const present = fs5.existsSync(skillsDir) && fs5.statSync(skillsDir).isDirectory();
|
|
29343
|
+
const skillCount = present ? fs5.readdirSync(skillsDir, { withFileTypes: true }).filter((item) => item.isDirectory() || item.isSymbolicLink()).length : 0;
|
|
29184
29344
|
return {
|
|
29185
29345
|
name: entry.replace(/^\./, ""),
|
|
29186
29346
|
path: skillsDir,
|
|
@@ -29203,15 +29363,15 @@ function createDevKitGitignoreBlock(entries) {
|
|
|
29203
29363
|
return [DEV_KIT_IGNORE_BEGIN, ...ignoreEntries, DEV_KIT_IGNORE_END].join("\n");
|
|
29204
29364
|
}
|
|
29205
29365
|
function writeDevKitStagedGitignore(stagedGitignorePath, entries) {
|
|
29206
|
-
|
|
29366
|
+
fs5.writeFileSync(stagedGitignorePath, `${createDevKitGitignoreBlock(entries)}
|
|
29207
29367
|
`, "utf8");
|
|
29208
29368
|
}
|
|
29209
29369
|
function ensureMakerAssetPolicyInstructionFiles(targetDir) {
|
|
29210
|
-
const resolvedTargetDir =
|
|
29211
|
-
|
|
29212
|
-
const agentsPath =
|
|
29213
|
-
const existingAgents =
|
|
29214
|
-
|
|
29370
|
+
const resolvedTargetDir = path6.resolve(targetDir);
|
|
29371
|
+
fs5.mkdirSync(resolvedTargetDir, { recursive: true });
|
|
29372
|
+
const agentsPath = path6.join(resolvedTargetDir, AGENTS_INSTRUCTION_FILE);
|
|
29373
|
+
const existingAgents = fs5.existsSync(agentsPath) ? fs5.readFileSync(agentsPath, "utf8") : "";
|
|
29374
|
+
fs5.writeFileSync(agentsPath, prependMakerAssetPolicyBlock(existingAgents), "utf8");
|
|
29215
29375
|
return [AGENTS_INSTRUCTION_FILE];
|
|
29216
29376
|
}
|
|
29217
29377
|
function prependMakerAssetPolicyBlock(existing) {
|
|
@@ -29266,7 +29426,7 @@ function createMakerAssetPolicyBlock() {
|
|
|
29266
29426
|
].join("\n");
|
|
29267
29427
|
}
|
|
29268
29428
|
function mergeDevKitGitignoreBlock(gitignorePath, block) {
|
|
29269
|
-
const existing =
|
|
29429
|
+
const existing = fs5.existsSync(gitignorePath) ? fs5.readFileSync(gitignorePath, "utf8") : "";
|
|
29270
29430
|
const withoutOldBlock = existing.replace(
|
|
29271
29431
|
new RegExp(
|
|
29272
29432
|
`${escapeRegExp(DEV_KIT_IGNORE_BEGIN)}[\\s\\S]*?${escapeRegExp(DEV_KIT_IGNORE_END)}\\n?`,
|
|
@@ -29275,38 +29435,38 @@ function mergeDevKitGitignoreBlock(gitignorePath, block) {
|
|
|
29275
29435
|
""
|
|
29276
29436
|
).trimEnd();
|
|
29277
29437
|
const next = [withoutOldBlock, block, ""].filter((part) => part.length > 0).join("\n\n");
|
|
29278
|
-
|
|
29438
|
+
fs5.writeFileSync(gitignorePath, next, "utf8");
|
|
29279
29439
|
}
|
|
29280
29440
|
function finalizeStagedDevKitGitignore(targetDir) {
|
|
29281
|
-
const stagedGitignorePath =
|
|
29282
|
-
if (!
|
|
29441
|
+
const stagedGitignorePath = path6.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE);
|
|
29442
|
+
if (!fs5.existsSync(stagedGitignorePath)) {
|
|
29283
29443
|
return false;
|
|
29284
29444
|
}
|
|
29285
|
-
const block =
|
|
29445
|
+
const block = fs5.readFileSync(stagedGitignorePath, "utf8").trim();
|
|
29286
29446
|
if (block.length > 0) {
|
|
29287
|
-
mergeDevKitGitignoreBlock(
|
|
29447
|
+
mergeDevKitGitignoreBlock(path6.join(targetDir, ".gitignore"), block);
|
|
29288
29448
|
}
|
|
29289
|
-
|
|
29449
|
+
fs5.rmSync(stagedGitignorePath, { force: true });
|
|
29290
29450
|
return true;
|
|
29291
29451
|
}
|
|
29292
29452
|
function copyEntry(source, target, options = {}) {
|
|
29293
|
-
const stat =
|
|
29453
|
+
const stat = fs5.statSync(source);
|
|
29294
29454
|
if (stat.isDirectory()) {
|
|
29295
|
-
|
|
29296
|
-
for (const child of
|
|
29455
|
+
fs5.mkdirSync(target, { recursive: true });
|
|
29456
|
+
for (const child of fs5.readdirSync(source)) {
|
|
29297
29457
|
if (child === ".DS_Store") {
|
|
29298
29458
|
continue;
|
|
29299
29459
|
}
|
|
29300
|
-
copyEntry(
|
|
29460
|
+
copyEntry(path6.join(source, child), path6.join(target, child), options);
|
|
29301
29461
|
}
|
|
29302
29462
|
return;
|
|
29303
29463
|
}
|
|
29304
29464
|
if (stat.isFile()) {
|
|
29305
|
-
if (options.preserveExisting &&
|
|
29465
|
+
if (options.preserveExisting && fs5.existsSync(target)) {
|
|
29306
29466
|
return;
|
|
29307
29467
|
}
|
|
29308
|
-
|
|
29309
|
-
|
|
29468
|
+
fs5.mkdirSync(path6.dirname(target), { recursive: true });
|
|
29469
|
+
fs5.copyFileSync(source, target);
|
|
29310
29470
|
}
|
|
29311
29471
|
}
|
|
29312
29472
|
function replaceDevKitManagedEntries(targetDir, sourceEntryNames) {
|
|
@@ -29316,11 +29476,11 @@ function replaceDevKitManagedEntries(targetDir, sourceEntryNames) {
|
|
|
29316
29476
|
candidates.add(entry);
|
|
29317
29477
|
}
|
|
29318
29478
|
}
|
|
29319
|
-
for (const entry of readManagedGitignoreEntries(
|
|
29479
|
+
for (const entry of readManagedGitignoreEntries(path6.join(targetDir, ".gitignore"))) {
|
|
29320
29480
|
candidates.add(entry);
|
|
29321
29481
|
}
|
|
29322
29482
|
for (const entry of readManagedGitignoreEntries(
|
|
29323
|
-
|
|
29483
|
+
path6.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE)
|
|
29324
29484
|
)) {
|
|
29325
29485
|
candidates.add(entry);
|
|
29326
29486
|
}
|
|
@@ -29331,14 +29491,14 @@ function replaceDevKitManagedEntries(targetDir, sourceEntryNames) {
|
|
|
29331
29491
|
if (!DEV_KIT_MANAGED_ENTRY_CANDIDATES.includes(entry)) {
|
|
29332
29492
|
continue;
|
|
29333
29493
|
}
|
|
29334
|
-
|
|
29494
|
+
fs5.rmSync(path6.join(targetDir, entry), { recursive: true, force: true });
|
|
29335
29495
|
}
|
|
29336
29496
|
}
|
|
29337
29497
|
function readManagedGitignoreEntries(gitignorePath) {
|
|
29338
|
-
if (!
|
|
29498
|
+
if (!fs5.existsSync(gitignorePath)) {
|
|
29339
29499
|
return [];
|
|
29340
29500
|
}
|
|
29341
|
-
const content =
|
|
29501
|
+
const content = fs5.readFileSync(gitignorePath, "utf8");
|
|
29342
29502
|
const blockPattern = new RegExp(
|
|
29343
29503
|
`${escapeRegExp(DEV_KIT_IGNORE_BEGIN)}\\n([\\s\\S]*?)\\n${escapeRegExp(DEV_KIT_IGNORE_END)}`,
|
|
29344
29504
|
"g"
|
|
@@ -29357,8 +29517,8 @@ function readManagedGitignoreEntries(gitignorePath) {
|
|
|
29357
29517
|
}
|
|
29358
29518
|
function installAiDevKitSkills(targetDir, options = {}) {
|
|
29359
29519
|
var _a3;
|
|
29360
|
-
const toolsDir =
|
|
29361
|
-
if (!
|
|
29520
|
+
const toolsDir = path6.join(targetDir, "tools");
|
|
29521
|
+
if (!fs5.existsSync(toolsDir) || !fs5.statSync(toolsDir).isDirectory()) {
|
|
29362
29522
|
return {
|
|
29363
29523
|
ok: false,
|
|
29364
29524
|
status: "skipped",
|
|
@@ -29370,8 +29530,8 @@ function installAiDevKitSkills(targetDir, options = {}) {
|
|
|
29370
29530
|
}
|
|
29371
29531
|
const isWindows = process.platform === "win32";
|
|
29372
29532
|
const scriptName = isWindows ? "install-skills.ps1" : "install-skills.sh";
|
|
29373
|
-
const scriptPath =
|
|
29374
|
-
if (!
|
|
29533
|
+
const scriptPath = path6.join(toolsDir, scriptName);
|
|
29534
|
+
if (!fs5.existsSync(scriptPath)) {
|
|
29375
29535
|
return {
|
|
29376
29536
|
ok: false,
|
|
29377
29537
|
status: "skipped",
|
|
@@ -29433,7 +29593,7 @@ function runDevKitSkillInstallerForInstall(targetDir, options = {}) {
|
|
|
29433
29593
|
}
|
|
29434
29594
|
function listPresentSkillInstallerOutputEntries(targetDir) {
|
|
29435
29595
|
return SKILL_INSTALLER_OUTPUT_ENTRIES.filter(
|
|
29436
|
-
(entry) =>
|
|
29596
|
+
(entry) => fs5.existsSync(path6.join(targetDir, entry))
|
|
29437
29597
|
);
|
|
29438
29598
|
}
|
|
29439
29599
|
function getAiDevKitVersionsUrl(environment) {
|
|
@@ -29465,16 +29625,16 @@ function writeResolvedDevKitVersionMetadata(targetDir, environment, sourceUrl, c
|
|
|
29465
29625
|
return metadata;
|
|
29466
29626
|
}
|
|
29467
29627
|
async function downloadAndExtractDevKit(url2, fetchImpl = fetch, timeoutMs = DEFAULT_DOWNLOAD_FETCH_TIMEOUT_MS) {
|
|
29468
|
-
const tempDir =
|
|
29469
|
-
const zipPath =
|
|
29628
|
+
const tempDir = fs5.mkdtempSync(path6.join(os3.tmpdir(), "taptap-maker-ai-dev-kit-"));
|
|
29629
|
+
const zipPath = path6.join(tempDir, "ai-dev-kit.zip");
|
|
29470
29630
|
const response = await fetchWithTimeout(fetchImpl, url2, {}, timeoutMs, "AI dev kit download");
|
|
29471
29631
|
if (!response.ok) {
|
|
29472
29632
|
throw new Error(`AI dev kit download failed: HTTP ${response.status} ${response.statusText}`);
|
|
29473
29633
|
}
|
|
29474
29634
|
const payload = Buffer.from(await response.arrayBuffer());
|
|
29475
|
-
|
|
29635
|
+
fs5.writeFileSync(zipPath, payload);
|
|
29476
29636
|
extractZip(zipPath, tempDir);
|
|
29477
|
-
|
|
29637
|
+
fs5.rmSync(zipPath, { force: true });
|
|
29478
29638
|
return tempDir;
|
|
29479
29639
|
}
|
|
29480
29640
|
function extractZip(zipPath, targetDir) {
|
|
@@ -29602,11 +29762,11 @@ function shellQuote(value) {
|
|
|
29602
29762
|
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
29603
29763
|
}
|
|
29604
29764
|
function resolveDevKitRoot(sourceDir) {
|
|
29605
|
-
const directEntries =
|
|
29765
|
+
const directEntries = fs5.existsSync(sourceDir) ? fs5.readdirSync(sourceDir) : [];
|
|
29606
29766
|
if (looksLikeDevKitRoot(sourceDir)) {
|
|
29607
29767
|
return sourceDir;
|
|
29608
29768
|
}
|
|
29609
|
-
const childDirs = directEntries.map((entry) =>
|
|
29769
|
+
const childDirs = directEntries.map((entry) => path6.join(sourceDir, entry)).filter((entryPath) => fs5.existsSync(entryPath) && fs5.statSync(entryPath).isDirectory());
|
|
29610
29770
|
for (const childDir of childDirs) {
|
|
29611
29771
|
if (looksLikeDevKitRoot(childDir)) {
|
|
29612
29772
|
return childDir;
|
|
@@ -29615,7 +29775,7 @@ function resolveDevKitRoot(sourceDir) {
|
|
|
29615
29775
|
throw new Error(`AI dev kit root not found under ${sourceDir}`);
|
|
29616
29776
|
}
|
|
29617
29777
|
function looksLikeDevKitRoot(dir) {
|
|
29618
|
-
return
|
|
29778
|
+
return fs5.existsSync(path6.join(dir, "engine-docs")) || fs5.existsSync(path6.join(dir, ".emmylua")) || fs5.existsSync(path6.join(dir, "urhox-libs"));
|
|
29619
29779
|
}
|
|
29620
29780
|
function formatIgnoreEntry(entry) {
|
|
29621
29781
|
if (entry === ".DS_Store") {
|
|
@@ -29733,7 +29893,7 @@ async function listMakerProjects(options) {
|
|
|
29733
29893
|
}
|
|
29734
29894
|
async function cloneMakerProject(options) {
|
|
29735
29895
|
var _a3, _b, _c, _d, _e, _f, _g, _h;
|
|
29736
|
-
const target =
|
|
29896
|
+
const target = path7.resolve(options.targetDir);
|
|
29737
29897
|
ensureTargetCanBindApp(target, options.appId);
|
|
29738
29898
|
const warnings = createPreCloneWarnings(target);
|
|
29739
29899
|
(_a3 = options.onProgress) == null ? void 0 : _a3.call(options, {
|
|
@@ -29899,7 +30059,7 @@ async function pushMakerProject(options) {
|
|
|
29899
30059
|
phase: "prepare",
|
|
29900
30060
|
message: "Preparing Maker project push"
|
|
29901
30061
|
});
|
|
29902
|
-
const requestedCwd =
|
|
30062
|
+
const requestedCwd = path7.resolve(options.cwd);
|
|
29903
30063
|
const workspace = resolveUsableMakerGitWorkspace(requestedCwd);
|
|
29904
30064
|
const cwd = workspace.projectRoot;
|
|
29905
30065
|
const project = loadProjectConfig(cwd);
|
|
@@ -30530,7 +30690,7 @@ function makeAuthenticatedGitUrl(gitUrl, pat) {
|
|
|
30530
30690
|
return gitUrl.replace(/^https:\/\//, `https://git:${encodeURIComponent(pat)}@`);
|
|
30531
30691
|
}
|
|
30532
30692
|
async function fetchAndCheckoutTarget(target, authUrl, pat, onProgress) {
|
|
30533
|
-
if (
|
|
30693
|
+
if (fs6.existsSync(target) && hasDirectoryEntries(target)) {
|
|
30534
30694
|
onProgress == null ? void 0 : onProgress({
|
|
30535
30695
|
progress: 10,
|
|
30536
30696
|
total: 100,
|
|
@@ -30577,23 +30737,23 @@ function emitFirstCloneWaitNotice(onProgress, phase) {
|
|
|
30577
30737
|
});
|
|
30578
30738
|
}
|
|
30579
30739
|
function hasDirectoryEntries(target) {
|
|
30580
|
-
if (!
|
|
30740
|
+
if (!fs6.existsSync(target)) {
|
|
30581
30741
|
return false;
|
|
30582
30742
|
}
|
|
30583
|
-
return
|
|
30743
|
+
return fs6.readdirSync(target).length > 0;
|
|
30584
30744
|
}
|
|
30585
30745
|
function listLocalFiles(root) {
|
|
30586
|
-
if (!
|
|
30746
|
+
if (!fs6.existsSync(root)) {
|
|
30587
30747
|
return [];
|
|
30588
30748
|
}
|
|
30589
30749
|
const files = [];
|
|
30590
30750
|
const visit = (dir, relativeDir) => {
|
|
30591
|
-
for (const entry of
|
|
30751
|
+
for (const entry of fs6.readdirSync(dir, { withFileTypes: true })) {
|
|
30592
30752
|
const relativePath = relativeDir ? `${relativeDir}/${entry.name}` : entry.name;
|
|
30593
30753
|
if (entry.name === ".git" || relativePath === ".maker-mcp" || relativePath.startsWith(".maker-mcp/") || entry.name === ".DS_Store") {
|
|
30594
30754
|
continue;
|
|
30595
30755
|
}
|
|
30596
|
-
const fullPath =
|
|
30756
|
+
const fullPath = path7.join(dir, entry.name);
|
|
30597
30757
|
if (entry.isDirectory()) {
|
|
30598
30758
|
visit(fullPath, relativePath);
|
|
30599
30759
|
continue;
|
|
@@ -30607,10 +30767,10 @@ function listLocalFiles(root) {
|
|
|
30607
30767
|
return files;
|
|
30608
30768
|
}
|
|
30609
30769
|
function listPreCloneNoticeFiles(root) {
|
|
30610
|
-
if (!
|
|
30770
|
+
if (!fs6.existsSync(root)) {
|
|
30611
30771
|
return [];
|
|
30612
30772
|
}
|
|
30613
|
-
return
|
|
30773
|
+
return fs6.readdirSync(root, { withFileTypes: true }).filter((entry) => !isIgnorablePreCloneEntry(entry.name)).map((entry) => entry.name).sort();
|
|
30614
30774
|
}
|
|
30615
30775
|
function createPreCloneWarnings(target) {
|
|
30616
30776
|
const preCloneLocalFiles = listPreCloneNoticeFiles(target);
|
|
@@ -30733,7 +30893,7 @@ function ensureOwnGitRoot(repoDir) {
|
|
|
30733
30893
|
);
|
|
30734
30894
|
}
|
|
30735
30895
|
function inspectMakerDirectoryGitStatus(cwd) {
|
|
30736
|
-
const targetDir =
|
|
30896
|
+
const targetDir = path7.resolve(cwd);
|
|
30737
30897
|
const gitRoot = resolveGitRoot(targetDir);
|
|
30738
30898
|
const gitDir = resolveGitDir(targetDir);
|
|
30739
30899
|
const makerBinding = findMakerProjectBinding(targetDir);
|
|
@@ -30806,16 +30966,16 @@ function formatMakerGitRootMismatch(status) {
|
|
|
30806
30966
|
}
|
|
30807
30967
|
function findMakerProjectBinding(startDir) {
|
|
30808
30968
|
var _a3;
|
|
30809
|
-
let current =
|
|
30969
|
+
let current = path7.resolve(startDir);
|
|
30810
30970
|
while (current.length > 0) {
|
|
30811
30971
|
const configPath = getProjectConfigPath(current);
|
|
30812
|
-
if (
|
|
30972
|
+
if (fs6.existsSync(configPath) && ((_a3 = loadProjectConfig(current)) == null ? void 0 : _a3.project_id)) {
|
|
30813
30973
|
return {
|
|
30814
30974
|
projectRoot: current,
|
|
30815
30975
|
configPath
|
|
30816
30976
|
};
|
|
30817
30977
|
}
|
|
30818
|
-
const parent =
|
|
30978
|
+
const parent = path7.dirname(current);
|
|
30819
30979
|
if (parent === current) {
|
|
30820
30980
|
return null;
|
|
30821
30981
|
}
|
|
@@ -30825,7 +30985,7 @@ function findMakerProjectBinding(startDir) {
|
|
|
30825
30985
|
}
|
|
30826
30986
|
function resolveGitRoot(cwd) {
|
|
30827
30987
|
try {
|
|
30828
|
-
return
|
|
30988
|
+
return path7.resolve(readGitSync(["-C", cwd, "rev-parse", "--show-toplevel"]).trim());
|
|
30829
30989
|
} catch {
|
|
30830
30990
|
return void 0;
|
|
30831
30991
|
}
|
|
@@ -30833,7 +30993,7 @@ function resolveGitRoot(cwd) {
|
|
|
30833
30993
|
function resolveGitDir(cwd) {
|
|
30834
30994
|
try {
|
|
30835
30995
|
const gitDir = readGitSync(["-C", cwd, "rev-parse", "--git-dir"]).trim();
|
|
30836
|
-
return
|
|
30996
|
+
return path7.isAbsolute(gitDir) ? path7.resolve(gitDir) : path7.resolve(cwd, gitDir);
|
|
30837
30997
|
} catch {
|
|
30838
30998
|
return void 0;
|
|
30839
30999
|
}
|
|
@@ -30842,9 +31002,9 @@ function samePath(left, right) {
|
|
|
30842
31002
|
return normalizePathForCompare(left) === normalizePathForCompare(right);
|
|
30843
31003
|
}
|
|
30844
31004
|
function normalizePathForCompare(value) {
|
|
30845
|
-
const resolved =
|
|
31005
|
+
const resolved = path7.resolve(value);
|
|
30846
31006
|
try {
|
|
30847
|
-
return
|
|
31007
|
+
return fs6.realpathSync.native(resolved);
|
|
30848
31008
|
} catch {
|
|
30849
31009
|
return resolved;
|
|
30850
31010
|
}
|
|
@@ -30957,7 +31117,7 @@ async function runGitCaptureWithTransientRetry(args, options = {}) {
|
|
|
30957
31117
|
async function runWithTransientRetry(operation, options) {
|
|
30958
31118
|
var _a3;
|
|
30959
31119
|
let retries = 0;
|
|
30960
|
-
const maxRetries =
|
|
31120
|
+
const maxRetries = 5;
|
|
30961
31121
|
for (; ; ) {
|
|
30962
31122
|
try {
|
|
30963
31123
|
await operation();
|
|
@@ -30975,7 +31135,7 @@ async function runWithTransientRetry(operation, options) {
|
|
|
30975
31135
|
phase: options.stage,
|
|
30976
31136
|
message: formatGitRetryProgressMessage(options.stage, decision, retries, maxRetries)
|
|
30977
31137
|
});
|
|
30978
|
-
await sleep(
|
|
31138
|
+
await sleep(getMakerGitRetryDelayMs() * retries);
|
|
30979
31139
|
}
|
|
30980
31140
|
}
|
|
30981
31141
|
}
|
|
@@ -31018,9 +31178,9 @@ function appendRetryExhausted(error2, retryAttempts, decision) {
|
|
|
31018
31178
|
].filter(Boolean).join("\n")
|
|
31019
31179
|
);
|
|
31020
31180
|
}
|
|
31021
|
-
function
|
|
31181
|
+
function getMakerGitRetryDelayMs() {
|
|
31022
31182
|
const value = Number.parseInt(process.env.TAPTAP_MAKER_GIT_RETRY_DELAY_MS || "", 10);
|
|
31023
|
-
return Number.isFinite(value) && value >= 0 ? value :
|
|
31183
|
+
return Number.isFinite(value) && value >= 0 ? value : 5e3;
|
|
31024
31184
|
}
|
|
31025
31185
|
function sleep(ms) {
|
|
31026
31186
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -31210,8 +31370,8 @@ async function requestTapAuthWithPat(manualPat, environment, options = {}) {
|
|
|
31210
31370
|
|
|
31211
31371
|
// src/maker/system/python.ts
|
|
31212
31372
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
31213
|
-
import
|
|
31214
|
-
import
|
|
31373
|
+
import fs7 from "node:fs";
|
|
31374
|
+
import path8 from "node:path";
|
|
31215
31375
|
var PYTHON_INFO_SCRIPT = [
|
|
31216
31376
|
"import json, sys",
|
|
31217
31377
|
'print(json.dumps({"executable": sys.executable, "version": ".".join(map(str, sys.version_info[:3]))}))'
|
|
@@ -31220,16 +31380,16 @@ var DEFAULT_PYTHON_VERSION = "3.12";
|
|
|
31220
31380
|
var MINIMUM_PYTHON_VERSION = "3.8";
|
|
31221
31381
|
var RECOMMENDED_PYTHON_VERSION = "3.12";
|
|
31222
31382
|
function getMakerPythonConfigPath() {
|
|
31223
|
-
return
|
|
31383
|
+
return path8.join(getMakerHome(), "python.json");
|
|
31224
31384
|
}
|
|
31225
31385
|
function getMakerUvInstallRoot() {
|
|
31226
|
-
return
|
|
31386
|
+
return path8.join(getMakerHome(), "bin");
|
|
31227
31387
|
}
|
|
31228
31388
|
function getMakerUvPath(platform = process.platform) {
|
|
31229
|
-
return
|
|
31389
|
+
return path8.join(getMakerUvInstallRoot(), platform === "win32" ? "uv.exe" : "uv");
|
|
31230
31390
|
}
|
|
31231
31391
|
function getMakerUvPythonInstallDir() {
|
|
31232
|
-
return
|
|
31392
|
+
return path8.join(getMakerHome(), "python", "uv");
|
|
31233
31393
|
}
|
|
31234
31394
|
function checkMakerPythonEnvironment(options = {}) {
|
|
31235
31395
|
const platform = options.platform || process.platform;
|
|
@@ -31245,7 +31405,7 @@ function checkMakerPythonEnvironment(options = {}) {
|
|
|
31245
31405
|
pathCommand,
|
|
31246
31406
|
uv: {
|
|
31247
31407
|
path: uvPath,
|
|
31248
|
-
installed:
|
|
31408
|
+
installed: fs7.existsSync(uvPath),
|
|
31249
31409
|
version: readUvVersion(uvPath, runner)
|
|
31250
31410
|
}
|
|
31251
31411
|
};
|
|
@@ -31467,10 +31627,10 @@ function resultToEnvironment(result, base) {
|
|
|
31467
31627
|
}
|
|
31468
31628
|
function ensureUvInstalled(platform, runner) {
|
|
31469
31629
|
const uvPath = getMakerUvPath(platform);
|
|
31470
|
-
if (
|
|
31630
|
+
if (fs7.existsSync(uvPath)) {
|
|
31471
31631
|
return uvPath;
|
|
31472
31632
|
}
|
|
31473
|
-
|
|
31633
|
+
fs7.mkdirSync(getMakerUvInstallRoot(), { recursive: true });
|
|
31474
31634
|
const env = {
|
|
31475
31635
|
...process.env,
|
|
31476
31636
|
INSTALLER_NO_MODIFY_PATH: "1",
|
|
@@ -31493,13 +31653,13 @@ function ensureUvInstalled(platform, runner) {
|
|
|
31493
31653
|
if (install.status !== 0) {
|
|
31494
31654
|
throw new Error(formatSetupFailure("uv installer failed", install));
|
|
31495
31655
|
}
|
|
31496
|
-
if (!
|
|
31497
|
-
const nestedUvPath =
|
|
31656
|
+
if (!fs7.existsSync(uvPath)) {
|
|
31657
|
+
const nestedUvPath = path8.join(
|
|
31498
31658
|
getMakerUvInstallRoot(),
|
|
31499
31659
|
"bin",
|
|
31500
31660
|
platform === "win32" ? "uv.exe" : "uv"
|
|
31501
31661
|
);
|
|
31502
|
-
if (
|
|
31662
|
+
if (fs7.existsSync(nestedUvPath)) {
|
|
31503
31663
|
return nestedUvPath;
|
|
31504
31664
|
}
|
|
31505
31665
|
throw new Error(`uv installer finished, but ${uvPath} was not created.`);
|
|
@@ -31510,11 +31670,11 @@ function createUvPythonEnv() {
|
|
|
31510
31670
|
return {
|
|
31511
31671
|
...process.env,
|
|
31512
31672
|
UV_PYTHON_INSTALL_DIR: getMakerUvPythonInstallDir(),
|
|
31513
|
-
UV_CACHE_DIR:
|
|
31673
|
+
UV_CACHE_DIR: path8.join(getMakerHome(), "cache", "uv")
|
|
31514
31674
|
};
|
|
31515
31675
|
}
|
|
31516
31676
|
function readUvVersion(uvPath, runner) {
|
|
31517
|
-
if (!
|
|
31677
|
+
if (!fs7.existsSync(uvPath)) {
|
|
31518
31678
|
return void 0;
|
|
31519
31679
|
}
|
|
31520
31680
|
const result = runner(uvPath, ["--version"], { encoding: "utf8" });
|
|
@@ -31567,11 +31727,11 @@ function parseVersionTuple(version2) {
|
|
|
31567
31727
|
}
|
|
31568
31728
|
function loadPythonRuntimeConfig() {
|
|
31569
31729
|
const configPath = getMakerPythonConfigPath();
|
|
31570
|
-
if (!
|
|
31730
|
+
if (!fs7.existsSync(configPath)) {
|
|
31571
31731
|
return void 0;
|
|
31572
31732
|
}
|
|
31573
31733
|
try {
|
|
31574
|
-
const data = JSON.parse(
|
|
31734
|
+
const data = JSON.parse(fs7.readFileSync(configPath, "utf8"));
|
|
31575
31735
|
if (typeof data.python === "string" || data.status === "setup_failed") {
|
|
31576
31736
|
return data;
|
|
31577
31737
|
}
|
|
@@ -31590,8 +31750,8 @@ function savePythonRuntimeConfig(environment) {
|
|
|
31590
31750
|
version: environment.version,
|
|
31591
31751
|
saved_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
31592
31752
|
};
|
|
31593
|
-
|
|
31594
|
-
|
|
31753
|
+
fs7.mkdirSync(path8.dirname(getMakerPythonConfigPath()), { recursive: true });
|
|
31754
|
+
fs7.writeFileSync(getMakerPythonConfigPath(), JSON.stringify(config2, null, 2), "utf8");
|
|
31595
31755
|
}
|
|
31596
31756
|
function savePythonSetupFailure(error2) {
|
|
31597
31757
|
const config2 = {
|
|
@@ -31599,8 +31759,8 @@ function savePythonSetupFailure(error2) {
|
|
|
31599
31759
|
error: error2 instanceof Error ? error2.message : String(error2),
|
|
31600
31760
|
saved_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
31601
31761
|
};
|
|
31602
|
-
|
|
31603
|
-
|
|
31762
|
+
fs7.mkdirSync(path8.dirname(getMakerPythonConfigPath()), { recursive: true });
|
|
31763
|
+
fs7.writeFileSync(getMakerPythonConfigPath(), JSON.stringify(config2, null, 2), "utf8");
|
|
31604
31764
|
}
|
|
31605
31765
|
function formatSetupFailure(message, result) {
|
|
31606
31766
|
var _a3, _b, _c;
|
|
@@ -31615,8 +31775,8 @@ function formatSetupFailure(message, result) {
|
|
|
31615
31775
|
|
|
31616
31776
|
// src/maker/system/luaLsp.ts
|
|
31617
31777
|
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
31618
|
-
import
|
|
31619
|
-
import
|
|
31778
|
+
import fs8 from "node:fs";
|
|
31779
|
+
import path9 from "node:path";
|
|
31620
31780
|
var LUA_LSP_PACKAGE = "maker-lua-lsp";
|
|
31621
31781
|
var LUA_LSP_IDES = "codex,cursor,claude";
|
|
31622
31782
|
var LUA_LSP_SETUP_TIMEOUT_MS = 12e4;
|
|
@@ -31626,10 +31786,10 @@ var PYTHON_SCRIPTS_DIR_SCRIPT = [
|
|
|
31626
31786
|
'print(sysconfig.get_path("scripts") or "")'
|
|
31627
31787
|
].join("; ");
|
|
31628
31788
|
function getMakerLuaLspConfigPath() {
|
|
31629
|
-
return
|
|
31789
|
+
return path9.join(getMakerHome(), "lua-lsp.json");
|
|
31630
31790
|
}
|
|
31631
31791
|
function getMakerLuaLspVenvDir() {
|
|
31632
|
-
return
|
|
31792
|
+
return path9.join(getMakerHome(), "lua-lsp-venv");
|
|
31633
31793
|
}
|
|
31634
31794
|
function checkMakerLuaLspEnvironment(options = {}) {
|
|
31635
31795
|
const runner = options.spawn || spawnSync5;
|
|
@@ -31657,7 +31817,7 @@ function checkMakerLuaLspEnvironment(options = {}) {
|
|
|
31657
31817
|
command: saved.command,
|
|
31658
31818
|
version: version3,
|
|
31659
31819
|
python: saved.python || python.python,
|
|
31660
|
-
scriptsDir:
|
|
31820
|
+
scriptsDir: path9.dirname(saved.command),
|
|
31661
31821
|
missing: [],
|
|
31662
31822
|
nextAction: "maker-lua-lsp 已安装;本地 Lua 诊断可用。"
|
|
31663
31823
|
};
|
|
@@ -31834,16 +31994,16 @@ function createLuaLspBase(platform) {
|
|
|
31834
31994
|
}
|
|
31835
31995
|
function resolveLuaLspCommand(python, platform, runner) {
|
|
31836
31996
|
const venvCommand = getLuaLspVenvCommand(platform);
|
|
31837
|
-
if (
|
|
31838
|
-
return { command: venvCommand, scriptsDir:
|
|
31997
|
+
if (fs8.existsSync(venvCommand)) {
|
|
31998
|
+
return { command: venvCommand, scriptsDir: path9.dirname(venvCommand) };
|
|
31839
31999
|
}
|
|
31840
32000
|
const scriptsDir = readPythonScriptsDir(python.python, runner);
|
|
31841
32001
|
if (scriptsDir) {
|
|
31842
|
-
const command =
|
|
32002
|
+
const command = path9.join(
|
|
31843
32003
|
scriptsDir,
|
|
31844
32004
|
platform === "win32" ? "maker-lua-lsp.exe" : "maker-lua-lsp"
|
|
31845
32005
|
);
|
|
31846
|
-
if (
|
|
32006
|
+
if (fs8.existsSync(command)) {
|
|
31847
32007
|
return { command, scriptsDir };
|
|
31848
32008
|
}
|
|
31849
32009
|
return { scriptsDir };
|
|
@@ -31867,23 +32027,23 @@ function ensureLuaLspVenv(python, platform, runner) {
|
|
|
31867
32027
|
return { python: venvPython, scriptsDir, command };
|
|
31868
32028
|
}
|
|
31869
32029
|
function isLuaLspVenvComplete(platform) {
|
|
31870
|
-
return
|
|
32030
|
+
return fs8.existsSync(getLuaLspVenvPython(platform)) && fs8.existsSync(getLuaLspVenvConfigPath());
|
|
31871
32031
|
}
|
|
31872
32032
|
function getLuaLspVenvConfigPath() {
|
|
31873
|
-
return
|
|
32033
|
+
return path9.join(getMakerLuaLspVenvDir(), "pyvenv.cfg");
|
|
31874
32034
|
}
|
|
31875
32035
|
function getLuaLspVenvPython(platform) {
|
|
31876
|
-
return
|
|
32036
|
+
return path9.join(
|
|
31877
32037
|
getMakerLuaLspVenvDir(),
|
|
31878
32038
|
platform === "win32" ? "Scripts" : "bin",
|
|
31879
32039
|
platform === "win32" ? "python.exe" : "python"
|
|
31880
32040
|
);
|
|
31881
32041
|
}
|
|
31882
32042
|
function getLuaLspVenvScriptsDir(platform) {
|
|
31883
|
-
return
|
|
32043
|
+
return path9.join(getMakerLuaLspVenvDir(), platform === "win32" ? "Scripts" : "bin");
|
|
31884
32044
|
}
|
|
31885
32045
|
function getLuaLspVenvCommand(platform) {
|
|
31886
|
-
return
|
|
32046
|
+
return path9.join(
|
|
31887
32047
|
getLuaLspVenvScriptsDir(platform),
|
|
31888
32048
|
platform === "win32" ? "maker-lua-lsp.exe" : "maker-lua-lsp"
|
|
31889
32049
|
);
|
|
@@ -31931,11 +32091,11 @@ function formatLuaLspSetupFailure(platform, python, message, result, command, sc
|
|
|
31931
32091
|
}
|
|
31932
32092
|
function loadLuaLspRuntimeConfig() {
|
|
31933
32093
|
const configPath = getMakerLuaLspConfigPath();
|
|
31934
|
-
if (!
|
|
32094
|
+
if (!fs8.existsSync(configPath)) {
|
|
31935
32095
|
return void 0;
|
|
31936
32096
|
}
|
|
31937
32097
|
try {
|
|
31938
|
-
return JSON.parse(
|
|
32098
|
+
return JSON.parse(fs8.readFileSync(configPath, "utf8"));
|
|
31939
32099
|
} catch {
|
|
31940
32100
|
return void 0;
|
|
31941
32101
|
}
|
|
@@ -31948,13 +32108,13 @@ function saveLuaLspRuntimeConfig(environment) {
|
|
|
31948
32108
|
error: environment.error,
|
|
31949
32109
|
saved_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
31950
32110
|
};
|
|
31951
|
-
|
|
31952
|
-
|
|
32111
|
+
fs8.mkdirSync(path9.dirname(getMakerLuaLspConfigPath()), { recursive: true });
|
|
32112
|
+
fs8.writeFileSync(getMakerLuaLspConfigPath(), JSON.stringify(config2, null, 2), "utf8");
|
|
31953
32113
|
}
|
|
31954
32114
|
|
|
31955
32115
|
// src/maker/cli/skill.ts
|
|
31956
|
-
import
|
|
31957
|
-
import
|
|
32116
|
+
import fs9 from "node:fs";
|
|
32117
|
+
import path10 from "node:path";
|
|
31958
32118
|
import { fileURLToPath } from "node:url";
|
|
31959
32119
|
var MAKER_LOCAL_SKILL_NAME = "taptap-maker-local";
|
|
31960
32120
|
var MAKER_DEV_KIT_GUIDE_SKILL_NAME = "taptap-maker-dev-kit-guide";
|
|
@@ -31973,7 +32133,7 @@ var BUNDLED_SKILLS = [
|
|
|
31973
32133
|
function formatMakerSkillStatus(_options = {}) {
|
|
31974
32134
|
const skillDocuments = BUNDLED_SKILLS.map((skill) => ({
|
|
31975
32135
|
name: skill.name,
|
|
31976
|
-
path:
|
|
32136
|
+
path: path10.join(resolveMakerSkillSourceDir(skill.name), "SKILL.md")
|
|
31977
32137
|
}));
|
|
31978
32138
|
return [
|
|
31979
32139
|
"TapTap Maker workflow guide documents",
|
|
@@ -32006,11 +32166,11 @@ function formatMakerSkillStatus(_options = {}) {
|
|
|
32006
32166
|
}
|
|
32007
32167
|
function resolveMakerSkillSourceDir(skillName = MAKER_LOCAL_SKILL_NAME) {
|
|
32008
32168
|
const candidates = [
|
|
32009
|
-
|
|
32169
|
+
path10.join(process.cwd(), "skills", skillName),
|
|
32010
32170
|
getBundledSkillSourceDir(skillName)
|
|
32011
32171
|
].filter(Boolean);
|
|
32012
32172
|
for (const candidate of candidates) {
|
|
32013
|
-
if (
|
|
32173
|
+
if (fs9.existsSync(path10.join(candidate, "SKILL.md"))) {
|
|
32014
32174
|
return candidate;
|
|
32015
32175
|
}
|
|
32016
32176
|
}
|
|
@@ -32023,13 +32183,13 @@ function getBundledSkillSourceDir(skillName) {
|
|
|
32023
32183
|
return null;
|
|
32024
32184
|
}
|
|
32025
32185
|
const bundlePath = fileURLToPath(__MAKER_BUNDLE_URL__);
|
|
32026
|
-
const packageRoot =
|
|
32027
|
-
return
|
|
32186
|
+
const packageRoot = path10.dirname(path10.dirname(bundlePath));
|
|
32187
|
+
return path10.join(packageRoot, "skills", skillName);
|
|
32028
32188
|
}
|
|
32029
32189
|
|
|
32030
32190
|
// src/maker/server/runtimeLogs.ts
|
|
32031
|
-
import
|
|
32032
|
-
import
|
|
32191
|
+
import fs10 from "node:fs";
|
|
32192
|
+
import path11 from "node:path";
|
|
32033
32193
|
var DEFAULT_RUNTIME_LOG_SINCE_SECONDS = 600;
|
|
32034
32194
|
var DEFAULT_RUNTIME_LOG_IDLE_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
32035
32195
|
var MAX_RUNTIME_LOG_WINDOW_SECONDS = 3600;
|
|
@@ -32170,19 +32330,19 @@ async function pullRuntimeLogs(options) {
|
|
|
32170
32330
|
}
|
|
32171
32331
|
function resetRuntimeLogs(projectRoot) {
|
|
32172
32332
|
const runtimeDir = getRuntimeLogDir(projectRoot);
|
|
32173
|
-
|
|
32333
|
+
fs10.mkdirSync(runtimeDir, { recursive: true });
|
|
32174
32334
|
for (const file2 of RUNTIME_LOG_FILES_TO_RESET) {
|
|
32175
|
-
|
|
32335
|
+
fs10.rmSync(path11.join(runtimeDir, file2), { force: true });
|
|
32176
32336
|
}
|
|
32177
32337
|
return runtimeDir;
|
|
32178
32338
|
}
|
|
32179
32339
|
function readRuntimeLogState(projectRoot) {
|
|
32180
32340
|
const statePath = getRuntimeLogStatePath(projectRoot);
|
|
32181
|
-
if (!
|
|
32341
|
+
if (!fs10.existsSync(statePath)) {
|
|
32182
32342
|
return null;
|
|
32183
32343
|
}
|
|
32184
32344
|
try {
|
|
32185
|
-
const state = JSON.parse(
|
|
32345
|
+
const state = JSON.parse(fs10.readFileSync(statePath, "utf8"));
|
|
32186
32346
|
return isRuntimeLogState(state) ? state : null;
|
|
32187
32347
|
} catch {
|
|
32188
32348
|
return null;
|
|
@@ -32210,9 +32370,9 @@ function normalizeRuntimeLogQueryResult(result) {
|
|
|
32210
32370
|
};
|
|
32211
32371
|
}
|
|
32212
32372
|
function writeRuntimeLogRawResponse(projectRoot, raw) {
|
|
32213
|
-
const rawPath =
|
|
32214
|
-
|
|
32215
|
-
|
|
32373
|
+
const rawPath = path11.join(getRuntimeLogDir(projectRoot), "last-query-runtime-logs-result.json");
|
|
32374
|
+
fs10.mkdirSync(path11.dirname(rawPath), { recursive: true });
|
|
32375
|
+
fs10.writeFileSync(
|
|
32216
32376
|
rawPath,
|
|
32217
32377
|
`${JSON.stringify({ capturedAt: (/* @__PURE__ */ new Date()).toISOString(), raw }, null, 2)}
|
|
32218
32378
|
`,
|
|
@@ -32221,7 +32381,7 @@ function writeRuntimeLogRawResponse(projectRoot, raw) {
|
|
|
32221
32381
|
return rawPath;
|
|
32222
32382
|
}
|
|
32223
32383
|
function appendRuntimeLogs(projectRoot, logs) {
|
|
32224
|
-
|
|
32384
|
+
fs10.mkdirSync(getRuntimeLogDir(projectRoot), { recursive: true });
|
|
32225
32385
|
if (logs.length === 0) {
|
|
32226
32386
|
return { files: [], written: 0 };
|
|
32227
32387
|
}
|
|
@@ -32229,7 +32389,7 @@ function appendRuntimeLogs(projectRoot, logs) {
|
|
|
32229
32389
|
let written = 0;
|
|
32230
32390
|
for (const log of logs) {
|
|
32231
32391
|
const line = JSON.stringify(compactRuntimeLogEntry(log));
|
|
32232
|
-
|
|
32392
|
+
fs10.appendFileSync(filePath, `${line}
|
|
32233
32393
|
`, "utf8");
|
|
32234
32394
|
written += 1;
|
|
32235
32395
|
}
|
|
@@ -32237,11 +32397,11 @@ function appendRuntimeLogs(projectRoot, logs) {
|
|
|
32237
32397
|
}
|
|
32238
32398
|
function writeRuntimeLogState(projectRoot, state) {
|
|
32239
32399
|
const statePath = getRuntimeLogStatePath(projectRoot);
|
|
32240
|
-
|
|
32400
|
+
fs10.mkdirSync(path11.dirname(statePath), { recursive: true });
|
|
32241
32401
|
const tempPath = `${statePath}.${process.pid}.${Date.now()}.tmp`;
|
|
32242
|
-
|
|
32402
|
+
fs10.writeFileSync(tempPath, `${JSON.stringify(state, null, 2)}
|
|
32243
32403
|
`, "utf8");
|
|
32244
|
-
|
|
32404
|
+
fs10.renameSync(tempPath, statePath);
|
|
32245
32405
|
}
|
|
32246
32406
|
function writeRuntimeLogFailureState(projectRoot, options) {
|
|
32247
32407
|
const nowIso = new Date(options.nowMs()).toISOString();
|
|
@@ -32273,13 +32433,13 @@ function isNonRetryableRuntimeLogError(error2) {
|
|
|
32273
32433
|
);
|
|
32274
32434
|
}
|
|
32275
32435
|
function getRuntimeLogDir(projectRoot) {
|
|
32276
|
-
return
|
|
32436
|
+
return path11.join(projectRoot, ".maker", "logs", "runtime");
|
|
32277
32437
|
}
|
|
32278
32438
|
function getRuntimeLogStatePath(projectRoot) {
|
|
32279
|
-
return
|
|
32439
|
+
return path11.join(getRuntimeLogDir(projectRoot), "state.json");
|
|
32280
32440
|
}
|
|
32281
32441
|
function getRuntimeLogPath(projectRoot) {
|
|
32282
|
-
return
|
|
32442
|
+
return path11.join(getRuntimeLogDir(projectRoot), MERGED_RUNTIME_LOG_FILE);
|
|
32283
32443
|
}
|
|
32284
32444
|
function resolveNextRuntimeLogCursor(result) {
|
|
32285
32445
|
const maxLogTime = result.logs.reduce((max, log) => {
|
|
@@ -32404,8 +32564,8 @@ function compactRuntimeLogEntry(entry) {
|
|
|
32404
32564
|
}
|
|
32405
32565
|
|
|
32406
32566
|
// src/maker/server/proxyAssets.ts
|
|
32407
|
-
import
|
|
32408
|
-
import
|
|
32567
|
+
import fs11 from "node:fs";
|
|
32568
|
+
import path12 from "node:path";
|
|
32409
32569
|
var IMAGE_ASSET_DIRS = ["assets/image"];
|
|
32410
32570
|
var VIDEO_ASSET_DIRS = ["assets/video"];
|
|
32411
32571
|
var AUDIO_ASSET_DIRS = ["assets/audio"];
|
|
@@ -32649,8 +32809,8 @@ async function materializeAsset(options) {
|
|
|
32649
32809
|
};
|
|
32650
32810
|
}
|
|
32651
32811
|
const bytes = Buffer.from(await response.arrayBuffer());
|
|
32652
|
-
|
|
32653
|
-
|
|
32812
|
+
fs11.mkdirSync(path12.dirname(absolutePath), { recursive: true });
|
|
32813
|
+
fs11.writeFileSync(absolutePath, bytes);
|
|
32654
32814
|
return { localPath: relativePath, absolutePath, download: { success: true } };
|
|
32655
32815
|
} catch (error2) {
|
|
32656
32816
|
return {
|
|
@@ -32664,12 +32824,12 @@ async function materializeAsset(options) {
|
|
|
32664
32824
|
function createUniqueAssetPath(options) {
|
|
32665
32825
|
const stem = `${sanitizeAssetBaseName(options.baseName)}_${formatAssetTimestamp(options.now)}`;
|
|
32666
32826
|
for (let index = 1; index <= 9999; index += 1) {
|
|
32667
|
-
const relativePath =
|
|
32827
|
+
const relativePath = path12.posix.join(
|
|
32668
32828
|
options.relativeDir,
|
|
32669
32829
|
`${stem}${index === 1 ? "" : `_${index}`}.${options.extension}`
|
|
32670
32830
|
);
|
|
32671
|
-
const absolutePath =
|
|
32672
|
-
if (!
|
|
32831
|
+
const absolutePath = path12.join(options.targetDir, ...relativePath.split("/"));
|
|
32832
|
+
if (!fs11.existsSync(absolutePath)) {
|
|
32673
32833
|
return { relativePath, absolutePath };
|
|
32674
32834
|
}
|
|
32675
32835
|
}
|
|
@@ -32752,7 +32912,7 @@ function findRegistryAssetByName(value, registry2, assetDirs) {
|
|
|
32752
32912
|
if (!isKnownAssetPath(localPath, assetDirs)) {
|
|
32753
32913
|
return false;
|
|
32754
32914
|
}
|
|
32755
|
-
const basename =
|
|
32915
|
+
const basename = path12.posix.basename(localPath);
|
|
32756
32916
|
const stem = basename.replace(/\.[^.]+$/, "");
|
|
32757
32917
|
return basename === value || stem === value || record2.name === value || record2.taskId === value;
|
|
32758
32918
|
});
|
|
@@ -32765,13 +32925,13 @@ function findRegistryAssetByName(value, registry2, assetDirs) {
|
|
|
32765
32925
|
}
|
|
32766
32926
|
function findLocalAssetByName(targetDir, value, assetDirs) {
|
|
32767
32927
|
var _a3;
|
|
32768
|
-
const hasExtension = Boolean(
|
|
32928
|
+
const hasExtension = Boolean(path12.extname(value));
|
|
32769
32929
|
const candidates = [];
|
|
32770
32930
|
for (const assetDir of assetDirs) {
|
|
32771
|
-
const absoluteDir =
|
|
32931
|
+
const absoluteDir = path12.join(targetDir, ...assetDir.split("/"));
|
|
32772
32932
|
let entries;
|
|
32773
32933
|
try {
|
|
32774
|
-
entries =
|
|
32934
|
+
entries = fs11.readdirSync(absoluteDir);
|
|
32775
32935
|
} catch {
|
|
32776
32936
|
continue;
|
|
32777
32937
|
}
|
|
@@ -32780,11 +32940,11 @@ function findLocalAssetByName(targetDir, value, assetDirs) {
|
|
|
32780
32940
|
if (hasExtension ? entry !== value : stem !== value && !stem.startsWith(`${value}_`)) {
|
|
32781
32941
|
continue;
|
|
32782
32942
|
}
|
|
32783
|
-
const absolutePath =
|
|
32943
|
+
const absolutePath = path12.join(absoluteDir, entry);
|
|
32784
32944
|
try {
|
|
32785
32945
|
candidates.push({
|
|
32786
|
-
localPath:
|
|
32787
|
-
mtimeMs:
|
|
32946
|
+
localPath: path12.posix.join(assetDir, entry),
|
|
32947
|
+
mtimeMs: fs11.statSync(absolutePath).mtimeMs
|
|
32788
32948
|
});
|
|
32789
32949
|
} catch {
|
|
32790
32950
|
}
|
|
@@ -32794,7 +32954,7 @@ function findLocalAssetByName(targetDir, value, assetDirs) {
|
|
|
32794
32954
|
return (_a3 = candidates[0]) == null ? void 0 : _a3.localPath;
|
|
32795
32955
|
}
|
|
32796
32956
|
function isKnownAssetPath(relativePath, assetDirs) {
|
|
32797
|
-
if (relativePath.startsWith("../") ||
|
|
32957
|
+
if (relativePath.startsWith("../") || path12.isAbsolute(relativePath)) {
|
|
32798
32958
|
return false;
|
|
32799
32959
|
}
|
|
32800
32960
|
return assetDirs.some(
|
|
@@ -32808,31 +32968,31 @@ function upsertGeneratedAssetRecord(targetDir, localPath, record2) {
|
|
|
32808
32968
|
const registry2 = readGeneratedAssetRegistry(targetDir);
|
|
32809
32969
|
registry2[localPath] = record2;
|
|
32810
32970
|
const registryPath = getGeneratedAssetRegistryPath(targetDir);
|
|
32811
|
-
|
|
32812
|
-
|
|
32971
|
+
fs11.mkdirSync(path12.dirname(registryPath), { recursive: true });
|
|
32972
|
+
fs11.writeFileSync(registryPath, `${JSON.stringify(registry2, null, 2)}
|
|
32813
32973
|
`, "utf8");
|
|
32814
32974
|
}
|
|
32815
32975
|
function readGeneratedAssetRegistry(targetDir) {
|
|
32816
32976
|
const registryPath = getGeneratedAssetRegistryPath(targetDir);
|
|
32817
|
-
if (!
|
|
32977
|
+
if (!fs11.existsSync(registryPath)) {
|
|
32818
32978
|
return {};
|
|
32819
32979
|
}
|
|
32820
32980
|
try {
|
|
32821
|
-
const parsed = JSON.parse(
|
|
32981
|
+
const parsed = JSON.parse(fs11.readFileSync(registryPath, "utf8"));
|
|
32822
32982
|
return isRecord(parsed) ? parsed : {};
|
|
32823
32983
|
} catch {
|
|
32824
32984
|
return {};
|
|
32825
32985
|
}
|
|
32826
32986
|
}
|
|
32827
32987
|
function getGeneratedAssetRegistryPath(targetDir) {
|
|
32828
|
-
return
|
|
32988
|
+
return path12.join(targetDir, ".maker", "assets", "generated-assets.json");
|
|
32829
32989
|
}
|
|
32830
32990
|
function normalizeAssetRegistryKey(targetDir, value) {
|
|
32831
32991
|
if (/^https?:\/\//i.test(value) || value.startsWith("data:")) {
|
|
32832
32992
|
return void 0;
|
|
32833
32993
|
}
|
|
32834
|
-
const relative =
|
|
32835
|
-
return relative.split(
|
|
32994
|
+
const relative = path12.isAbsolute(value) ? path12.relative(targetDir, value) : value;
|
|
32995
|
+
return relative.split(path12.sep).join("/");
|
|
32836
32996
|
}
|
|
32837
32997
|
function isRecord(value) {
|
|
32838
32998
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -32861,7 +33021,7 @@ function extensionFromUrl(url2) {
|
|
|
32861
33021
|
}
|
|
32862
33022
|
try {
|
|
32863
33023
|
const pathname = new URL(url2).pathname;
|
|
32864
|
-
const extension =
|
|
33024
|
+
const extension = path12.extname(pathname).replace(/^\./, "").toLowerCase();
|
|
32865
33025
|
return extension || void 0;
|
|
32866
33026
|
} catch {
|
|
32867
33027
|
return void 0;
|
|
@@ -32869,7 +33029,7 @@ function extensionFromUrl(url2) {
|
|
|
32869
33029
|
}
|
|
32870
33030
|
|
|
32871
33031
|
// src/maker/server/mcp.ts
|
|
32872
|
-
var VERSION = true ? "0.0.17-beta.
|
|
33032
|
+
var VERSION = true ? "0.0.17-beta.2" : "dev";
|
|
32873
33033
|
var DEFAULT_BUILD_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
32874
33034
|
var DEFAULT_PROXY_RETRY_ATTEMPTS = 5;
|
|
32875
33035
|
var DEFAULT_PROXY_RETRY_DELAY_MS = 30 * 1e3;
|
|
@@ -33009,12 +33169,14 @@ async function listRemoteProxyTools(options) {
|
|
|
33009
33169
|
env: options.env,
|
|
33010
33170
|
exposedTools: MAKER_REMOTE_PROXY_EXPOSED_TOOL_NAMES
|
|
33011
33171
|
});
|
|
33012
|
-
const transport =
|
|
33013
|
-
|
|
33014
|
-
|
|
33015
|
-
|
|
33016
|
-
|
|
33017
|
-
|
|
33172
|
+
const transport = trackMakerChildTransport(
|
|
33173
|
+
new StdioClientTransport({
|
|
33174
|
+
command: proxy.command,
|
|
33175
|
+
args: proxy.args,
|
|
33176
|
+
env: mergeStringEnv(process.env, proxy.envVars),
|
|
33177
|
+
stderr: "pipe"
|
|
33178
|
+
})
|
|
33179
|
+
);
|
|
33018
33180
|
const client = new Client(
|
|
33019
33181
|
{
|
|
33020
33182
|
name: "taptap-maker-tool-list-forwarder",
|
|
@@ -33045,12 +33207,14 @@ async function callRemoteProxyTool(options) {
|
|
|
33045
33207
|
});
|
|
33046
33208
|
const result = await retryMakerProxyOperation(
|
|
33047
33209
|
async () => {
|
|
33048
|
-
const transport =
|
|
33049
|
-
|
|
33050
|
-
|
|
33051
|
-
|
|
33052
|
-
|
|
33053
|
-
|
|
33210
|
+
const transport = trackMakerChildTransport(
|
|
33211
|
+
new StdioClientTransport({
|
|
33212
|
+
command: proxy.command,
|
|
33213
|
+
args: proxy.args,
|
|
33214
|
+
env: mergeStringEnv(process.env, proxy.envVars),
|
|
33215
|
+
stderr: "pipe"
|
|
33216
|
+
})
|
|
33217
|
+
);
|
|
33054
33218
|
const client = new Client(
|
|
33055
33219
|
{
|
|
33056
33220
|
name: "taptap-maker-tool-call-forwarder",
|
|
@@ -33220,6 +33384,37 @@ async function startMakerMcpServer() {
|
|
|
33220
33384
|
});
|
|
33221
33385
|
const transport = new StdioServerTransport();
|
|
33222
33386
|
await server.connect(transport);
|
|
33387
|
+
installMakerServerExitHandlers();
|
|
33388
|
+
}
|
|
33389
|
+
var MAKER_SERVER_SHUTDOWN_TIMEOUT_MS = 3e3;
|
|
33390
|
+
function installMakerServerExitHandlers() {
|
|
33391
|
+
let exiting = false;
|
|
33392
|
+
const shutdown = async (source) => {
|
|
33393
|
+
if (exiting) {
|
|
33394
|
+
return;
|
|
33395
|
+
}
|
|
33396
|
+
exiting = true;
|
|
33397
|
+
logLifecycleEvent(source, "Maker MCP server is exiting; closing active child transports.");
|
|
33398
|
+
const timeout = new Promise((resolve) => {
|
|
33399
|
+
var _a3;
|
|
33400
|
+
const timer = setTimeout(resolve, MAKER_SERVER_SHUTDOWN_TIMEOUT_MS);
|
|
33401
|
+
(_a3 = timer.unref) == null ? void 0 : _a3.call(timer);
|
|
33402
|
+
});
|
|
33403
|
+
await Promise.race([closeTrackedMakerChildTransports(), timeout]);
|
|
33404
|
+
process.exit(0);
|
|
33405
|
+
};
|
|
33406
|
+
process.stdin.once("end", () => {
|
|
33407
|
+
void shutdown("maker-server-stdin-end");
|
|
33408
|
+
});
|
|
33409
|
+
process.stdin.once("close", () => {
|
|
33410
|
+
void shutdown("maker-server-stdin-close");
|
|
33411
|
+
});
|
|
33412
|
+
process.once("SIGINT", () => {
|
|
33413
|
+
void shutdown("maker-server-sigint");
|
|
33414
|
+
});
|
|
33415
|
+
process.once("SIGTERM", () => {
|
|
33416
|
+
void shutdown("maker-server-sigterm");
|
|
33417
|
+
});
|
|
33223
33418
|
}
|
|
33224
33419
|
async function formatStatus(options = {}) {
|
|
33225
33420
|
var _a3;
|
|
@@ -33227,7 +33422,7 @@ async function formatStatus(options = {}) {
|
|
|
33227
33422
|
const env = getMakerEnvironment(void 0, targetDir);
|
|
33228
33423
|
const identify = identifyMakerProject({ cwd: targetDir });
|
|
33229
33424
|
const mcpCwd = process.cwd();
|
|
33230
|
-
const mcpCwdIdentify =
|
|
33425
|
+
const mcpCwdIdentify = path13.resolve(mcpCwd) === path13.resolve(targetDir) ? identify : identifyMakerProject({ cwd: mcpCwd });
|
|
33231
33426
|
const gitDirectoryStatus = inspectMakerDirectoryGitStatus(targetDir);
|
|
33232
33427
|
const remoteSyncText = identify.projectRoot && gitDirectoryStatus.isUsableMakerGitRepo && !options.skipRemoteSync ? await formatMakerRemoteSyncStatusSafely(identify.projectRoot) : identify.projectRoot && gitDirectoryStatus.isUsableMakerGitRepo ? formatMakerRemoteSyncSkipped() : "";
|
|
33233
33428
|
const pat = loadPat();
|
|
@@ -33347,10 +33542,10 @@ function formatMakerToolRegistrationCwdStatus(options) {
|
|
|
33347
33542
|
if (!options.projectRoot) {
|
|
33348
33543
|
return "";
|
|
33349
33544
|
}
|
|
33350
|
-
const mcpCwd =
|
|
33351
|
-
const targetDir =
|
|
33352
|
-
const projectRoot =
|
|
33353
|
-
const mcpProjectRoot = options.mcpProjectRoot ?
|
|
33545
|
+
const mcpCwd = path13.resolve(options.mcpCwd);
|
|
33546
|
+
const targetDir = path13.resolve(options.targetDir);
|
|
33547
|
+
const projectRoot = path13.resolve(options.projectRoot);
|
|
33548
|
+
const mcpProjectRoot = options.mcpProjectRoot ? path13.resolve(options.mcpProjectRoot) : void 0;
|
|
33354
33549
|
if (mcpProjectRoot === projectRoot) {
|
|
33355
33550
|
return "";
|
|
33356
33551
|
}
|
|
@@ -33512,7 +33707,7 @@ function formatAiDialogueDirectoryHint(targetDir) {
|
|
|
33512
33707
|
}
|
|
33513
33708
|
function resolveMakerToolTargetDir(targetDir) {
|
|
33514
33709
|
if (targetDir) {
|
|
33515
|
-
return
|
|
33710
|
+
return path13.resolve(targetDir);
|
|
33516
33711
|
}
|
|
33517
33712
|
return process.cwd();
|
|
33518
33713
|
}
|
|
@@ -33612,14 +33807,14 @@ function formatStatusProjectList(projects) {
|
|
|
33612
33807
|
].filter((line) => line !== void 0).join("\n");
|
|
33613
33808
|
}
|
|
33614
33809
|
function formatClonePartialStateLines(targetDir) {
|
|
33615
|
-
const resolvedTargetDir =
|
|
33810
|
+
const resolvedTargetDir = path13.resolve(targetDir);
|
|
33616
33811
|
const identify = identifyMakerProject({ cwd: resolvedTargetDir });
|
|
33617
33812
|
const gitStatus = inspectMakerDirectoryGitStatus(resolvedTargetDir);
|
|
33618
33813
|
const devKitStatus = inspectAiDevKit(resolvedTargetDir);
|
|
33619
|
-
const stagedDevKitGitignorePath =
|
|
33814
|
+
const stagedDevKitGitignorePath = path13.join(resolvedTargetDir, DEV_KIT_GITIGNORE_STAGING_FILE);
|
|
33620
33815
|
const projectBound = Boolean(identify.projectId);
|
|
33621
33816
|
const gitInitialized = Boolean(
|
|
33622
|
-
gitStatus.isOwnGitRoot ||
|
|
33817
|
+
gitStatus.isOwnGitRoot || fs12.existsSync(path13.join(resolvedTargetDir, ".git"))
|
|
33623
33818
|
);
|
|
33624
33819
|
const safeToRetry = !projectBound;
|
|
33625
33820
|
return [
|
|
@@ -33633,7 +33828,7 @@ function formatClonePartialStateLines(targetDir) {
|
|
|
33633
33828
|
identify.configPath ? `- config: ${identify.configPath}` : "",
|
|
33634
33829
|
`- ai_dev_kit_present: ${devKitStatus.ready ? "yes" : "no"}`,
|
|
33635
33830
|
`- ai_dev_kit_missing_entries: ${devKitStatus.missingEntries.join(", ") || "(none)"}`,
|
|
33636
|
-
`- staged_dev_kit_gitignore: ${
|
|
33831
|
+
`- staged_dev_kit_gitignore: ${fs12.existsSync(stagedDevKitGitignorePath) ? "yes" : "no"}`,
|
|
33637
33832
|
`- safe_to_retry: ${safeToRetry ? "yes" : "no"}`,
|
|
33638
33833
|
safeToRetry ? "- next_step: 可以直接重试 taptap-maker init;如果连续失败,建议换一个全新的独立目录重新 clone。" : "- next_step: 当前目录已经有 Maker 绑定信息;先运行 taptap-maker doctor 或读取 maker://status 确认状态。"
|
|
33639
33834
|
].filter(Boolean);
|
|
@@ -33706,7 +33901,7 @@ function resolveEmbeddedProxyCommand(options) {
|
|
|
33706
33901
|
}
|
|
33707
33902
|
return {
|
|
33708
33903
|
command: process.execPath,
|
|
33709
|
-
args: [
|
|
33904
|
+
args: [path13.resolve(makerEntry), "__maker-proxy"]
|
|
33710
33905
|
};
|
|
33711
33906
|
}
|
|
33712
33907
|
function createToolProgressReporter(progressToken, extra, operationName) {
|
|
@@ -33908,12 +34103,14 @@ async function runRemoteBuildCurrentDirectory(options, targetDir) {
|
|
|
33908
34103
|
const timeoutMs = options.timeoutMs || DEFAULT_BUILD_TIMEOUT_MS;
|
|
33909
34104
|
const result = await retryMakerProxyOperation(
|
|
33910
34105
|
async () => {
|
|
33911
|
-
const transport =
|
|
33912
|
-
|
|
33913
|
-
|
|
33914
|
-
|
|
33915
|
-
|
|
33916
|
-
|
|
34106
|
+
const transport = trackMakerChildTransport(
|
|
34107
|
+
new StdioClientTransport({
|
|
34108
|
+
command: proxy.command,
|
|
34109
|
+
args: proxy.args,
|
|
34110
|
+
env: mergeStringEnv(process.env, proxy.envVars),
|
|
34111
|
+
stderr: "pipe"
|
|
34112
|
+
})
|
|
34113
|
+
);
|
|
33917
34114
|
const client = new Client(
|
|
33918
34115
|
{
|
|
33919
34116
|
name: "taptap-maker-build-forwarder",
|
|
@@ -34045,18 +34242,18 @@ async function attachRuntimeLogWatch(buildResult, startWatch) {
|
|
|
34045
34242
|
}
|
|
34046
34243
|
}
|
|
34047
34244
|
async function startRuntimeLogWatch(buildResult) {
|
|
34048
|
-
const runtimeDir =
|
|
34049
|
-
|
|
34050
|
-
const stdoutLog =
|
|
34051
|
-
const stderrLog =
|
|
34052
|
-
const pidFile =
|
|
34245
|
+
const runtimeDir = path13.join(buildResult.projectRoot, ".maker", "logs", "runtime");
|
|
34246
|
+
fs12.mkdirSync(runtimeDir, { recursive: true });
|
|
34247
|
+
const stdoutLog = path13.join(runtimeDir, "watcher.out.log");
|
|
34248
|
+
const stderrLog = path13.join(runtimeDir, "watcher.err.log");
|
|
34249
|
+
const pidFile = path13.join(runtimeDir, "watcher.pid");
|
|
34053
34250
|
const previous = stopExistingRuntimeLogWatcher(pidFile);
|
|
34054
|
-
const outFd =
|
|
34055
|
-
const errFd =
|
|
34251
|
+
const outFd = fs12.openSync(stdoutLog, "a");
|
|
34252
|
+
const errFd = fs12.openSync(stderrLog, "a");
|
|
34056
34253
|
const command = formatRuntimeLogWatchCommand(buildResult);
|
|
34057
34254
|
if (previous.previousStopError) {
|
|
34058
|
-
|
|
34059
|
-
|
|
34255
|
+
fs12.closeSync(outFd);
|
|
34256
|
+
fs12.closeSync(errFd);
|
|
34060
34257
|
return {
|
|
34061
34258
|
started: false,
|
|
34062
34259
|
command: command.text,
|
|
@@ -34119,18 +34316,18 @@ async function startRuntimeLogWatch(buildResult) {
|
|
|
34119
34316
|
...previous
|
|
34120
34317
|
};
|
|
34121
34318
|
} finally {
|
|
34122
|
-
|
|
34123
|
-
|
|
34319
|
+
fs12.closeSync(outFd);
|
|
34320
|
+
fs12.closeSync(errFd);
|
|
34124
34321
|
}
|
|
34125
34322
|
}
|
|
34126
34323
|
function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
|
|
34127
|
-
if (!
|
|
34324
|
+
if (!fs12.existsSync(pidFile)) {
|
|
34128
34325
|
return {};
|
|
34129
34326
|
}
|
|
34130
34327
|
const pidState = readRuntimeLogWatcherPidState(pidFile);
|
|
34131
34328
|
const pid = pidState == null ? void 0 : pidState.pid;
|
|
34132
34329
|
if (!Number.isInteger(pid) || pid <= 0) {
|
|
34133
|
-
|
|
34330
|
+
fs12.rmSync(pidFile, { force: true });
|
|
34134
34331
|
return {};
|
|
34135
34332
|
}
|
|
34136
34333
|
try {
|
|
@@ -34138,7 +34335,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
|
|
|
34138
34335
|
const processCommand = (options.getProcessCommand || getProcessCommand)(pid);
|
|
34139
34336
|
const verifiedCommand = getVerifiedRuntimeLogWatcherCommand(processCommand, pidState);
|
|
34140
34337
|
if (!verifiedCommand) {
|
|
34141
|
-
|
|
34338
|
+
fs12.rmSync(pidFile, { force: true });
|
|
34142
34339
|
return {
|
|
34143
34340
|
previousPid: pid,
|
|
34144
34341
|
previousStopped: false,
|
|
@@ -34148,7 +34345,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
|
|
|
34148
34345
|
process.kill(pid, "SIGTERM");
|
|
34149
34346
|
const stopped = (options.waitForExit || waitForProcessExit)(pid, WATCHER_STOP_TIMEOUT_MS);
|
|
34150
34347
|
if (stopped) {
|
|
34151
|
-
|
|
34348
|
+
fs12.rmSync(pidFile, { force: true });
|
|
34152
34349
|
return { previousPid: pid, previousStopped: true };
|
|
34153
34350
|
}
|
|
34154
34351
|
return {
|
|
@@ -34157,7 +34354,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
|
|
|
34157
34354
|
previousStopError: `process ${pid} did not exit after SIGTERM within ${WATCHER_STOP_TIMEOUT_MS}ms`
|
|
34158
34355
|
};
|
|
34159
34356
|
} catch (error2) {
|
|
34160
|
-
|
|
34357
|
+
fs12.rmSync(pidFile, { force: true });
|
|
34161
34358
|
const code = error2 && typeof error2 === "object" && "code" in error2 ? String(error2.code) : "";
|
|
34162
34359
|
if (code === "ESRCH") {
|
|
34163
34360
|
return { previousPid: pid, previousStopped: false };
|
|
@@ -34170,7 +34367,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
|
|
|
34170
34367
|
}
|
|
34171
34368
|
}
|
|
34172
34369
|
function readRuntimeLogWatcherPidState(pidFile) {
|
|
34173
|
-
const raw =
|
|
34370
|
+
const raw = fs12.readFileSync(pidFile, "utf8").trim();
|
|
34174
34371
|
if (!raw) {
|
|
34175
34372
|
return null;
|
|
34176
34373
|
}
|
|
@@ -34186,7 +34383,7 @@ function readRuntimeLogWatcherPidState(pidFile) {
|
|
|
34186
34383
|
}
|
|
34187
34384
|
}
|
|
34188
34385
|
function writeRuntimeLogWatcherPidFile(pidFile, state) {
|
|
34189
|
-
|
|
34386
|
+
fs12.writeFileSync(pidFile, `${JSON.stringify(state, null, 2)}
|
|
34190
34387
|
`, "utf8");
|
|
34191
34388
|
}
|
|
34192
34389
|
function getProcessCommand(pid) {
|
|
@@ -34272,10 +34469,10 @@ function formatRuntimeLogWatchCommand(buildResult) {
|
|
|
34272
34469
|
};
|
|
34273
34470
|
}
|
|
34274
34471
|
function resolveMakerCliEntry() {
|
|
34275
|
-
return process.argv[1] ||
|
|
34472
|
+
return process.argv[1] || path13.resolve(process.cwd(), "dist", "maker.js");
|
|
34276
34473
|
}
|
|
34277
34474
|
function getRuntimeLogFilePath(projectRoot) {
|
|
34278
|
-
return
|
|
34475
|
+
return path13.join(projectRoot, ".maker", "logs", "runtime", "runtime.log");
|
|
34279
34476
|
}
|
|
34280
34477
|
async function refreshMakerPreview(buildResult) {
|
|
34281
34478
|
const makerEnv = buildResult.env === "rnd" || buildResult.env === "production" ? buildResult.env : void 0;
|
|
@@ -34326,12 +34523,14 @@ async function refreshMakerPreview(buildResult) {
|
|
|
34326
34523
|
}
|
|
34327
34524
|
function createRemoteRuntimeLogClient(proxy, timeoutMs = 60 * 1e3, options = {}) {
|
|
34328
34525
|
let client;
|
|
34329
|
-
const createTransport = options.createTransport || (() =>
|
|
34330
|
-
|
|
34331
|
-
|
|
34332
|
-
|
|
34333
|
-
|
|
34334
|
-
|
|
34526
|
+
const createTransport = options.createTransport || (() => trackMakerChildTransport(
|
|
34527
|
+
new HiddenStdioClientTransport({
|
|
34528
|
+
command: proxy.command,
|
|
34529
|
+
args: proxy.args,
|
|
34530
|
+
env: mergeStringEnv(process.env, proxy.envVars),
|
|
34531
|
+
stderr: "pipe"
|
|
34532
|
+
})
|
|
34533
|
+
));
|
|
34335
34534
|
const createClient = options.createClient || (() => new Client(
|
|
34336
34535
|
{
|
|
34337
34536
|
name: "taptap-maker-runtime-log-forwarder",
|
|
@@ -34406,7 +34605,7 @@ function createBuildArgs(projectRoot, options) {
|
|
|
34406
34605
|
if (options.scriptsPath) {
|
|
34407
34606
|
buildArgs.scriptsPath = options.scriptsPath;
|
|
34408
34607
|
}
|
|
34409
|
-
if (!options.entry && !options.scriptsPath && !options.entryClient && !options.entryServer && !options.multiplayer &&
|
|
34608
|
+
if (!options.entry && !options.scriptsPath && !options.entryClient && !options.entryServer && !options.multiplayer && fs12.existsSync(path13.join(projectRoot, "scripts", "main.lua"))) {
|
|
34410
34609
|
buildArgs.entry = "main.lua";
|
|
34411
34610
|
buildArgs.scriptsPath = "scripts";
|
|
34412
34611
|
}
|
|
@@ -34418,7 +34617,7 @@ function createBuildArgs(projectRoot, options) {
|
|
|
34418
34617
|
}
|
|
34419
34618
|
if (options.multiplayer) {
|
|
34420
34619
|
buildArgs.multiplayer = options.multiplayer;
|
|
34421
|
-
} else if (!
|
|
34620
|
+
} else if (!fs12.existsSync(path13.join(projectRoot, ".project", "settings.json"))) {
|
|
34422
34621
|
buildArgs.multiplayer = { enabled: false };
|
|
34423
34622
|
}
|
|
34424
34623
|
return buildArgs;
|
|
@@ -34593,11 +34792,11 @@ function formatRuntimeLogWatchNextActionLines(result) {
|
|
|
34593
34792
|
((_a3 = result.runtimeLogWatch) == null ? void 0 : _a3.pid) ? `- watch_pid: ${result.runtimeLogWatch.pid}` : "",
|
|
34594
34793
|
`- watch_command: ${command}`,
|
|
34595
34794
|
((_b = result.runtimeLogWatch) == null ? void 0 : _b.command) ? `- actual_watch_command: ${result.runtimeLogWatch.command}` : "",
|
|
34596
|
-
`- local_file: ${
|
|
34795
|
+
`- local_file: ${path13.join(result.projectRoot, ".maker", "logs", "runtime", "runtime.log")}`,
|
|
34597
34796
|
((_c = result.runtimeLogWatch) == null ? void 0 : _c.stdoutLog) ? `- watcher_stdout: ${result.runtimeLogWatch.stdoutLog}` : "",
|
|
34598
34797
|
((_d = result.runtimeLogWatch) == null ? void 0 : _d.stderrLog) ? `- watcher_stderr: ${result.runtimeLogWatch.stderrLog}` : "",
|
|
34599
34798
|
((_e = result.runtimeLogWatch) == null ? void 0 : _e.pidFile) ? `- watcher_pid_file: ${result.runtimeLogWatch.pidFile}` : "",
|
|
34600
|
-
`- state_file: ${
|
|
34799
|
+
`- state_file: ${path13.join(result.projectRoot, ".maker", "logs", "runtime", "state.json")}`,
|
|
34601
34800
|
((_f = result.runtimeLogWatch) == null ? void 0 : _f.previousPid) ? `- previous_watch_pid: ${result.runtimeLogWatch.previousPid}` : "",
|
|
34602
34801
|
((_g = result.runtimeLogWatch) == null ? void 0 : _g.previousStopped) !== void 0 ? `- previous_watch_stopped: ${result.runtimeLogWatch.previousStopped ? "yes" : "no"}` : "",
|
|
34603
34802
|
((_h = result.runtimeLogWatch) == null ? void 0 : _h.previousStopError) ? `- previous_watch_stop_error: ${result.runtimeLogWatch.previousStopError}` : "",
|
|
@@ -34714,9 +34913,9 @@ function indent(value) {
|
|
|
34714
34913
|
// src/maker/cli/commands.ts
|
|
34715
34914
|
import { spawnSync as spawnSync8 } from "node:child_process";
|
|
34716
34915
|
import crypto2 from "node:crypto";
|
|
34717
|
-
import
|
|
34916
|
+
import fs13 from "node:fs";
|
|
34718
34917
|
import os4 from "node:os";
|
|
34719
|
-
import
|
|
34918
|
+
import path14 from "node:path";
|
|
34720
34919
|
import readline from "node:readline/promises";
|
|
34721
34920
|
import { stdin as input, stdout as output } from "node:process";
|
|
34722
34921
|
|
|
@@ -34983,7 +35182,7 @@ function toOptionKey(value) {
|
|
|
34983
35182
|
}
|
|
34984
35183
|
async function runInit(parsed, ctx) {
|
|
34985
35184
|
rejectPackageOption(parsed);
|
|
34986
|
-
const targetDir =
|
|
35185
|
+
const targetDir = path14.resolve(stringOption(parsed, "target_dir") || process.cwd());
|
|
34987
35186
|
const env = makerEnvOption(parsed);
|
|
34988
35187
|
const skipConfirm = booleanOption(parsed, "skip_confirm");
|
|
34989
35188
|
const skipMcpInstall = booleanOption(parsed, "skip_mcp_install");
|
|
@@ -35076,7 +35275,7 @@ async function runInit(parsed, ctx) {
|
|
|
35076
35275
|
}
|
|
35077
35276
|
async function runDoctor(parsed, ctx) {
|
|
35078
35277
|
var _a3, _b;
|
|
35079
|
-
const targetDir =
|
|
35278
|
+
const targetDir = path14.resolve(stringOption(parsed, "target_dir") || process.cwd());
|
|
35080
35279
|
const env = makerEnvOption(parsed);
|
|
35081
35280
|
const git = checkGitEnvironment();
|
|
35082
35281
|
const python = checkMakerPythonEnvironment();
|
|
@@ -35088,6 +35287,10 @@ async function runDoctor(parsed, ctx) {
|
|
|
35088
35287
|
const projectRoot = identify.projectRoot || targetDir;
|
|
35089
35288
|
const devKit = inspectAiDevKit(projectRoot);
|
|
35090
35289
|
const devKitUpdate = await checkAiDevKitUpdate(projectRoot, { environment: env });
|
|
35290
|
+
const orphanProcessCheck = inspectMakerOrphanProcesses();
|
|
35291
|
+
const mcpToolsAvailability = inspectMakerMcpToolsAvailability({
|
|
35292
|
+
makerProjectDir: identify.projectRoot
|
|
35293
|
+
});
|
|
35091
35294
|
if (ctx.json) {
|
|
35092
35295
|
writeJson({
|
|
35093
35296
|
env,
|
|
@@ -35100,7 +35303,9 @@ async function runDoctor(parsed, ctx) {
|
|
|
35100
35303
|
lua_lsp: luaLsp,
|
|
35101
35304
|
project: identify,
|
|
35102
35305
|
dev_kit: devKit,
|
|
35103
|
-
dev_kit_update: devKitUpdate
|
|
35306
|
+
dev_kit_update: devKitUpdate,
|
|
35307
|
+
mcp_tools_availability: mcpToolsAvailability,
|
|
35308
|
+
orphan_process_check: orphanProcessCheck
|
|
35104
35309
|
});
|
|
35105
35310
|
return;
|
|
35106
35311
|
}
|
|
@@ -35134,11 +35339,118 @@ async function runDoctor(parsed, ctx) {
|
|
|
35134
35339
|
`- update_available: ${devKitUpdate.updateAvailable ? "yes" : "no"}`,
|
|
35135
35340
|
devKitUpdate.versionCheckError ? `- version_check: ${devKitUpdate.versionCheckError}` : "",
|
|
35136
35341
|
"",
|
|
35342
|
+
formatMakerMcpToolsAvailability(mcpToolsAvailability),
|
|
35343
|
+
"",
|
|
35344
|
+
formatMakerOrphanProcessStatus(orphanProcessCheck),
|
|
35345
|
+
"",
|
|
35137
35346
|
formatMakerSkillStatus({ projectRoot }),
|
|
35138
35347
|
""
|
|
35139
35348
|
].filter(Boolean).join("\n")
|
|
35140
35349
|
);
|
|
35141
35350
|
}
|
|
35351
|
+
function inspectMakerMcpToolsAvailability(options) {
|
|
35352
|
+
const aiPwd = path14.resolve(process.cwd());
|
|
35353
|
+
const aiPwdIdentify = identifyMakerProject({ cwd: aiPwd });
|
|
35354
|
+
const makerProjectDir = options.makerProjectDir ? path14.resolve(options.makerProjectDir) : void 0;
|
|
35355
|
+
if (!makerProjectDir) {
|
|
35356
|
+
return {
|
|
35357
|
+
tools_visibility: "refresh_ai_client_if_missing",
|
|
35358
|
+
pwd_alignment: "not_bound",
|
|
35359
|
+
ai_pwd: aiPwd,
|
|
35360
|
+
ai_pwd_project_dir: aiPwdIdentify.projectRoot
|
|
35361
|
+
};
|
|
35362
|
+
}
|
|
35363
|
+
return {
|
|
35364
|
+
tools_visibility: "refresh_ai_client_if_missing",
|
|
35365
|
+
pwd_alignment: aiPwdIdentify.projectRoot && samePath2(aiPwdIdentify.projectRoot, makerProjectDir) ? "same_project" : "cwd_mismatch",
|
|
35366
|
+
maker_project_dir: makerProjectDir,
|
|
35367
|
+
ai_pwd: aiPwd,
|
|
35368
|
+
ai_pwd_project_dir: aiPwdIdentify.projectRoot
|
|
35369
|
+
};
|
|
35370
|
+
}
|
|
35371
|
+
function formatMakerMcpToolsAvailability(availability) {
|
|
35372
|
+
const lines = [
|
|
35373
|
+
"Maker MCP tools availability",
|
|
35374
|
+
`- tools_visibility: ${availability.tools_visibility}`,
|
|
35375
|
+
"- hint: If Maker proxy tools are missing in this AI chat, this is common after install.",
|
|
35376
|
+
"- next_action: Restart the AI client or open a new AI conversation; /mcp clients can Reconnect taptap-maker.",
|
|
35377
|
+
`- pwd_alignment: ${availability.pwd_alignment}`
|
|
35378
|
+
];
|
|
35379
|
+
if (availability.pwd_alignment === "cwd_mismatch") {
|
|
35380
|
+
lines.push(`- maker_project_dir: ${availability.maker_project_dir}`);
|
|
35381
|
+
lines.push(`- ai_pwd: ${availability.ai_pwd}`);
|
|
35382
|
+
lines.push(`- ai_pwd_project_dir: ${availability.ai_pwd_project_dir || "(none)"}`);
|
|
35383
|
+
lines.push(
|
|
35384
|
+
"- impact: Maker proxy tools may not appear because tools/list uses the AI client pwd."
|
|
35385
|
+
);
|
|
35386
|
+
lines.push(
|
|
35387
|
+
"- next_action: Run the AI client from the Maker project directory, or reinstall MCP with --target-dir."
|
|
35388
|
+
);
|
|
35389
|
+
}
|
|
35390
|
+
return lines.join("\n");
|
|
35391
|
+
}
|
|
35392
|
+
function samePath2(left, right) {
|
|
35393
|
+
return normalizePathForCompare2(left) === normalizePathForCompare2(right);
|
|
35394
|
+
}
|
|
35395
|
+
function normalizePathForCompare2(value) {
|
|
35396
|
+
const resolved = path14.resolve(value);
|
|
35397
|
+
try {
|
|
35398
|
+
return fs13.realpathSync.native(resolved);
|
|
35399
|
+
} catch {
|
|
35400
|
+
return resolved;
|
|
35401
|
+
}
|
|
35402
|
+
}
|
|
35403
|
+
function inspectMakerOrphanProcesses() {
|
|
35404
|
+
if (process.platform === "win32") {
|
|
35405
|
+
return { status: "not_supported_on_windows", processes: [] };
|
|
35406
|
+
}
|
|
35407
|
+
const result = spawnSync8("ps", ["-axo", "pid,ppid,pcpu,etime,command"], {
|
|
35408
|
+
encoding: "utf8"
|
|
35409
|
+
});
|
|
35410
|
+
if (result.status !== 0 || typeof result.stdout !== "string") {
|
|
35411
|
+
return { status: "check_failed", processes: [] };
|
|
35412
|
+
}
|
|
35413
|
+
const processes = result.stdout.split(/\r?\n/).slice(1).map((line) => parseMakerProcessLine(line)).filter((processInfo) => Boolean(processInfo));
|
|
35414
|
+
return { status: "ok", processes };
|
|
35415
|
+
}
|
|
35416
|
+
function parseMakerProcessLine(line) {
|
|
35417
|
+
const match = line.trim().match(/^(\d+)\s+(\d+)\s+([0-9.]+)\s+(\S+)\s+(.+)$/);
|
|
35418
|
+
if (!match) {
|
|
35419
|
+
return null;
|
|
35420
|
+
}
|
|
35421
|
+
const [, pid, ppid, cpu, elapsed, command] = match;
|
|
35422
|
+
if (ppid !== "1") {
|
|
35423
|
+
return null;
|
|
35424
|
+
}
|
|
35425
|
+
if (/\blogs\b.*\bwatch\b/.test(command)) {
|
|
35426
|
+
return null;
|
|
35427
|
+
}
|
|
35428
|
+
if (!/\bmaker\.js\b/.test(command) && !/\btaptap-maker\b/.test(command)) {
|
|
35429
|
+
return null;
|
|
35430
|
+
}
|
|
35431
|
+
return { pid, ppid, cpu, elapsed, command };
|
|
35432
|
+
}
|
|
35433
|
+
function formatMakerOrphanProcessStatus(check2) {
|
|
35434
|
+
const lines = ["Maker orphan process check"];
|
|
35435
|
+
if (check2.status === "not_supported_on_windows") {
|
|
35436
|
+
return [...lines, "- orphan_processes: not_supported_on_windows"].join("\n");
|
|
35437
|
+
}
|
|
35438
|
+
if (check2.status === "check_failed") {
|
|
35439
|
+
return [...lines, "- orphan_processes: check_failed"].join("\n");
|
|
35440
|
+
}
|
|
35441
|
+
if (check2.processes.length === 0) {
|
|
35442
|
+
return [...lines, "- orphan_processes: none"].join("\n");
|
|
35443
|
+
}
|
|
35444
|
+
for (const processInfo of check2.processes) {
|
|
35445
|
+
lines.push(
|
|
35446
|
+
`- pid: ${processInfo.pid} ppid: ${processInfo.ppid} cpu: ${processInfo.cpu} elapsed: ${processInfo.elapsed}`
|
|
35447
|
+
);
|
|
35448
|
+
lines.push(` command: ${processInfo.command}`);
|
|
35449
|
+
}
|
|
35450
|
+
lines.push("- action: safe_to_kill_orphan_maker_processes");
|
|
35451
|
+
lines.push("- note: these PPID=1 Maker processes are detached from the AI client.");
|
|
35452
|
+
return lines.join("\n");
|
|
35453
|
+
}
|
|
35142
35454
|
function ensureInitPythonReady(ctx, targetDir, env) {
|
|
35143
35455
|
const initial = checkMakerPythonEnvironment();
|
|
35144
35456
|
if (initial.ready) {
|
|
@@ -35401,7 +35713,7 @@ async function runPatSet(parsed, ctx) {
|
|
|
35401
35713
|
}
|
|
35402
35714
|
async function resolvePatSet(parsed, ctx) {
|
|
35403
35715
|
if (booleanOption(parsed, "pat_stdin") || booleanOption(parsed, "pat_from_stdin")) {
|
|
35404
|
-
const pat =
|
|
35716
|
+
const pat = fs13.readFileSync(0, "utf8").trim();
|
|
35405
35717
|
if (!pat) {
|
|
35406
35718
|
throw new Error("No PAT found on stdin.");
|
|
35407
35719
|
}
|
|
@@ -35431,7 +35743,7 @@ async function runMcpInstall(parsed, ctx) {
|
|
|
35431
35743
|
env: makerEnvOption(parsed),
|
|
35432
35744
|
pkg: MAKER_NPM_PACKAGE,
|
|
35433
35745
|
mcpName: stringOption(parsed, "name") || DEFAULT_MCP_NAME,
|
|
35434
|
-
cwd: explicitTargetDir ?
|
|
35746
|
+
cwd: explicitTargetDir ? path14.resolve(explicitTargetDir) : void 0
|
|
35435
35747
|
});
|
|
35436
35748
|
if (ctx.json) {
|
|
35437
35749
|
writeJson(results);
|
|
@@ -35534,7 +35846,7 @@ function getMcpVerifyNextSteps(mode, commandText) {
|
|
|
35534
35846
|
];
|
|
35535
35847
|
}
|
|
35536
35848
|
async function runDevKitUpdate(parsed, ctx) {
|
|
35537
|
-
const targetDir =
|
|
35849
|
+
const targetDir = path14.resolve(stringOption(parsed, "target_dir") || process.cwd());
|
|
35538
35850
|
const result = await installAiDevKit({
|
|
35539
35851
|
targetDir,
|
|
35540
35852
|
preserveExisting: false,
|
|
@@ -35546,7 +35858,7 @@ async function runDevKitUpdate(parsed, ctx) {
|
|
|
35546
35858
|
emitDevKitSkillInstallerFailure(ctx, result.skillInstaller, "AI skills install failed");
|
|
35547
35859
|
}
|
|
35548
35860
|
async function runLogsWatch(parsed, ctx) {
|
|
35549
|
-
const targetDir =
|
|
35861
|
+
const targetDir = path14.resolve(stringOption(parsed, "target_dir") || process.cwd());
|
|
35550
35862
|
const intervalMs = parseDurationMs(stringOption(parsed, "interval") || "5s");
|
|
35551
35863
|
const timeoutMs = numberOption(parsed, "timeout_ms") ?? 60 * 1e3;
|
|
35552
35864
|
const maxPolls = numberOption(parsed, "max_polls");
|
|
@@ -35556,9 +35868,9 @@ async function runLogsWatch(parsed, ctx) {
|
|
|
35556
35868
|
serverUrl: stringOption(parsed, "server_url"),
|
|
35557
35869
|
env: makerEnvOption(parsed)
|
|
35558
35870
|
});
|
|
35559
|
-
const runtimeDir =
|
|
35560
|
-
const runtimeLog =
|
|
35561
|
-
const pidFile =
|
|
35871
|
+
const runtimeDir = path14.join(proxy.projectRoot, ".maker", "logs", "runtime");
|
|
35872
|
+
const runtimeLog = path14.join(runtimeDir, "runtime.log");
|
|
35873
|
+
const pidFile = path14.join(runtimeDir, "watcher.pid");
|
|
35562
35874
|
const replacedWatcher = registerRuntimeLogWatcherProcess(pidFile);
|
|
35563
35875
|
const runtimeLogClient = createRemoteRuntimeLogClient(proxy, timeoutMs);
|
|
35564
35876
|
emit(ctx, "logs_watch_start", "Maker runtime log watcher started", {
|
|
@@ -35603,10 +35915,10 @@ async function runLogsWatch(parsed, ctx) {
|
|
|
35603
35915
|
}
|
|
35604
35916
|
}
|
|
35605
35917
|
function registerRuntimeLogWatcherProcess(pidFile) {
|
|
35606
|
-
|
|
35918
|
+
fs13.mkdirSync(path14.dirname(pidFile), { recursive: true });
|
|
35607
35919
|
const existingPid = readPidFile(pidFile);
|
|
35608
35920
|
const previous = existingPid && existingPid !== process.pid ? stopExistingRuntimeLogWatcher(pidFile) : {};
|
|
35609
|
-
|
|
35921
|
+
fs13.writeFileSync(
|
|
35610
35922
|
pidFile,
|
|
35611
35923
|
`${JSON.stringify(
|
|
35612
35924
|
{
|
|
@@ -35624,10 +35936,10 @@ function registerRuntimeLogWatcherProcess(pidFile) {
|
|
|
35624
35936
|
return previous;
|
|
35625
35937
|
}
|
|
35626
35938
|
function readPidFile(pidFile) {
|
|
35627
|
-
if (!
|
|
35939
|
+
if (!fs13.existsSync(pidFile)) {
|
|
35628
35940
|
return void 0;
|
|
35629
35941
|
}
|
|
35630
|
-
const raw =
|
|
35942
|
+
const raw = fs13.readFileSync(pidFile, "utf8").trim();
|
|
35631
35943
|
let pid = Number(raw);
|
|
35632
35944
|
if (!Number.isInteger(pid) || pid <= 0) {
|
|
35633
35945
|
try {
|
|
@@ -35647,7 +35959,7 @@ function installRuntimeLogWatcherPidCleanup(pidFile) {
|
|
|
35647
35959
|
}
|
|
35648
35960
|
cleaned = true;
|
|
35649
35961
|
if (readPidFile(pidFile) === process.pid) {
|
|
35650
|
-
|
|
35962
|
+
fs13.rmSync(pidFile, { force: true });
|
|
35651
35963
|
}
|
|
35652
35964
|
};
|
|
35653
35965
|
process.once("exit", cleanup);
|
|
@@ -35756,7 +36068,7 @@ async function prepareDevKit(targetDir, ctx, options = {}) {
|
|
|
35756
36068
|
onStart: (event) => emitSkillInstallerStart(ctx, event)
|
|
35757
36069
|
});
|
|
35758
36070
|
writeDevKitStagedGitignore(
|
|
35759
|
-
|
|
36071
|
+
path14.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE),
|
|
35760
36072
|
listPresentDevKitManagedEntries(targetDir)
|
|
35761
36073
|
);
|
|
35762
36074
|
if (options.finalizeGitignore) {
|
|
@@ -35773,7 +36085,7 @@ async function prepareDevKit(targetDir, ctx, options = {}) {
|
|
|
35773
36085
|
);
|
|
35774
36086
|
} catch (error2) {
|
|
35775
36087
|
writeDevKitStagedGitignore(
|
|
35776
|
-
|
|
36088
|
+
path14.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE),
|
|
35777
36089
|
listPresentDevKitManagedEntries(targetDir)
|
|
35778
36090
|
);
|
|
35779
36091
|
if (options.finalizeGitignore) {
|
|
@@ -35861,7 +36173,7 @@ function installMcpConfig(ide, options) {
|
|
|
35861
36173
|
}
|
|
35862
36174
|
function installMcpConfigUnsafe(ide, options) {
|
|
35863
36175
|
if (ide === "codex") {
|
|
35864
|
-
const configPath =
|
|
36176
|
+
const configPath = path14.join(os4.homedir(), ".codex", "config.toml");
|
|
35865
36177
|
mergeCodexMcpConfig(configPath, options);
|
|
35866
36178
|
return {
|
|
35867
36179
|
ide,
|
|
@@ -35871,7 +36183,7 @@ function installMcpConfigUnsafe(ide, options) {
|
|
|
35871
36183
|
};
|
|
35872
36184
|
}
|
|
35873
36185
|
if (ide === "cursor") {
|
|
35874
|
-
const configPath =
|
|
36186
|
+
const configPath = path14.join(os4.homedir(), ".cursor", "mcp.json");
|
|
35875
36187
|
mergeJsonMcpConfig(configPath, options);
|
|
35876
36188
|
return {
|
|
35877
36189
|
ide,
|
|
@@ -35887,7 +36199,7 @@ function installMcpConfigUnsafe(ide, options) {
|
|
|
35887
36199
|
return { ide, ok: true, message: "✓ Claude Code MCP config updated with claude mcp add" };
|
|
35888
36200
|
}
|
|
35889
36201
|
}
|
|
35890
|
-
const configPath =
|
|
36202
|
+
const configPath = path14.join(os4.homedir(), ".claude.json");
|
|
35891
36203
|
mergeJsonMcpConfig(configPath, options);
|
|
35892
36204
|
return {
|
|
35893
36205
|
ide,
|
|
@@ -35904,13 +36216,13 @@ function mergeJsonMcpConfig(configPath, options) {
|
|
|
35904
36216
|
const mcpServers = asObject(existing.mcpServers);
|
|
35905
36217
|
mcpServers[options.mcpName] = createJsonMcpServerConfig(options);
|
|
35906
36218
|
existing.mcpServers = mcpServers;
|
|
35907
|
-
|
|
35908
|
-
|
|
36219
|
+
fs13.mkdirSync(path14.dirname(configPath), { recursive: true });
|
|
36220
|
+
fs13.writeFileSync(configPath, `${JSON.stringify(existing, null, 2)}
|
|
35909
36221
|
`, "utf8");
|
|
35910
36222
|
}
|
|
35911
36223
|
function mergeCodexMcpConfig(configPath, options) {
|
|
35912
36224
|
const backupPath = backupIfExists(configPath);
|
|
35913
|
-
const existing =
|
|
36225
|
+
const existing = fs13.existsSync(configPath) ? fs13.readFileSync(configPath, "utf8") : "";
|
|
35914
36226
|
const sectionPattern = createCodexMcpSectionPattern(options.mcpName);
|
|
35915
36227
|
const withoutOld = existing.replace(sectionPattern, "").trimEnd();
|
|
35916
36228
|
const launch = getNpxCliCommand(options.pkg);
|
|
@@ -35924,9 +36236,9 @@ function mergeCodexMcpConfig(configPath, options) {
|
|
|
35924
36236
|
`TAPTAP_MCP_ENV = "${options.env}"`,
|
|
35925
36237
|
""
|
|
35926
36238
|
].join("\n");
|
|
35927
|
-
|
|
35928
|
-
|
|
35929
|
-
const updated =
|
|
36239
|
+
fs13.mkdirSync(path14.dirname(configPath), { recursive: true });
|
|
36240
|
+
fs13.writeFileSync(configPath, [withoutOld, section].filter(Boolean).join("\n\n"), "utf8");
|
|
36241
|
+
const updated = fs13.readFileSync(configPath, "utf8");
|
|
35930
36242
|
const duplicates = findCodexMcpTableDuplicates(updated, options.mcpName);
|
|
35931
36243
|
if (duplicates.length > 0) {
|
|
35932
36244
|
restoreBackup(configPath, backupPath);
|
|
@@ -36043,10 +36355,10 @@ function rejectPackageOption(parsed) {
|
|
|
36043
36355
|
}
|
|
36044
36356
|
}
|
|
36045
36357
|
function readJsonObject(filePath) {
|
|
36046
|
-
if (!
|
|
36358
|
+
if (!fs13.existsSync(filePath)) {
|
|
36047
36359
|
return {};
|
|
36048
36360
|
}
|
|
36049
|
-
return JSON.parse(
|
|
36361
|
+
return JSON.parse(fs13.readFileSync(filePath, "utf8"));
|
|
36050
36362
|
}
|
|
36051
36363
|
function asObject(value) {
|
|
36052
36364
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
@@ -36055,26 +36367,26 @@ function asObject(value) {
|
|
|
36055
36367
|
return {};
|
|
36056
36368
|
}
|
|
36057
36369
|
function backupIfExists(filePath) {
|
|
36058
|
-
if (!
|
|
36370
|
+
if (!fs13.existsSync(filePath)) {
|
|
36059
36371
|
return void 0;
|
|
36060
36372
|
}
|
|
36061
36373
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:]/g, "").replace(/\..+$/, "");
|
|
36062
36374
|
const backupPath = `${filePath}.bak.${stamp}`;
|
|
36063
|
-
|
|
36375
|
+
fs13.copyFileSync(filePath, backupPath);
|
|
36064
36376
|
return backupPath;
|
|
36065
36377
|
}
|
|
36066
36378
|
function restoreBackup(filePath, backupPath) {
|
|
36067
36379
|
if (backupPath) {
|
|
36068
|
-
|
|
36380
|
+
fs13.copyFileSync(backupPath, filePath);
|
|
36069
36381
|
return;
|
|
36070
36382
|
}
|
|
36071
|
-
|
|
36383
|
+
fs13.rmSync(filePath, { force: true });
|
|
36072
36384
|
}
|
|
36073
36385
|
function saveInitState(targetDir, state) {
|
|
36074
|
-
|
|
36075
|
-
const key = crypto2.createHash("sha256").update(
|
|
36076
|
-
|
|
36077
|
-
|
|
36386
|
+
fs13.mkdirSync(getMakerHome(), { recursive: true });
|
|
36387
|
+
const key = crypto2.createHash("sha256").update(path14.resolve(targetDir)).digest("hex").slice(0, 16);
|
|
36388
|
+
fs13.writeFileSync(
|
|
36389
|
+
path14.join(getMakerHome(), `init-state-${key}.json`),
|
|
36078
36390
|
`${JSON.stringify({ ...state, updated_at: (/* @__PURE__ */ new Date()).toISOString() }, null, 2)}
|
|
36079
36391
|
`,
|
|
36080
36392
|
"utf8"
|
|
@@ -36210,7 +36522,7 @@ function makerEnvOption(parsed) {
|
|
|
36210
36522
|
return env;
|
|
36211
36523
|
}
|
|
36212
36524
|
const targetDir = stringOption(parsed, "target_dir");
|
|
36213
|
-
return getMakerEnvironment(void 0, targetDir ?
|
|
36525
|
+
return getMakerEnvironment(void 0, targetDir ? path14.resolve(targetDir) : process.cwd());
|
|
36214
36526
|
}
|
|
36215
36527
|
function mcpVerifyModeOption(parsed) {
|
|
36216
36528
|
const mode = stringOption(parsed, "mode") || "npx";
|
|
@@ -36287,69 +36599,6 @@ function formatCliError(error2) {
|
|
|
36287
36599
|
return error2 instanceof Error ? error2.message : String(error2);
|
|
36288
36600
|
}
|
|
36289
36601
|
|
|
36290
|
-
// src/maker/crashLog.ts
|
|
36291
|
-
import fs13 from "node:fs";
|
|
36292
|
-
import path14 from "node:path";
|
|
36293
|
-
var DEFAULT_MAX_BYTES = 1024 * 1024;
|
|
36294
|
-
var DEFAULT_MAX_ENTRY_BYTES = 16 * 1024;
|
|
36295
|
-
function appendMakerCrashLog(source, error2, options = {}) {
|
|
36296
|
-
const makerHome = getMakerHome();
|
|
36297
|
-
fs13.mkdirSync(makerHome, { recursive: true });
|
|
36298
|
-
const logPath = path14.join(makerHome, "mcp-crash.log");
|
|
36299
|
-
const maxBytes = positiveInteger(options.maxBytes) || resolveEnvBytes("TAPTAP_MAKER_CRASH_LOG_MAX_BYTES", DEFAULT_MAX_BYTES);
|
|
36300
|
-
const maxEntryBytes = positiveInteger(options.maxEntryBytes) || resolveEnvBytes("TAPTAP_MAKER_CRASH_LOG_MAX_ENTRY_BYTES", DEFAULT_MAX_ENTRY_BYTES);
|
|
36301
|
-
const message = error2 instanceof Error ? error2.stack || error2.message : String(error2);
|
|
36302
|
-
const entry = truncateUtf8(
|
|
36303
|
-
[`[${(/* @__PURE__ */ new Date()).toISOString()}] ${source}`, message, ""].join("\n"),
|
|
36304
|
-
Math.min(maxEntryBytes, maxBytes)
|
|
36305
|
-
);
|
|
36306
|
-
const entryBytes = Buffer.byteLength(entry, "utf8");
|
|
36307
|
-
rotateIfNeeded(logPath, maxBytes, entryBytes);
|
|
36308
|
-
fs13.appendFileSync(logPath, entry, "utf8");
|
|
36309
|
-
}
|
|
36310
|
-
function rotateIfNeeded(logPath, maxBytes, incomingBytes) {
|
|
36311
|
-
if (!fs13.existsSync(logPath)) {
|
|
36312
|
-
return;
|
|
36313
|
-
}
|
|
36314
|
-
const currentBytes = fs13.statSync(logPath).size;
|
|
36315
|
-
if (currentBytes + incomingBytes <= maxBytes) {
|
|
36316
|
-
return;
|
|
36317
|
-
}
|
|
36318
|
-
const rotatedPath = `${logPath}.1`;
|
|
36319
|
-
writeFileTail(logPath, rotatedPath, maxBytes);
|
|
36320
|
-
fs13.writeFileSync(logPath, "", "utf8");
|
|
36321
|
-
}
|
|
36322
|
-
function writeFileTail(sourcePath, targetPath, maxBytes) {
|
|
36323
|
-
const size = fs13.statSync(sourcePath).size;
|
|
36324
|
-
const bytesToRead = Math.min(size, maxBytes);
|
|
36325
|
-
const start = Math.max(0, size - bytesToRead);
|
|
36326
|
-
const fd = fs13.openSync(sourcePath, "r");
|
|
36327
|
-
try {
|
|
36328
|
-
const buffer = Buffer.alloc(bytesToRead);
|
|
36329
|
-
fs13.readSync(fd, buffer, 0, bytesToRead, start);
|
|
36330
|
-
fs13.writeFileSync(targetPath, buffer);
|
|
36331
|
-
} finally {
|
|
36332
|
-
fs13.closeSync(fd);
|
|
36333
|
-
}
|
|
36334
|
-
}
|
|
36335
|
-
function truncateUtf8(value, maxBytes) {
|
|
36336
|
-
if (Buffer.byteLength(value, "utf8") <= maxBytes) {
|
|
36337
|
-
return value;
|
|
36338
|
-
}
|
|
36339
|
-
const suffix = `
|
|
36340
|
-
[truncated to ${maxBytes} bytes]
|
|
36341
|
-
`;
|
|
36342
|
-
const suffixBytes = Buffer.byteLength(suffix, "utf8");
|
|
36343
|
-
const prefixBytes = Math.max(0, maxBytes - suffixBytes);
|
|
36344
|
-
return `${Buffer.from(value, "utf8").subarray(0, prefixBytes).toString("utf8")}${suffix}`;
|
|
36345
|
-
}
|
|
36346
|
-
function resolveEnvBytes(key, fallback) {
|
|
36347
|
-
return positiveInteger(Number(process.env[key])) || fallback;
|
|
36348
|
-
}
|
|
36349
|
-
function positiveInteger(value) {
|
|
36350
|
-
return typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.floor(value) : void 0;
|
|
36351
|
-
}
|
|
36352
|
-
|
|
36353
36602
|
// src/mcp-proxy/config.ts
|
|
36354
36603
|
function readStdin() {
|
|
36355
36604
|
return new Promise((resolve, reject) => {
|
|
@@ -38279,6 +38528,8 @@ var LogWriter = class {
|
|
|
38279
38528
|
// src/mcp-proxy/proxy.ts
|
|
38280
38529
|
var VERSION2 = typeof __PROXY_VERSION__ !== "undefined" ? __PROXY_VERSION__ : "dev";
|
|
38281
38530
|
var LOCAL_PROXY_TAG = "local";
|
|
38531
|
+
var DEFAULT_RECONNECT_INTERVAL_MS = 5e3;
|
|
38532
|
+
var MAX_RECONNECT_INTERVAL_MS = 60 * 1e3;
|
|
38282
38533
|
var TapTapMCPProxy = class {
|
|
38283
38534
|
constructor(config2) {
|
|
38284
38535
|
this.connected = false;
|
|
@@ -38286,6 +38537,7 @@ var TapTapMCPProxy = class {
|
|
|
38286
38537
|
this.reconnectTimer = null;
|
|
38287
38538
|
this.healthCheckTimer = null;
|
|
38288
38539
|
this.pendingRequests = [];
|
|
38540
|
+
this.reconnectDelayMs = DEFAULT_RECONNECT_INTERVAL_MS;
|
|
38289
38541
|
// 会话验证相关
|
|
38290
38542
|
this.sessionValidated = false;
|
|
38291
38543
|
this.lastValidationTime = 0;
|
|
@@ -38294,15 +38546,15 @@ var TapTapMCPProxy = class {
|
|
|
38294
38546
|
this.config = config2;
|
|
38295
38547
|
this.cookieJar = new CookieJar(((_a3 = config2.options) == null ? void 0 : _a3.verbose) ?? false);
|
|
38296
38548
|
this.logWriter = this.createLogWriter();
|
|
38297
|
-
this.client =
|
|
38298
|
-
{ name: "taptap-proxy-client", version: "1.0.0" },
|
|
38299
|
-
{ capabilities: {} }
|
|
38300
|
-
);
|
|
38549
|
+
this.client = this.createClient();
|
|
38301
38550
|
this.server = new Server(
|
|
38302
38551
|
{ name: "taptap-proxy", version: "1.0.0" },
|
|
38303
38552
|
{ capabilities: { tools: {}, resources: {} } }
|
|
38304
38553
|
);
|
|
38305
38554
|
}
|
|
38555
|
+
createClient() {
|
|
38556
|
+
return new Client({ name: "taptap-proxy-client", version: "1.0.0" }, { capabilities: {} });
|
|
38557
|
+
}
|
|
38306
38558
|
/**
|
|
38307
38559
|
* 创建文件日志写入器
|
|
38308
38560
|
*/
|
|
@@ -38471,7 +38723,7 @@ var TapTapMCPProxy = class {
|
|
|
38471
38723
|
* 连接到 TapTap MCP Server
|
|
38472
38724
|
*/
|
|
38473
38725
|
async connectToServer() {
|
|
38474
|
-
var _a3, _b;
|
|
38726
|
+
var _a3, _b, _c;
|
|
38475
38727
|
this.log("info", `Connecting to ${this.config.server.url}...`);
|
|
38476
38728
|
try {
|
|
38477
38729
|
const cookieEnabled = ((_a3 = this.config.options) == null ? void 0 : _a3.enable_cookie_sticky) ?? true;
|
|
@@ -38492,6 +38744,7 @@ var TapTapMCPProxy = class {
|
|
|
38492
38744
|
this.connected = true;
|
|
38493
38745
|
this.sessionValidated = true;
|
|
38494
38746
|
this.lastValidationTime = Date.now();
|
|
38747
|
+
this.reconnectDelayMs = ((_c = this.config.options) == null ? void 0 : _c.reconnect_interval) ?? DEFAULT_RECONNECT_INTERVAL_MS;
|
|
38495
38748
|
this.log("info", "✅ Connected and session validated");
|
|
38496
38749
|
this.startHealthCheck();
|
|
38497
38750
|
if (this.reconnecting) {
|
|
@@ -38542,7 +38795,7 @@ var TapTapMCPProxy = class {
|
|
|
38542
38795
|
* 启动定期健康检查
|
|
38543
38796
|
*/
|
|
38544
38797
|
startHealthCheck() {
|
|
38545
|
-
var _a3;
|
|
38798
|
+
var _a3, _b, _c;
|
|
38546
38799
|
this.stopHealthCheck();
|
|
38547
38800
|
const interval = ((_a3 = this.config.options) == null ? void 0 : _a3.health_check_interval) ?? this.SESSION_VALIDATION_INTERVAL;
|
|
38548
38801
|
this.healthCheckTimer = setInterval(async () => {
|
|
@@ -38559,6 +38812,7 @@ var TapTapMCPProxy = class {
|
|
|
38559
38812
|
}
|
|
38560
38813
|
}
|
|
38561
38814
|
}, interval);
|
|
38815
|
+
(_c = (_b = this.healthCheckTimer).unref) == null ? void 0 : _c.call(_b);
|
|
38562
38816
|
this.log("debug", `Health check started (interval: ${interval}ms)`);
|
|
38563
38817
|
}
|
|
38564
38818
|
/**
|
|
@@ -38618,10 +38872,11 @@ var TapTapMCPProxy = class {
|
|
|
38618
38872
|
* 重连到 TapTap Server
|
|
38619
38873
|
*/
|
|
38620
38874
|
async reconnectToServer() {
|
|
38621
|
-
var _a3, _b
|
|
38875
|
+
var _a3, _b;
|
|
38622
38876
|
if (this.reconnecting) return;
|
|
38623
38877
|
this.reconnecting = true;
|
|
38624
38878
|
this.clearReconnectTimer();
|
|
38879
|
+
this.stopHealthCheck();
|
|
38625
38880
|
const cookieEnabled = ((_a3 = this.config.options) == null ? void 0 : _a3.enable_cookie_sticky) ?? true;
|
|
38626
38881
|
if (cookieEnabled && this.cookieJar.hasCookies) {
|
|
38627
38882
|
this.cookieJar.clear();
|
|
@@ -38630,14 +38885,12 @@ var TapTapMCPProxy = class {
|
|
|
38630
38885
|
}
|
|
38631
38886
|
}
|
|
38632
38887
|
try {
|
|
38633
|
-
this.client
|
|
38634
|
-
|
|
38635
|
-
{ capabilities: {} }
|
|
38636
|
-
);
|
|
38888
|
+
await this.closeClientSafely("reconnect-old-client");
|
|
38889
|
+
this.client = this.createClient();
|
|
38637
38890
|
await this.connectToServer();
|
|
38638
38891
|
this.log("info", "✅ Reconnected successfully");
|
|
38639
38892
|
} catch (error2) {
|
|
38640
|
-
const interval =
|
|
38893
|
+
const interval = this.reconnectDelayMs;
|
|
38641
38894
|
this.log("error", `❌ Reconnect failed: ${this.formatError(error2)}`);
|
|
38642
38895
|
this.log("info", `Will retry in ${interval / 1e3}s...`);
|
|
38643
38896
|
this.reconnecting = false;
|
|
@@ -38648,12 +38901,18 @@ var TapTapMCPProxy = class {
|
|
|
38648
38901
|
* 调度重连
|
|
38649
38902
|
*/
|
|
38650
38903
|
scheduleReconnect() {
|
|
38651
|
-
var _a3;
|
|
38904
|
+
var _a3, _b, _c;
|
|
38652
38905
|
this.clearReconnectTimer();
|
|
38653
|
-
const
|
|
38906
|
+
const configuredInterval = ((_a3 = this.config.options) == null ? void 0 : _a3.reconnect_interval) ?? DEFAULT_RECONNECT_INTERVAL_MS;
|
|
38907
|
+
const interval = this.reconnectDelayMs || configuredInterval;
|
|
38654
38908
|
this.reconnectTimer = setTimeout(() => {
|
|
38655
38909
|
this.reconnectToServer();
|
|
38656
38910
|
}, interval);
|
|
38911
|
+
(_c = (_b = this.reconnectTimer).unref) == null ? void 0 : _c.call(_b);
|
|
38912
|
+
this.reconnectDelayMs = Math.min(
|
|
38913
|
+
Math.max(interval * 2, configuredInterval),
|
|
38914
|
+
MAX_RECONNECT_INTERVAL_MS
|
|
38915
|
+
);
|
|
38657
38916
|
}
|
|
38658
38917
|
/**
|
|
38659
38918
|
* 清除重连定时器
|
|
@@ -38678,6 +38937,17 @@ var TapTapMCPProxy = class {
|
|
|
38678
38937
|
const req = this.pendingRequests.shift();
|
|
38679
38938
|
req.reject(timeout);
|
|
38680
38939
|
}
|
|
38940
|
+
void this.closeClientSafely("cleanup");
|
|
38941
|
+
}
|
|
38942
|
+
async closeClientSafely(source) {
|
|
38943
|
+
try {
|
|
38944
|
+
await this.client.close();
|
|
38945
|
+
} catch (error2) {
|
|
38946
|
+
this.log(
|
|
38947
|
+
"warning",
|
|
38948
|
+
`Failed to close proxy client during ${source}: ${this.formatError(error2)}`
|
|
38949
|
+
);
|
|
38950
|
+
}
|
|
38681
38951
|
}
|
|
38682
38952
|
/**
|
|
38683
38953
|
* 检测是否是需要重连的错误(网络错误或会话无效)
|
|
@@ -38933,12 +39203,15 @@ async function startEmbeddedProxy() {
|
|
|
38933
39203
|
const config2 = await loadConfig();
|
|
38934
39204
|
const proxy = new TapTapMCPProxy(config2);
|
|
38935
39205
|
await proxy.start();
|
|
38936
|
-
const cleanup = () => {
|
|
39206
|
+
const cleanup = (source = "proxy-signal") => {
|
|
39207
|
+
logLifecycleEvent(source, "Embedded Maker proxy received shutdown signal; exiting.");
|
|
38937
39208
|
proxy.cleanup();
|
|
38938
39209
|
process.exit(0);
|
|
38939
39210
|
};
|
|
38940
|
-
|
|
38941
|
-
|
|
39211
|
+
installProxyStdinExitHandler(proxy);
|
|
39212
|
+
installParentDeathWatchdog(proxy);
|
|
39213
|
+
process.on("SIGINT", () => cleanup("proxy-sigint"));
|
|
39214
|
+
process.on("SIGTERM", () => cleanup("proxy-sigterm"));
|
|
38942
39215
|
}
|
|
38943
39216
|
function printHelp2() {
|
|
38944
39217
|
process.stdout.write(
|
|
@@ -38978,24 +39251,65 @@ function printHelp2() {
|
|
|
38978
39251
|
}
|
|
38979
39252
|
main().catch((error2) => {
|
|
38980
39253
|
logCrash("main.catch", error2);
|
|
38981
|
-
|
|
39254
|
+
safeWriteStderr(`❌ ${formatCliError(error2)}
|
|
38982
39255
|
`);
|
|
38983
39256
|
process.exit(1);
|
|
38984
39257
|
});
|
|
38985
39258
|
function installCrashLogging() {
|
|
39259
|
+
installStdioErrorHandler(process.stdout, "stdout-error");
|
|
39260
|
+
installStdioErrorHandler(process.stderr, "stderr-error");
|
|
39261
|
+
let handlingFatalError = false;
|
|
38986
39262
|
process.on("uncaughtException", (error2) => {
|
|
38987
39263
|
logCrash("uncaughtException", error2);
|
|
38988
|
-
|
|
39264
|
+
if (isDisconnectedStdioError(error2)) {
|
|
39265
|
+
logLifecycleEvent("uncaughtException-stdio-closed", "Maker stdio disconnected; exiting.");
|
|
39266
|
+
process.exit(0);
|
|
39267
|
+
}
|
|
39268
|
+
if (handlingFatalError) {
|
|
39269
|
+
logCrash("uncaughtException-recursive", error2);
|
|
39270
|
+
process.exit(1);
|
|
39271
|
+
}
|
|
39272
|
+
handlingFatalError = true;
|
|
39273
|
+
safeWriteStderr(`❌ Uncaught Maker MCP error: ${error2.message}
|
|
38989
39274
|
`);
|
|
39275
|
+
handlingFatalError = false;
|
|
38990
39276
|
});
|
|
38991
39277
|
process.on("unhandledRejection", (reason) => {
|
|
38992
39278
|
logCrash("unhandledRejection", reason);
|
|
38993
|
-
|
|
39279
|
+
if (isDisconnectedStdioError(reason)) {
|
|
39280
|
+
logLifecycleEvent("unhandledRejection-stdio-closed", "Maker stdio disconnected; exiting.");
|
|
39281
|
+
process.exit(0);
|
|
39282
|
+
}
|
|
39283
|
+
if (handlingFatalError) {
|
|
39284
|
+
logCrash("unhandledRejection-recursive", reason);
|
|
39285
|
+
process.exit(1);
|
|
39286
|
+
}
|
|
39287
|
+
handlingFatalError = true;
|
|
39288
|
+
safeWriteStderr(
|
|
38994
39289
|
`❌ Unhandled Maker MCP rejection: ${reason instanceof Error ? reason.message : String(reason)}
|
|
38995
39290
|
`
|
|
38996
39291
|
);
|
|
39292
|
+
handlingFatalError = false;
|
|
39293
|
+
});
|
|
39294
|
+
}
|
|
39295
|
+
function installStdioErrorHandler(stream, source) {
|
|
39296
|
+
stream.on("error", (error2) => {
|
|
39297
|
+
logCrash(source, error2);
|
|
39298
|
+
if (isDisconnectedStdioError(error2)) {
|
|
39299
|
+
process.exit(0);
|
|
39300
|
+
}
|
|
38997
39301
|
});
|
|
38998
39302
|
}
|
|
39303
|
+
function safeWriteStderr(message) {
|
|
39304
|
+
try {
|
|
39305
|
+
process.stderr.write(message);
|
|
39306
|
+
} catch (error2) {
|
|
39307
|
+
logCrash("stderr-write-failed", error2);
|
|
39308
|
+
if (isDisconnectedStdioError(error2)) {
|
|
39309
|
+
process.exit(0);
|
|
39310
|
+
}
|
|
39311
|
+
}
|
|
39312
|
+
}
|
|
38999
39313
|
function logCrash(source, error2) {
|
|
39000
39314
|
try {
|
|
39001
39315
|
appendMakerCrashLog(source, error2);
|