@taptap/maker 0.0.17-beta.1 → 0.0.17-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/maker.js +709 -366
- 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,183 @@ 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([
|
|
28396
|
+
"EPIPE",
|
|
28397
|
+
"ERR_STREAM_DESTROYED",
|
|
28398
|
+
"ECONNRESET",
|
|
28399
|
+
"EIO",
|
|
28400
|
+
"ENXIO"
|
|
28401
|
+
]);
|
|
28402
|
+
function isDisconnectedStdioError(error2) {
|
|
28403
|
+
if (!error2 || typeof error2 !== "object") {
|
|
28404
|
+
return false;
|
|
28405
|
+
}
|
|
28406
|
+
const code = error2.code;
|
|
28407
|
+
if (typeof code === "string" && DISCONNECTED_STDIO_CODES.has(code)) {
|
|
28408
|
+
return true;
|
|
28409
|
+
}
|
|
28410
|
+
const message = error2 instanceof Error ? error2.message.toLowerCase() : "";
|
|
28411
|
+
return message.includes("epipe") || message.includes("stream destroyed");
|
|
28412
|
+
}
|
|
28413
|
+
function shouldExitForParentDeath(options) {
|
|
28414
|
+
if ((options.platform === "darwin" || options.platform === "linux") && options.initialPpid > 1 && options.currentPpid === 1) {
|
|
28415
|
+
return true;
|
|
28416
|
+
}
|
|
28417
|
+
try {
|
|
28418
|
+
options.probeParent();
|
|
28419
|
+
return false;
|
|
28420
|
+
} catch (error2) {
|
|
28421
|
+
return Boolean(
|
|
28422
|
+
error2 && typeof error2 === "object" && error2.code === "ESRCH" && options.initialPpid > 1
|
|
28423
|
+
);
|
|
28424
|
+
}
|
|
28425
|
+
}
|
|
28426
|
+
function installProxyStdinExitHandler(proxy, stdin = process.stdin, exit = (code) => process.exit(code)) {
|
|
28427
|
+
let exiting = false;
|
|
28428
|
+
const exitOnStdinClosed = () => {
|
|
28429
|
+
if (exiting) {
|
|
28430
|
+
return;
|
|
28431
|
+
}
|
|
28432
|
+
exiting = true;
|
|
28433
|
+
logLifecycleEvent("proxy-stdin-closed", "Embedded Maker proxy stdin closed; exiting.");
|
|
28434
|
+
proxy.cleanup();
|
|
28435
|
+
exit(0);
|
|
28436
|
+
};
|
|
28437
|
+
stdin.once("end", exitOnStdinClosed);
|
|
28438
|
+
stdin.once("close", exitOnStdinClosed);
|
|
28439
|
+
}
|
|
28440
|
+
function installParentDeathWatchdog(proxy, options = {}) {
|
|
28441
|
+
var _a3;
|
|
28442
|
+
const initialPpid = options.initialPpid ?? process.ppid;
|
|
28443
|
+
const getCurrentPpid = options.getCurrentPpid ?? (() => process.ppid);
|
|
28444
|
+
const exit = options.exit ?? ((code) => process.exit(code));
|
|
28445
|
+
let exiting = false;
|
|
28446
|
+
const timer = setInterval(() => {
|
|
28447
|
+
if (exiting) {
|
|
28448
|
+
return;
|
|
28449
|
+
}
|
|
28450
|
+
const shouldExit = shouldExitForParentDeath({
|
|
28451
|
+
initialPpid,
|
|
28452
|
+
currentPpid: getCurrentPpid(),
|
|
28453
|
+
platform: process.platform,
|
|
28454
|
+
probeParent: () => process.kill(initialPpid, 0)
|
|
28455
|
+
});
|
|
28456
|
+
if (!shouldExit) {
|
|
28457
|
+
return;
|
|
28458
|
+
}
|
|
28459
|
+
exiting = true;
|
|
28460
|
+
logLifecycleEvent("proxy-parent-dead", "Embedded Maker proxy parent process is gone; exiting.");
|
|
28461
|
+
proxy.cleanup();
|
|
28462
|
+
exit(0);
|
|
28463
|
+
}, options.intervalMs ?? 15e3);
|
|
28464
|
+
(_a3 = timer.unref) == null ? void 0 : _a3.call(timer);
|
|
28465
|
+
return timer;
|
|
28466
|
+
}
|
|
28467
|
+
function logLifecycleEvent(source, message) {
|
|
28468
|
+
try {
|
|
28469
|
+
appendMakerCrashLog(`lifecycle:${source}`, message);
|
|
28470
|
+
} catch {
|
|
28471
|
+
}
|
|
28472
|
+
}
|
|
28473
|
+
|
|
28308
28474
|
// src/maker/cli/projects.ts
|
|
28309
28475
|
import { spawn as spawn3, spawnSync as spawnSync3 } from "node:child_process";
|
|
28310
|
-
import
|
|
28311
|
-
import
|
|
28476
|
+
import fs6 from "node:fs";
|
|
28477
|
+
import path7 from "node:path";
|
|
28312
28478
|
|
|
28313
28479
|
// src/maker/config.ts
|
|
28314
|
-
import
|
|
28315
|
-
import
|
|
28480
|
+
import fs4 from "node:fs";
|
|
28481
|
+
import path5 from "node:path";
|
|
28316
28482
|
|
|
28317
28483
|
// src/core/utils/env.ts
|
|
28318
|
-
import * as
|
|
28484
|
+
import * as path4 from "node:path";
|
|
28319
28485
|
import * as os2 from "node:os";
|
|
28320
28486
|
import process5 from "node:process";
|
|
28321
28487
|
var ENVIRONMENT_ENDPOINTS = {
|
|
@@ -28411,11 +28577,11 @@ var EnvConfig = class {
|
|
|
28411
28577
|
// --------------------------------------------------------------------------
|
|
28412
28578
|
/** 缓存目录 */
|
|
28413
28579
|
static get cacheDir() {
|
|
28414
|
-
return getEnv("TAPTAP_MCP_CACHE_DIR",
|
|
28580
|
+
return getEnv("TAPTAP_MCP_CACHE_DIR", path4.join(os2.tmpdir(), "taptap-mcp", "cache"));
|
|
28415
28581
|
}
|
|
28416
28582
|
/** 临时文件目录 */
|
|
28417
28583
|
static get tempDir() {
|
|
28418
|
-
return getEnv("TAPTAP_MCP_TEMP_DIR",
|
|
28584
|
+
return getEnv("TAPTAP_MCP_TEMP_DIR", path4.join(os2.tmpdir(), "taptap-mcp", "temp"));
|
|
28419
28585
|
}
|
|
28420
28586
|
/** 工作区根目录 */
|
|
28421
28587
|
static get workspaceRoot() {
|
|
@@ -28556,7 +28722,7 @@ var MAKER_ENDPOINTS = {
|
|
|
28556
28722
|
remoteMcpServerUrl: "https://fuping.agnt.xd.com/mcp/v1"
|
|
28557
28723
|
}
|
|
28558
28724
|
};
|
|
28559
|
-
var MAKER_PROJECT_ENV_CONFIG_FILE =
|
|
28725
|
+
var MAKER_PROJECT_ENV_CONFIG_FILE = path5.join(".maker", "taptap-maker.local.json");
|
|
28560
28726
|
var makerEnvironmentOverride;
|
|
28561
28727
|
var MAKER_ENV_OVERRIDES = {
|
|
28562
28728
|
apiBase: {
|
|
@@ -28621,13 +28787,13 @@ function getMakerApiBaseUrl(environment) {
|
|
|
28621
28787
|
return requireMakerEndpoint("apiBase", endpoints.apiBase, environment).replace(/\/$/, "");
|
|
28622
28788
|
}
|
|
28623
28789
|
function getMakerProjectEnvironmentConfigPath(cwd = process.cwd()) {
|
|
28624
|
-
let current =
|
|
28790
|
+
let current = path5.resolve(cwd);
|
|
28625
28791
|
for (; ; ) {
|
|
28626
|
-
const candidate =
|
|
28627
|
-
if (
|
|
28792
|
+
const candidate = path5.join(current, MAKER_PROJECT_ENV_CONFIG_FILE);
|
|
28793
|
+
if (fs4.existsSync(candidate)) {
|
|
28628
28794
|
return candidate;
|
|
28629
28795
|
}
|
|
28630
|
-
const parent =
|
|
28796
|
+
const parent = path5.dirname(current);
|
|
28631
28797
|
if (parent === current) {
|
|
28632
28798
|
return void 0;
|
|
28633
28799
|
}
|
|
@@ -28658,7 +28824,7 @@ function getProjectLocalEnvironment(cwd) {
|
|
|
28658
28824
|
return void 0;
|
|
28659
28825
|
}
|
|
28660
28826
|
try {
|
|
28661
|
-
const raw =
|
|
28827
|
+
const raw = fs4.readFileSync(configPath, "utf8");
|
|
28662
28828
|
const data = JSON.parse(raw);
|
|
28663
28829
|
const env = data.env || data.environment;
|
|
28664
28830
|
return env === "rnd" || env === "production" ? env : void 0;
|
|
@@ -28924,9 +29090,9 @@ function formatGitMissingMessage(environment) {
|
|
|
28924
29090
|
|
|
28925
29091
|
// src/maker/cli/devKit.ts
|
|
28926
29092
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
28927
|
-
import
|
|
29093
|
+
import fs5 from "node:fs";
|
|
28928
29094
|
import os3 from "node:os";
|
|
28929
|
-
import
|
|
29095
|
+
import path6 from "node:path";
|
|
28930
29096
|
|
|
28931
29097
|
// src/maker/fetchTimeout.ts
|
|
28932
29098
|
var DEFAULT_SHORT_FETCH_TIMEOUT_MS = 10 * 1e3;
|
|
@@ -28957,7 +29123,7 @@ var AI_DEV_KIT_URLS = {
|
|
|
28957
29123
|
rnd: "https://urhox-demo-platform.spark.xd.com/ai-dev-kit/rnd/latest/ai-dev-kit.zip"
|
|
28958
29124
|
};
|
|
28959
29125
|
var DEFAULT_AI_DEV_KIT_URL = AI_DEV_KIT_URLS.production;
|
|
28960
|
-
var AI_DEV_KIT_VERSION_METADATA_FILE =
|
|
29126
|
+
var AI_DEV_KIT_VERSION_METADATA_FILE = path6.join(".maker", "ai-dev-kit-version.json");
|
|
28961
29127
|
var AI_DEV_KIT_DOWNLOAD_ENV = {
|
|
28962
29128
|
production: "pd",
|
|
28963
29129
|
rnd: "rnd"
|
|
@@ -28995,9 +29161,9 @@ var DEV_KIT_MANAGED_ENTRY_CANDIDATES = [
|
|
|
28995
29161
|
var SKIPPED_TOP_LEVEL_ENTRIES = /* @__PURE__ */ new Set(["scripts", ".DS_Store", "ai-dev-kit.zip"]);
|
|
28996
29162
|
var SKILL_INSTALLER_OUTPUT_ENTRIES = [".claude", ".codex", ".cursor", ".gemini"];
|
|
28997
29163
|
function inspectAiDevKit(targetDir) {
|
|
28998
|
-
const resolvedTargetDir =
|
|
29164
|
+
const resolvedTargetDir = path6.resolve(targetDir);
|
|
28999
29165
|
const presentEntries = DEV_KIT_REQUIRED_ENTRIES.filter(
|
|
29000
|
-
(entry) =>
|
|
29166
|
+
(entry) => fs5.existsSync(path6.join(resolvedTargetDir, entry))
|
|
29001
29167
|
);
|
|
29002
29168
|
const missingEntries = DEV_KIT_REQUIRED_ENTRIES.filter(
|
|
29003
29169
|
(entry) => !presentEntries.includes(entry)
|
|
@@ -29012,16 +29178,16 @@ function inspectAiDevKit(targetDir) {
|
|
|
29012
29178
|
};
|
|
29013
29179
|
}
|
|
29014
29180
|
function getAiDevKitVersionMetadataPath(targetDir) {
|
|
29015
|
-
return
|
|
29181
|
+
return path6.join(path6.resolve(targetDir), AI_DEV_KIT_VERSION_METADATA_FILE);
|
|
29016
29182
|
}
|
|
29017
29183
|
function readAiDevKitVersionMetadata(targetDir) {
|
|
29018
29184
|
const metadataPath = getAiDevKitVersionMetadataPath(targetDir);
|
|
29019
|
-
if (!
|
|
29185
|
+
if (!fs5.existsSync(metadataPath)) {
|
|
29020
29186
|
return void 0;
|
|
29021
29187
|
}
|
|
29022
29188
|
try {
|
|
29023
29189
|
const data = JSON.parse(
|
|
29024
|
-
|
|
29190
|
+
fs5.readFileSync(metadataPath, "utf8")
|
|
29025
29191
|
);
|
|
29026
29192
|
if (data.env !== "production" && data.env !== "rnd" || !isValidDevKitVersion(data.version) || typeof data.source_url !== "string" || typeof data.installed_at !== "string") {
|
|
29027
29193
|
return void 0;
|
|
@@ -29033,8 +29199,8 @@ function readAiDevKitVersionMetadata(targetDir) {
|
|
|
29033
29199
|
}
|
|
29034
29200
|
function writeAiDevKitVersionMetadata(targetDir, metadata) {
|
|
29035
29201
|
const metadataPath = getAiDevKitVersionMetadataPath(targetDir);
|
|
29036
|
-
|
|
29037
|
-
|
|
29202
|
+
fs5.mkdirSync(path6.dirname(metadataPath), { recursive: true });
|
|
29203
|
+
fs5.writeFileSync(metadataPath, `${JSON.stringify(metadata, null, 2)}
|
|
29038
29204
|
`, "utf8");
|
|
29039
29205
|
}
|
|
29040
29206
|
async function fetchAiDevKitVersions(options = {}) {
|
|
@@ -29089,7 +29255,7 @@ async function resolveAiDevKitDownload(options = {}) {
|
|
|
29089
29255
|
}
|
|
29090
29256
|
async function checkAiDevKitUpdate(targetDir, options = {}) {
|
|
29091
29257
|
var _a3;
|
|
29092
|
-
const resolvedTargetDir =
|
|
29258
|
+
const resolvedTargetDir = path6.resolve(targetDir);
|
|
29093
29259
|
const installed = readAiDevKitVersionMetadata(resolvedTargetDir);
|
|
29094
29260
|
const download = await resolveAiDevKitDownload({
|
|
29095
29261
|
environment: options.environment,
|
|
@@ -29107,24 +29273,24 @@ async function checkAiDevKitUpdate(targetDir, options = {}) {
|
|
|
29107
29273
|
};
|
|
29108
29274
|
}
|
|
29109
29275
|
function listPresentDevKitManagedEntries(targetDir) {
|
|
29110
|
-
const resolvedTargetDir =
|
|
29276
|
+
const resolvedTargetDir = path6.resolve(targetDir);
|
|
29111
29277
|
return DEV_KIT_MANAGED_ENTRY_CANDIDATES.filter(
|
|
29112
|
-
(entry) =>
|
|
29278
|
+
(entry) => fs5.existsSync(path6.join(resolvedTargetDir, entry))
|
|
29113
29279
|
);
|
|
29114
29280
|
}
|
|
29115
29281
|
async function installAiDevKit(options = {}) {
|
|
29116
29282
|
var _a3;
|
|
29117
|
-
const targetDir =
|
|
29118
|
-
|
|
29283
|
+
const targetDir = path6.resolve(options.targetDir || ".");
|
|
29284
|
+
fs5.mkdirSync(targetDir, { recursive: true });
|
|
29119
29285
|
const download = options.sourceDir ? void 0 : options.url ? void 0 : await resolveAiDevKitDownload({
|
|
29120
29286
|
environment: options.environment,
|
|
29121
29287
|
fetchImpl: options.fetchImpl,
|
|
29122
29288
|
versionCheckTimeoutMs: options.versionCheckTimeoutMs
|
|
29123
29289
|
});
|
|
29124
29290
|
const downloadUrl = options.url || (download == null ? void 0 : download.url) || resolveDefaultAiDevKitUrl(options.environment);
|
|
29125
|
-
const preparedSource = options.sourceDir ?
|
|
29291
|
+
const preparedSource = options.sourceDir ? path6.resolve(options.sourceDir) : await downloadAndExtractDevKit(downloadUrl, options.fetchImpl, options.downloadTimeoutMs);
|
|
29126
29292
|
const sourceDir = resolveDevKitRoot(preparedSource);
|
|
29127
|
-
const entries =
|
|
29293
|
+
const entries = fs5.readdirSync(sourceDir, { withFileTypes: true });
|
|
29128
29294
|
const installedEntries = [];
|
|
29129
29295
|
const skippedEntries = [];
|
|
29130
29296
|
if (options.replaceManagedEntries) {
|
|
@@ -29138,7 +29304,7 @@ async function installAiDevKit(options = {}) {
|
|
|
29138
29304
|
skippedEntries.push(entry.name);
|
|
29139
29305
|
continue;
|
|
29140
29306
|
}
|
|
29141
|
-
copyEntry(
|
|
29307
|
+
copyEntry(path6.join(sourceDir, entry.name), path6.join(targetDir, entry.name), {
|
|
29142
29308
|
preserveExisting: options.preserveExisting
|
|
29143
29309
|
});
|
|
29144
29310
|
installedEntries.push(entry.name);
|
|
@@ -29152,7 +29318,7 @@ async function installAiDevKit(options = {}) {
|
|
|
29152
29318
|
installedEntries.push(entry);
|
|
29153
29319
|
}
|
|
29154
29320
|
}
|
|
29155
|
-
const stagedGitignorePath =
|
|
29321
|
+
const stagedGitignorePath = path6.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE);
|
|
29156
29322
|
writeDevKitStagedGitignore(stagedGitignorePath, [
|
|
29157
29323
|
...installedEntries,
|
|
29158
29324
|
...listPresentSkillInstallerOutputEntries(targetDir)
|
|
@@ -29168,7 +29334,7 @@ async function installAiDevKit(options = {}) {
|
|
|
29168
29334
|
sourceDir,
|
|
29169
29335
|
installedEntries: installedEntries.sort(),
|
|
29170
29336
|
skippedEntries: skippedEntries.sort(),
|
|
29171
|
-
gitignorePath:
|
|
29337
|
+
gitignorePath: path6.join(targetDir, ".gitignore"),
|
|
29172
29338
|
stagedGitignorePath,
|
|
29173
29339
|
skillInstaller,
|
|
29174
29340
|
download,
|
|
@@ -29176,11 +29342,11 @@ async function installAiDevKit(options = {}) {
|
|
|
29176
29342
|
};
|
|
29177
29343
|
}
|
|
29178
29344
|
function inspectAiDevKitSkillInstallStatus(targetDir) {
|
|
29179
|
-
const resolvedTargetDir =
|
|
29345
|
+
const resolvedTargetDir = path6.resolve(targetDir);
|
|
29180
29346
|
const targets = SKILL_INSTALLER_OUTPUT_ENTRIES.map((entry) => {
|
|
29181
|
-
const skillsDir =
|
|
29182
|
-
const present =
|
|
29183
|
-
const skillCount = present ?
|
|
29347
|
+
const skillsDir = path6.join(resolvedTargetDir, entry, "skills");
|
|
29348
|
+
const present = fs5.existsSync(skillsDir) && fs5.statSync(skillsDir).isDirectory();
|
|
29349
|
+
const skillCount = present ? fs5.readdirSync(skillsDir, { withFileTypes: true }).filter((item) => item.isDirectory() || item.isSymbolicLink()).length : 0;
|
|
29184
29350
|
return {
|
|
29185
29351
|
name: entry.replace(/^\./, ""),
|
|
29186
29352
|
path: skillsDir,
|
|
@@ -29203,15 +29369,15 @@ function createDevKitGitignoreBlock(entries) {
|
|
|
29203
29369
|
return [DEV_KIT_IGNORE_BEGIN, ...ignoreEntries, DEV_KIT_IGNORE_END].join("\n");
|
|
29204
29370
|
}
|
|
29205
29371
|
function writeDevKitStagedGitignore(stagedGitignorePath, entries) {
|
|
29206
|
-
|
|
29372
|
+
fs5.writeFileSync(stagedGitignorePath, `${createDevKitGitignoreBlock(entries)}
|
|
29207
29373
|
`, "utf8");
|
|
29208
29374
|
}
|
|
29209
29375
|
function ensureMakerAssetPolicyInstructionFiles(targetDir) {
|
|
29210
|
-
const resolvedTargetDir =
|
|
29211
|
-
|
|
29212
|
-
const agentsPath =
|
|
29213
|
-
const existingAgents =
|
|
29214
|
-
|
|
29376
|
+
const resolvedTargetDir = path6.resolve(targetDir);
|
|
29377
|
+
fs5.mkdirSync(resolvedTargetDir, { recursive: true });
|
|
29378
|
+
const agentsPath = path6.join(resolvedTargetDir, AGENTS_INSTRUCTION_FILE);
|
|
29379
|
+
const existingAgents = fs5.existsSync(agentsPath) ? fs5.readFileSync(agentsPath, "utf8") : "";
|
|
29380
|
+
fs5.writeFileSync(agentsPath, prependMakerAssetPolicyBlock(existingAgents), "utf8");
|
|
29215
29381
|
return [AGENTS_INSTRUCTION_FILE];
|
|
29216
29382
|
}
|
|
29217
29383
|
function prependMakerAssetPolicyBlock(existing) {
|
|
@@ -29266,7 +29432,7 @@ function createMakerAssetPolicyBlock() {
|
|
|
29266
29432
|
].join("\n");
|
|
29267
29433
|
}
|
|
29268
29434
|
function mergeDevKitGitignoreBlock(gitignorePath, block) {
|
|
29269
|
-
const existing =
|
|
29435
|
+
const existing = fs5.existsSync(gitignorePath) ? fs5.readFileSync(gitignorePath, "utf8") : "";
|
|
29270
29436
|
const withoutOldBlock = existing.replace(
|
|
29271
29437
|
new RegExp(
|
|
29272
29438
|
`${escapeRegExp(DEV_KIT_IGNORE_BEGIN)}[\\s\\S]*?${escapeRegExp(DEV_KIT_IGNORE_END)}\\n?`,
|
|
@@ -29275,38 +29441,38 @@ function mergeDevKitGitignoreBlock(gitignorePath, block) {
|
|
|
29275
29441
|
""
|
|
29276
29442
|
).trimEnd();
|
|
29277
29443
|
const next = [withoutOldBlock, block, ""].filter((part) => part.length > 0).join("\n\n");
|
|
29278
|
-
|
|
29444
|
+
fs5.writeFileSync(gitignorePath, next, "utf8");
|
|
29279
29445
|
}
|
|
29280
29446
|
function finalizeStagedDevKitGitignore(targetDir) {
|
|
29281
|
-
const stagedGitignorePath =
|
|
29282
|
-
if (!
|
|
29447
|
+
const stagedGitignorePath = path6.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE);
|
|
29448
|
+
if (!fs5.existsSync(stagedGitignorePath)) {
|
|
29283
29449
|
return false;
|
|
29284
29450
|
}
|
|
29285
|
-
const block =
|
|
29451
|
+
const block = fs5.readFileSync(stagedGitignorePath, "utf8").trim();
|
|
29286
29452
|
if (block.length > 0) {
|
|
29287
|
-
mergeDevKitGitignoreBlock(
|
|
29453
|
+
mergeDevKitGitignoreBlock(path6.join(targetDir, ".gitignore"), block);
|
|
29288
29454
|
}
|
|
29289
|
-
|
|
29455
|
+
fs5.rmSync(stagedGitignorePath, { force: true });
|
|
29290
29456
|
return true;
|
|
29291
29457
|
}
|
|
29292
29458
|
function copyEntry(source, target, options = {}) {
|
|
29293
|
-
const stat =
|
|
29459
|
+
const stat = fs5.statSync(source);
|
|
29294
29460
|
if (stat.isDirectory()) {
|
|
29295
|
-
|
|
29296
|
-
for (const child of
|
|
29461
|
+
fs5.mkdirSync(target, { recursive: true });
|
|
29462
|
+
for (const child of fs5.readdirSync(source)) {
|
|
29297
29463
|
if (child === ".DS_Store") {
|
|
29298
29464
|
continue;
|
|
29299
29465
|
}
|
|
29300
|
-
copyEntry(
|
|
29466
|
+
copyEntry(path6.join(source, child), path6.join(target, child), options);
|
|
29301
29467
|
}
|
|
29302
29468
|
return;
|
|
29303
29469
|
}
|
|
29304
29470
|
if (stat.isFile()) {
|
|
29305
|
-
if (options.preserveExisting &&
|
|
29471
|
+
if (options.preserveExisting && fs5.existsSync(target)) {
|
|
29306
29472
|
return;
|
|
29307
29473
|
}
|
|
29308
|
-
|
|
29309
|
-
|
|
29474
|
+
fs5.mkdirSync(path6.dirname(target), { recursive: true });
|
|
29475
|
+
fs5.copyFileSync(source, target);
|
|
29310
29476
|
}
|
|
29311
29477
|
}
|
|
29312
29478
|
function replaceDevKitManagedEntries(targetDir, sourceEntryNames) {
|
|
@@ -29316,11 +29482,11 @@ function replaceDevKitManagedEntries(targetDir, sourceEntryNames) {
|
|
|
29316
29482
|
candidates.add(entry);
|
|
29317
29483
|
}
|
|
29318
29484
|
}
|
|
29319
|
-
for (const entry of readManagedGitignoreEntries(
|
|
29485
|
+
for (const entry of readManagedGitignoreEntries(path6.join(targetDir, ".gitignore"))) {
|
|
29320
29486
|
candidates.add(entry);
|
|
29321
29487
|
}
|
|
29322
29488
|
for (const entry of readManagedGitignoreEntries(
|
|
29323
|
-
|
|
29489
|
+
path6.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE)
|
|
29324
29490
|
)) {
|
|
29325
29491
|
candidates.add(entry);
|
|
29326
29492
|
}
|
|
@@ -29331,14 +29497,14 @@ function replaceDevKitManagedEntries(targetDir, sourceEntryNames) {
|
|
|
29331
29497
|
if (!DEV_KIT_MANAGED_ENTRY_CANDIDATES.includes(entry)) {
|
|
29332
29498
|
continue;
|
|
29333
29499
|
}
|
|
29334
|
-
|
|
29500
|
+
fs5.rmSync(path6.join(targetDir, entry), { recursive: true, force: true });
|
|
29335
29501
|
}
|
|
29336
29502
|
}
|
|
29337
29503
|
function readManagedGitignoreEntries(gitignorePath) {
|
|
29338
|
-
if (!
|
|
29504
|
+
if (!fs5.existsSync(gitignorePath)) {
|
|
29339
29505
|
return [];
|
|
29340
29506
|
}
|
|
29341
|
-
const content =
|
|
29507
|
+
const content = fs5.readFileSync(gitignorePath, "utf8");
|
|
29342
29508
|
const blockPattern = new RegExp(
|
|
29343
29509
|
`${escapeRegExp(DEV_KIT_IGNORE_BEGIN)}\\n([\\s\\S]*?)\\n${escapeRegExp(DEV_KIT_IGNORE_END)}`,
|
|
29344
29510
|
"g"
|
|
@@ -29357,8 +29523,8 @@ function readManagedGitignoreEntries(gitignorePath) {
|
|
|
29357
29523
|
}
|
|
29358
29524
|
function installAiDevKitSkills(targetDir, options = {}) {
|
|
29359
29525
|
var _a3;
|
|
29360
|
-
const toolsDir =
|
|
29361
|
-
if (!
|
|
29526
|
+
const toolsDir = path6.join(targetDir, "tools");
|
|
29527
|
+
if (!fs5.existsSync(toolsDir) || !fs5.statSync(toolsDir).isDirectory()) {
|
|
29362
29528
|
return {
|
|
29363
29529
|
ok: false,
|
|
29364
29530
|
status: "skipped",
|
|
@@ -29370,8 +29536,8 @@ function installAiDevKitSkills(targetDir, options = {}) {
|
|
|
29370
29536
|
}
|
|
29371
29537
|
const isWindows = process.platform === "win32";
|
|
29372
29538
|
const scriptName = isWindows ? "install-skills.ps1" : "install-skills.sh";
|
|
29373
|
-
const scriptPath =
|
|
29374
|
-
if (!
|
|
29539
|
+
const scriptPath = path6.join(toolsDir, scriptName);
|
|
29540
|
+
if (!fs5.existsSync(scriptPath)) {
|
|
29375
29541
|
return {
|
|
29376
29542
|
ok: false,
|
|
29377
29543
|
status: "skipped",
|
|
@@ -29433,7 +29599,7 @@ function runDevKitSkillInstallerForInstall(targetDir, options = {}) {
|
|
|
29433
29599
|
}
|
|
29434
29600
|
function listPresentSkillInstallerOutputEntries(targetDir) {
|
|
29435
29601
|
return SKILL_INSTALLER_OUTPUT_ENTRIES.filter(
|
|
29436
|
-
(entry) =>
|
|
29602
|
+
(entry) => fs5.existsSync(path6.join(targetDir, entry))
|
|
29437
29603
|
);
|
|
29438
29604
|
}
|
|
29439
29605
|
function getAiDevKitVersionsUrl(environment) {
|
|
@@ -29465,16 +29631,16 @@ function writeResolvedDevKitVersionMetadata(targetDir, environment, sourceUrl, c
|
|
|
29465
29631
|
return metadata;
|
|
29466
29632
|
}
|
|
29467
29633
|
async function downloadAndExtractDevKit(url2, fetchImpl = fetch, timeoutMs = DEFAULT_DOWNLOAD_FETCH_TIMEOUT_MS) {
|
|
29468
|
-
const tempDir =
|
|
29469
|
-
const zipPath =
|
|
29634
|
+
const tempDir = fs5.mkdtempSync(path6.join(os3.tmpdir(), "taptap-maker-ai-dev-kit-"));
|
|
29635
|
+
const zipPath = path6.join(tempDir, "ai-dev-kit.zip");
|
|
29470
29636
|
const response = await fetchWithTimeout(fetchImpl, url2, {}, timeoutMs, "AI dev kit download");
|
|
29471
29637
|
if (!response.ok) {
|
|
29472
29638
|
throw new Error(`AI dev kit download failed: HTTP ${response.status} ${response.statusText}`);
|
|
29473
29639
|
}
|
|
29474
29640
|
const payload = Buffer.from(await response.arrayBuffer());
|
|
29475
|
-
|
|
29641
|
+
fs5.writeFileSync(zipPath, payload);
|
|
29476
29642
|
extractZip(zipPath, tempDir);
|
|
29477
|
-
|
|
29643
|
+
fs5.rmSync(zipPath, { force: true });
|
|
29478
29644
|
return tempDir;
|
|
29479
29645
|
}
|
|
29480
29646
|
function extractZip(zipPath, targetDir) {
|
|
@@ -29602,11 +29768,11 @@ function shellQuote(value) {
|
|
|
29602
29768
|
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
29603
29769
|
}
|
|
29604
29770
|
function resolveDevKitRoot(sourceDir) {
|
|
29605
|
-
const directEntries =
|
|
29771
|
+
const directEntries = fs5.existsSync(sourceDir) ? fs5.readdirSync(sourceDir) : [];
|
|
29606
29772
|
if (looksLikeDevKitRoot(sourceDir)) {
|
|
29607
29773
|
return sourceDir;
|
|
29608
29774
|
}
|
|
29609
|
-
const childDirs = directEntries.map((entry) =>
|
|
29775
|
+
const childDirs = directEntries.map((entry) => path6.join(sourceDir, entry)).filter((entryPath) => fs5.existsSync(entryPath) && fs5.statSync(entryPath).isDirectory());
|
|
29610
29776
|
for (const childDir of childDirs) {
|
|
29611
29777
|
if (looksLikeDevKitRoot(childDir)) {
|
|
29612
29778
|
return childDir;
|
|
@@ -29615,7 +29781,7 @@ function resolveDevKitRoot(sourceDir) {
|
|
|
29615
29781
|
throw new Error(`AI dev kit root not found under ${sourceDir}`);
|
|
29616
29782
|
}
|
|
29617
29783
|
function looksLikeDevKitRoot(dir) {
|
|
29618
|
-
return
|
|
29784
|
+
return fs5.existsSync(path6.join(dir, "engine-docs")) || fs5.existsSync(path6.join(dir, ".emmylua")) || fs5.existsSync(path6.join(dir, "urhox-libs"));
|
|
29619
29785
|
}
|
|
29620
29786
|
function formatIgnoreEntry(entry) {
|
|
29621
29787
|
if (entry === ".DS_Store") {
|
|
@@ -29733,7 +29899,7 @@ async function listMakerProjects(options) {
|
|
|
29733
29899
|
}
|
|
29734
29900
|
async function cloneMakerProject(options) {
|
|
29735
29901
|
var _a3, _b, _c, _d, _e, _f, _g, _h;
|
|
29736
|
-
const target =
|
|
29902
|
+
const target = path7.resolve(options.targetDir);
|
|
29737
29903
|
ensureTargetCanBindApp(target, options.appId);
|
|
29738
29904
|
const warnings = createPreCloneWarnings(target);
|
|
29739
29905
|
(_a3 = options.onProgress) == null ? void 0 : _a3.call(options, {
|
|
@@ -29899,7 +30065,7 @@ async function pushMakerProject(options) {
|
|
|
29899
30065
|
phase: "prepare",
|
|
29900
30066
|
message: "Preparing Maker project push"
|
|
29901
30067
|
});
|
|
29902
|
-
const requestedCwd =
|
|
30068
|
+
const requestedCwd = path7.resolve(options.cwd);
|
|
29903
30069
|
const workspace = resolveUsableMakerGitWorkspace(requestedCwd);
|
|
29904
30070
|
const cwd = workspace.projectRoot;
|
|
29905
30071
|
const project = loadProjectConfig(cwd);
|
|
@@ -30530,7 +30696,7 @@ function makeAuthenticatedGitUrl(gitUrl, pat) {
|
|
|
30530
30696
|
return gitUrl.replace(/^https:\/\//, `https://git:${encodeURIComponent(pat)}@`);
|
|
30531
30697
|
}
|
|
30532
30698
|
async function fetchAndCheckoutTarget(target, authUrl, pat, onProgress) {
|
|
30533
|
-
if (
|
|
30699
|
+
if (fs6.existsSync(target) && hasDirectoryEntries(target)) {
|
|
30534
30700
|
onProgress == null ? void 0 : onProgress({
|
|
30535
30701
|
progress: 10,
|
|
30536
30702
|
total: 100,
|
|
@@ -30577,23 +30743,23 @@ function emitFirstCloneWaitNotice(onProgress, phase) {
|
|
|
30577
30743
|
});
|
|
30578
30744
|
}
|
|
30579
30745
|
function hasDirectoryEntries(target) {
|
|
30580
|
-
if (!
|
|
30746
|
+
if (!fs6.existsSync(target)) {
|
|
30581
30747
|
return false;
|
|
30582
30748
|
}
|
|
30583
|
-
return
|
|
30749
|
+
return fs6.readdirSync(target).length > 0;
|
|
30584
30750
|
}
|
|
30585
30751
|
function listLocalFiles(root) {
|
|
30586
|
-
if (!
|
|
30752
|
+
if (!fs6.existsSync(root)) {
|
|
30587
30753
|
return [];
|
|
30588
30754
|
}
|
|
30589
30755
|
const files = [];
|
|
30590
30756
|
const visit = (dir, relativeDir) => {
|
|
30591
|
-
for (const entry of
|
|
30757
|
+
for (const entry of fs6.readdirSync(dir, { withFileTypes: true })) {
|
|
30592
30758
|
const relativePath = relativeDir ? `${relativeDir}/${entry.name}` : entry.name;
|
|
30593
30759
|
if (entry.name === ".git" || relativePath === ".maker-mcp" || relativePath.startsWith(".maker-mcp/") || entry.name === ".DS_Store") {
|
|
30594
30760
|
continue;
|
|
30595
30761
|
}
|
|
30596
|
-
const fullPath =
|
|
30762
|
+
const fullPath = path7.join(dir, entry.name);
|
|
30597
30763
|
if (entry.isDirectory()) {
|
|
30598
30764
|
visit(fullPath, relativePath);
|
|
30599
30765
|
continue;
|
|
@@ -30607,10 +30773,10 @@ function listLocalFiles(root) {
|
|
|
30607
30773
|
return files;
|
|
30608
30774
|
}
|
|
30609
30775
|
function listPreCloneNoticeFiles(root) {
|
|
30610
|
-
if (!
|
|
30776
|
+
if (!fs6.existsSync(root)) {
|
|
30611
30777
|
return [];
|
|
30612
30778
|
}
|
|
30613
|
-
return
|
|
30779
|
+
return fs6.readdirSync(root, { withFileTypes: true }).filter((entry) => !isIgnorablePreCloneEntry(entry.name)).map((entry) => entry.name).sort();
|
|
30614
30780
|
}
|
|
30615
30781
|
function createPreCloneWarnings(target) {
|
|
30616
30782
|
const preCloneLocalFiles = listPreCloneNoticeFiles(target);
|
|
@@ -30733,7 +30899,7 @@ function ensureOwnGitRoot(repoDir) {
|
|
|
30733
30899
|
);
|
|
30734
30900
|
}
|
|
30735
30901
|
function inspectMakerDirectoryGitStatus(cwd) {
|
|
30736
|
-
const targetDir =
|
|
30902
|
+
const targetDir = path7.resolve(cwd);
|
|
30737
30903
|
const gitRoot = resolveGitRoot(targetDir);
|
|
30738
30904
|
const gitDir = resolveGitDir(targetDir);
|
|
30739
30905
|
const makerBinding = findMakerProjectBinding(targetDir);
|
|
@@ -30806,16 +30972,16 @@ function formatMakerGitRootMismatch(status) {
|
|
|
30806
30972
|
}
|
|
30807
30973
|
function findMakerProjectBinding(startDir) {
|
|
30808
30974
|
var _a3;
|
|
30809
|
-
let current =
|
|
30975
|
+
let current = path7.resolve(startDir);
|
|
30810
30976
|
while (current.length > 0) {
|
|
30811
30977
|
const configPath = getProjectConfigPath(current);
|
|
30812
|
-
if (
|
|
30978
|
+
if (fs6.existsSync(configPath) && ((_a3 = loadProjectConfig(current)) == null ? void 0 : _a3.project_id)) {
|
|
30813
30979
|
return {
|
|
30814
30980
|
projectRoot: current,
|
|
30815
30981
|
configPath
|
|
30816
30982
|
};
|
|
30817
30983
|
}
|
|
30818
|
-
const parent =
|
|
30984
|
+
const parent = path7.dirname(current);
|
|
30819
30985
|
if (parent === current) {
|
|
30820
30986
|
return null;
|
|
30821
30987
|
}
|
|
@@ -30825,7 +30991,7 @@ function findMakerProjectBinding(startDir) {
|
|
|
30825
30991
|
}
|
|
30826
30992
|
function resolveGitRoot(cwd) {
|
|
30827
30993
|
try {
|
|
30828
|
-
return
|
|
30994
|
+
return path7.resolve(readGitSync(["-C", cwd, "rev-parse", "--show-toplevel"]).trim());
|
|
30829
30995
|
} catch {
|
|
30830
30996
|
return void 0;
|
|
30831
30997
|
}
|
|
@@ -30833,7 +30999,7 @@ function resolveGitRoot(cwd) {
|
|
|
30833
30999
|
function resolveGitDir(cwd) {
|
|
30834
31000
|
try {
|
|
30835
31001
|
const gitDir = readGitSync(["-C", cwd, "rev-parse", "--git-dir"]).trim();
|
|
30836
|
-
return
|
|
31002
|
+
return path7.isAbsolute(gitDir) ? path7.resolve(gitDir) : path7.resolve(cwd, gitDir);
|
|
30837
31003
|
} catch {
|
|
30838
31004
|
return void 0;
|
|
30839
31005
|
}
|
|
@@ -30842,9 +31008,9 @@ function samePath(left, right) {
|
|
|
30842
31008
|
return normalizePathForCompare(left) === normalizePathForCompare(right);
|
|
30843
31009
|
}
|
|
30844
31010
|
function normalizePathForCompare(value) {
|
|
30845
|
-
const resolved =
|
|
31011
|
+
const resolved = path7.resolve(value);
|
|
30846
31012
|
try {
|
|
30847
|
-
return
|
|
31013
|
+
return fs6.realpathSync.native(resolved);
|
|
30848
31014
|
} catch {
|
|
30849
31015
|
return resolved;
|
|
30850
31016
|
}
|
|
@@ -30957,7 +31123,7 @@ async function runGitCaptureWithTransientRetry(args, options = {}) {
|
|
|
30957
31123
|
async function runWithTransientRetry(operation, options) {
|
|
30958
31124
|
var _a3;
|
|
30959
31125
|
let retries = 0;
|
|
30960
|
-
const maxRetries =
|
|
31126
|
+
const maxRetries = 5;
|
|
30961
31127
|
for (; ; ) {
|
|
30962
31128
|
try {
|
|
30963
31129
|
await operation();
|
|
@@ -30975,7 +31141,7 @@ async function runWithTransientRetry(operation, options) {
|
|
|
30975
31141
|
phase: options.stage,
|
|
30976
31142
|
message: formatGitRetryProgressMessage(options.stage, decision, retries, maxRetries)
|
|
30977
31143
|
});
|
|
30978
|
-
await sleep(
|
|
31144
|
+
await sleep(getMakerGitRetryDelayMs() * retries);
|
|
30979
31145
|
}
|
|
30980
31146
|
}
|
|
30981
31147
|
}
|
|
@@ -31018,9 +31184,9 @@ function appendRetryExhausted(error2, retryAttempts, decision) {
|
|
|
31018
31184
|
].filter(Boolean).join("\n")
|
|
31019
31185
|
);
|
|
31020
31186
|
}
|
|
31021
|
-
function
|
|
31187
|
+
function getMakerGitRetryDelayMs() {
|
|
31022
31188
|
const value = Number.parseInt(process.env.TAPTAP_MAKER_GIT_RETRY_DELAY_MS || "", 10);
|
|
31023
|
-
return Number.isFinite(value) && value >= 0 ? value :
|
|
31189
|
+
return Number.isFinite(value) && value >= 0 ? value : 5e3;
|
|
31024
31190
|
}
|
|
31025
31191
|
function sleep(ms) {
|
|
31026
31192
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -31210,8 +31376,8 @@ async function requestTapAuthWithPat(manualPat, environment, options = {}) {
|
|
|
31210
31376
|
|
|
31211
31377
|
// src/maker/system/python.ts
|
|
31212
31378
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
31213
|
-
import
|
|
31214
|
-
import
|
|
31379
|
+
import fs7 from "node:fs";
|
|
31380
|
+
import path8 from "node:path";
|
|
31215
31381
|
var PYTHON_INFO_SCRIPT = [
|
|
31216
31382
|
"import json, sys",
|
|
31217
31383
|
'print(json.dumps({"executable": sys.executable, "version": ".".join(map(str, sys.version_info[:3]))}))'
|
|
@@ -31220,16 +31386,16 @@ var DEFAULT_PYTHON_VERSION = "3.12";
|
|
|
31220
31386
|
var MINIMUM_PYTHON_VERSION = "3.8";
|
|
31221
31387
|
var RECOMMENDED_PYTHON_VERSION = "3.12";
|
|
31222
31388
|
function getMakerPythonConfigPath() {
|
|
31223
|
-
return
|
|
31389
|
+
return path8.join(getMakerHome(), "python.json");
|
|
31224
31390
|
}
|
|
31225
31391
|
function getMakerUvInstallRoot() {
|
|
31226
|
-
return
|
|
31392
|
+
return path8.join(getMakerHome(), "bin");
|
|
31227
31393
|
}
|
|
31228
31394
|
function getMakerUvPath(platform = process.platform) {
|
|
31229
|
-
return
|
|
31395
|
+
return path8.join(getMakerUvInstallRoot(), platform === "win32" ? "uv.exe" : "uv");
|
|
31230
31396
|
}
|
|
31231
31397
|
function getMakerUvPythonInstallDir() {
|
|
31232
|
-
return
|
|
31398
|
+
return path8.join(getMakerHome(), "python", "uv");
|
|
31233
31399
|
}
|
|
31234
31400
|
function checkMakerPythonEnvironment(options = {}) {
|
|
31235
31401
|
const platform = options.platform || process.platform;
|
|
@@ -31245,7 +31411,7 @@ function checkMakerPythonEnvironment(options = {}) {
|
|
|
31245
31411
|
pathCommand,
|
|
31246
31412
|
uv: {
|
|
31247
31413
|
path: uvPath,
|
|
31248
|
-
installed:
|
|
31414
|
+
installed: fs7.existsSync(uvPath),
|
|
31249
31415
|
version: readUvVersion(uvPath, runner)
|
|
31250
31416
|
}
|
|
31251
31417
|
};
|
|
@@ -31467,10 +31633,10 @@ function resultToEnvironment(result, base) {
|
|
|
31467
31633
|
}
|
|
31468
31634
|
function ensureUvInstalled(platform, runner) {
|
|
31469
31635
|
const uvPath = getMakerUvPath(platform);
|
|
31470
|
-
if (
|
|
31636
|
+
if (fs7.existsSync(uvPath)) {
|
|
31471
31637
|
return uvPath;
|
|
31472
31638
|
}
|
|
31473
|
-
|
|
31639
|
+
fs7.mkdirSync(getMakerUvInstallRoot(), { recursive: true });
|
|
31474
31640
|
const env = {
|
|
31475
31641
|
...process.env,
|
|
31476
31642
|
INSTALLER_NO_MODIFY_PATH: "1",
|
|
@@ -31493,13 +31659,13 @@ function ensureUvInstalled(platform, runner) {
|
|
|
31493
31659
|
if (install.status !== 0) {
|
|
31494
31660
|
throw new Error(formatSetupFailure("uv installer failed", install));
|
|
31495
31661
|
}
|
|
31496
|
-
if (!
|
|
31497
|
-
const nestedUvPath =
|
|
31662
|
+
if (!fs7.existsSync(uvPath)) {
|
|
31663
|
+
const nestedUvPath = path8.join(
|
|
31498
31664
|
getMakerUvInstallRoot(),
|
|
31499
31665
|
"bin",
|
|
31500
31666
|
platform === "win32" ? "uv.exe" : "uv"
|
|
31501
31667
|
);
|
|
31502
|
-
if (
|
|
31668
|
+
if (fs7.existsSync(nestedUvPath)) {
|
|
31503
31669
|
return nestedUvPath;
|
|
31504
31670
|
}
|
|
31505
31671
|
throw new Error(`uv installer finished, but ${uvPath} was not created.`);
|
|
@@ -31510,11 +31676,11 @@ function createUvPythonEnv() {
|
|
|
31510
31676
|
return {
|
|
31511
31677
|
...process.env,
|
|
31512
31678
|
UV_PYTHON_INSTALL_DIR: getMakerUvPythonInstallDir(),
|
|
31513
|
-
UV_CACHE_DIR:
|
|
31679
|
+
UV_CACHE_DIR: path8.join(getMakerHome(), "cache", "uv")
|
|
31514
31680
|
};
|
|
31515
31681
|
}
|
|
31516
31682
|
function readUvVersion(uvPath, runner) {
|
|
31517
|
-
if (!
|
|
31683
|
+
if (!fs7.existsSync(uvPath)) {
|
|
31518
31684
|
return void 0;
|
|
31519
31685
|
}
|
|
31520
31686
|
const result = runner(uvPath, ["--version"], { encoding: "utf8" });
|
|
@@ -31567,11 +31733,11 @@ function parseVersionTuple(version2) {
|
|
|
31567
31733
|
}
|
|
31568
31734
|
function loadPythonRuntimeConfig() {
|
|
31569
31735
|
const configPath = getMakerPythonConfigPath();
|
|
31570
|
-
if (!
|
|
31736
|
+
if (!fs7.existsSync(configPath)) {
|
|
31571
31737
|
return void 0;
|
|
31572
31738
|
}
|
|
31573
31739
|
try {
|
|
31574
|
-
const data = JSON.parse(
|
|
31740
|
+
const data = JSON.parse(fs7.readFileSync(configPath, "utf8"));
|
|
31575
31741
|
if (typeof data.python === "string" || data.status === "setup_failed") {
|
|
31576
31742
|
return data;
|
|
31577
31743
|
}
|
|
@@ -31590,8 +31756,8 @@ function savePythonRuntimeConfig(environment) {
|
|
|
31590
31756
|
version: environment.version,
|
|
31591
31757
|
saved_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
31592
31758
|
};
|
|
31593
|
-
|
|
31594
|
-
|
|
31759
|
+
fs7.mkdirSync(path8.dirname(getMakerPythonConfigPath()), { recursive: true });
|
|
31760
|
+
fs7.writeFileSync(getMakerPythonConfigPath(), JSON.stringify(config2, null, 2), "utf8");
|
|
31595
31761
|
}
|
|
31596
31762
|
function savePythonSetupFailure(error2) {
|
|
31597
31763
|
const config2 = {
|
|
@@ -31599,8 +31765,8 @@ function savePythonSetupFailure(error2) {
|
|
|
31599
31765
|
error: error2 instanceof Error ? error2.message : String(error2),
|
|
31600
31766
|
saved_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
31601
31767
|
};
|
|
31602
|
-
|
|
31603
|
-
|
|
31768
|
+
fs7.mkdirSync(path8.dirname(getMakerPythonConfigPath()), { recursive: true });
|
|
31769
|
+
fs7.writeFileSync(getMakerPythonConfigPath(), JSON.stringify(config2, null, 2), "utf8");
|
|
31604
31770
|
}
|
|
31605
31771
|
function formatSetupFailure(message, result) {
|
|
31606
31772
|
var _a3, _b, _c;
|
|
@@ -31615,8 +31781,8 @@ function formatSetupFailure(message, result) {
|
|
|
31615
31781
|
|
|
31616
31782
|
// src/maker/system/luaLsp.ts
|
|
31617
31783
|
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
31618
|
-
import
|
|
31619
|
-
import
|
|
31784
|
+
import fs8 from "node:fs";
|
|
31785
|
+
import path9 from "node:path";
|
|
31620
31786
|
var LUA_LSP_PACKAGE = "maker-lua-lsp";
|
|
31621
31787
|
var LUA_LSP_IDES = "codex,cursor,claude";
|
|
31622
31788
|
var LUA_LSP_SETUP_TIMEOUT_MS = 12e4;
|
|
@@ -31626,10 +31792,10 @@ var PYTHON_SCRIPTS_DIR_SCRIPT = [
|
|
|
31626
31792
|
'print(sysconfig.get_path("scripts") or "")'
|
|
31627
31793
|
].join("; ");
|
|
31628
31794
|
function getMakerLuaLspConfigPath() {
|
|
31629
|
-
return
|
|
31795
|
+
return path9.join(getMakerHome(), "lua-lsp.json");
|
|
31630
31796
|
}
|
|
31631
31797
|
function getMakerLuaLspVenvDir() {
|
|
31632
|
-
return
|
|
31798
|
+
return path9.join(getMakerHome(), "lua-lsp-venv");
|
|
31633
31799
|
}
|
|
31634
31800
|
function checkMakerLuaLspEnvironment(options = {}) {
|
|
31635
31801
|
const runner = options.spawn || spawnSync5;
|
|
@@ -31657,7 +31823,7 @@ function checkMakerLuaLspEnvironment(options = {}) {
|
|
|
31657
31823
|
command: saved.command,
|
|
31658
31824
|
version: version3,
|
|
31659
31825
|
python: saved.python || python.python,
|
|
31660
|
-
scriptsDir:
|
|
31826
|
+
scriptsDir: path9.dirname(saved.command),
|
|
31661
31827
|
missing: [],
|
|
31662
31828
|
nextAction: "maker-lua-lsp 已安装;本地 Lua 诊断可用。"
|
|
31663
31829
|
};
|
|
@@ -31834,16 +32000,16 @@ function createLuaLspBase(platform) {
|
|
|
31834
32000
|
}
|
|
31835
32001
|
function resolveLuaLspCommand(python, platform, runner) {
|
|
31836
32002
|
const venvCommand = getLuaLspVenvCommand(platform);
|
|
31837
|
-
if (
|
|
31838
|
-
return { command: venvCommand, scriptsDir:
|
|
32003
|
+
if (fs8.existsSync(venvCommand)) {
|
|
32004
|
+
return { command: venvCommand, scriptsDir: path9.dirname(venvCommand) };
|
|
31839
32005
|
}
|
|
31840
32006
|
const scriptsDir = readPythonScriptsDir(python.python, runner);
|
|
31841
32007
|
if (scriptsDir) {
|
|
31842
|
-
const command =
|
|
32008
|
+
const command = path9.join(
|
|
31843
32009
|
scriptsDir,
|
|
31844
32010
|
platform === "win32" ? "maker-lua-lsp.exe" : "maker-lua-lsp"
|
|
31845
32011
|
);
|
|
31846
|
-
if (
|
|
32012
|
+
if (fs8.existsSync(command)) {
|
|
31847
32013
|
return { command, scriptsDir };
|
|
31848
32014
|
}
|
|
31849
32015
|
return { scriptsDir };
|
|
@@ -31867,23 +32033,23 @@ function ensureLuaLspVenv(python, platform, runner) {
|
|
|
31867
32033
|
return { python: venvPython, scriptsDir, command };
|
|
31868
32034
|
}
|
|
31869
32035
|
function isLuaLspVenvComplete(platform) {
|
|
31870
|
-
return
|
|
32036
|
+
return fs8.existsSync(getLuaLspVenvPython(platform)) && fs8.existsSync(getLuaLspVenvConfigPath());
|
|
31871
32037
|
}
|
|
31872
32038
|
function getLuaLspVenvConfigPath() {
|
|
31873
|
-
return
|
|
32039
|
+
return path9.join(getMakerLuaLspVenvDir(), "pyvenv.cfg");
|
|
31874
32040
|
}
|
|
31875
32041
|
function getLuaLspVenvPython(platform) {
|
|
31876
|
-
return
|
|
32042
|
+
return path9.join(
|
|
31877
32043
|
getMakerLuaLspVenvDir(),
|
|
31878
32044
|
platform === "win32" ? "Scripts" : "bin",
|
|
31879
32045
|
platform === "win32" ? "python.exe" : "python"
|
|
31880
32046
|
);
|
|
31881
32047
|
}
|
|
31882
32048
|
function getLuaLspVenvScriptsDir(platform) {
|
|
31883
|
-
return
|
|
32049
|
+
return path9.join(getMakerLuaLspVenvDir(), platform === "win32" ? "Scripts" : "bin");
|
|
31884
32050
|
}
|
|
31885
32051
|
function getLuaLspVenvCommand(platform) {
|
|
31886
|
-
return
|
|
32052
|
+
return path9.join(
|
|
31887
32053
|
getLuaLspVenvScriptsDir(platform),
|
|
31888
32054
|
platform === "win32" ? "maker-lua-lsp.exe" : "maker-lua-lsp"
|
|
31889
32055
|
);
|
|
@@ -31931,11 +32097,11 @@ function formatLuaLspSetupFailure(platform, python, message, result, command, sc
|
|
|
31931
32097
|
}
|
|
31932
32098
|
function loadLuaLspRuntimeConfig() {
|
|
31933
32099
|
const configPath = getMakerLuaLspConfigPath();
|
|
31934
|
-
if (!
|
|
32100
|
+
if (!fs8.existsSync(configPath)) {
|
|
31935
32101
|
return void 0;
|
|
31936
32102
|
}
|
|
31937
32103
|
try {
|
|
31938
|
-
return JSON.parse(
|
|
32104
|
+
return JSON.parse(fs8.readFileSync(configPath, "utf8"));
|
|
31939
32105
|
} catch {
|
|
31940
32106
|
return void 0;
|
|
31941
32107
|
}
|
|
@@ -31948,13 +32114,13 @@ function saveLuaLspRuntimeConfig(environment) {
|
|
|
31948
32114
|
error: environment.error,
|
|
31949
32115
|
saved_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
31950
32116
|
};
|
|
31951
|
-
|
|
31952
|
-
|
|
32117
|
+
fs8.mkdirSync(path9.dirname(getMakerLuaLspConfigPath()), { recursive: true });
|
|
32118
|
+
fs8.writeFileSync(getMakerLuaLspConfigPath(), JSON.stringify(config2, null, 2), "utf8");
|
|
31953
32119
|
}
|
|
31954
32120
|
|
|
31955
32121
|
// src/maker/cli/skill.ts
|
|
31956
|
-
import
|
|
31957
|
-
import
|
|
32122
|
+
import fs9 from "node:fs";
|
|
32123
|
+
import path10 from "node:path";
|
|
31958
32124
|
import { fileURLToPath } from "node:url";
|
|
31959
32125
|
var MAKER_LOCAL_SKILL_NAME = "taptap-maker-local";
|
|
31960
32126
|
var MAKER_DEV_KIT_GUIDE_SKILL_NAME = "taptap-maker-dev-kit-guide";
|
|
@@ -31973,7 +32139,7 @@ var BUNDLED_SKILLS = [
|
|
|
31973
32139
|
function formatMakerSkillStatus(_options = {}) {
|
|
31974
32140
|
const skillDocuments = BUNDLED_SKILLS.map((skill) => ({
|
|
31975
32141
|
name: skill.name,
|
|
31976
|
-
path:
|
|
32142
|
+
path: path10.join(resolveMakerSkillSourceDir(skill.name), "SKILL.md")
|
|
31977
32143
|
}));
|
|
31978
32144
|
return [
|
|
31979
32145
|
"TapTap Maker workflow guide documents",
|
|
@@ -32006,11 +32172,11 @@ function formatMakerSkillStatus(_options = {}) {
|
|
|
32006
32172
|
}
|
|
32007
32173
|
function resolveMakerSkillSourceDir(skillName = MAKER_LOCAL_SKILL_NAME) {
|
|
32008
32174
|
const candidates = [
|
|
32009
|
-
|
|
32175
|
+
path10.join(process.cwd(), "skills", skillName),
|
|
32010
32176
|
getBundledSkillSourceDir(skillName)
|
|
32011
32177
|
].filter(Boolean);
|
|
32012
32178
|
for (const candidate of candidates) {
|
|
32013
|
-
if (
|
|
32179
|
+
if (fs9.existsSync(path10.join(candidate, "SKILL.md"))) {
|
|
32014
32180
|
return candidate;
|
|
32015
32181
|
}
|
|
32016
32182
|
}
|
|
@@ -32023,13 +32189,13 @@ function getBundledSkillSourceDir(skillName) {
|
|
|
32023
32189
|
return null;
|
|
32024
32190
|
}
|
|
32025
32191
|
const bundlePath = fileURLToPath(__MAKER_BUNDLE_URL__);
|
|
32026
|
-
const packageRoot =
|
|
32027
|
-
return
|
|
32192
|
+
const packageRoot = path10.dirname(path10.dirname(bundlePath));
|
|
32193
|
+
return path10.join(packageRoot, "skills", skillName);
|
|
32028
32194
|
}
|
|
32029
32195
|
|
|
32030
32196
|
// src/maker/server/runtimeLogs.ts
|
|
32031
|
-
import
|
|
32032
|
-
import
|
|
32197
|
+
import fs10 from "node:fs";
|
|
32198
|
+
import path11 from "node:path";
|
|
32033
32199
|
var DEFAULT_RUNTIME_LOG_SINCE_SECONDS = 600;
|
|
32034
32200
|
var DEFAULT_RUNTIME_LOG_IDLE_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
32035
32201
|
var MAX_RUNTIME_LOG_WINDOW_SECONDS = 3600;
|
|
@@ -32170,19 +32336,19 @@ async function pullRuntimeLogs(options) {
|
|
|
32170
32336
|
}
|
|
32171
32337
|
function resetRuntimeLogs(projectRoot) {
|
|
32172
32338
|
const runtimeDir = getRuntimeLogDir(projectRoot);
|
|
32173
|
-
|
|
32339
|
+
fs10.mkdirSync(runtimeDir, { recursive: true });
|
|
32174
32340
|
for (const file2 of RUNTIME_LOG_FILES_TO_RESET) {
|
|
32175
|
-
|
|
32341
|
+
fs10.rmSync(path11.join(runtimeDir, file2), { force: true });
|
|
32176
32342
|
}
|
|
32177
32343
|
return runtimeDir;
|
|
32178
32344
|
}
|
|
32179
32345
|
function readRuntimeLogState(projectRoot) {
|
|
32180
32346
|
const statePath = getRuntimeLogStatePath(projectRoot);
|
|
32181
|
-
if (!
|
|
32347
|
+
if (!fs10.existsSync(statePath)) {
|
|
32182
32348
|
return null;
|
|
32183
32349
|
}
|
|
32184
32350
|
try {
|
|
32185
|
-
const state = JSON.parse(
|
|
32351
|
+
const state = JSON.parse(fs10.readFileSync(statePath, "utf8"));
|
|
32186
32352
|
return isRuntimeLogState(state) ? state : null;
|
|
32187
32353
|
} catch {
|
|
32188
32354
|
return null;
|
|
@@ -32210,9 +32376,9 @@ function normalizeRuntimeLogQueryResult(result) {
|
|
|
32210
32376
|
};
|
|
32211
32377
|
}
|
|
32212
32378
|
function writeRuntimeLogRawResponse(projectRoot, raw) {
|
|
32213
|
-
const rawPath =
|
|
32214
|
-
|
|
32215
|
-
|
|
32379
|
+
const rawPath = path11.join(getRuntimeLogDir(projectRoot), "last-query-runtime-logs-result.json");
|
|
32380
|
+
fs10.mkdirSync(path11.dirname(rawPath), { recursive: true });
|
|
32381
|
+
fs10.writeFileSync(
|
|
32216
32382
|
rawPath,
|
|
32217
32383
|
`${JSON.stringify({ capturedAt: (/* @__PURE__ */ new Date()).toISOString(), raw }, null, 2)}
|
|
32218
32384
|
`,
|
|
@@ -32221,7 +32387,7 @@ function writeRuntimeLogRawResponse(projectRoot, raw) {
|
|
|
32221
32387
|
return rawPath;
|
|
32222
32388
|
}
|
|
32223
32389
|
function appendRuntimeLogs(projectRoot, logs) {
|
|
32224
|
-
|
|
32390
|
+
fs10.mkdirSync(getRuntimeLogDir(projectRoot), { recursive: true });
|
|
32225
32391
|
if (logs.length === 0) {
|
|
32226
32392
|
return { files: [], written: 0 };
|
|
32227
32393
|
}
|
|
@@ -32229,7 +32395,7 @@ function appendRuntimeLogs(projectRoot, logs) {
|
|
|
32229
32395
|
let written = 0;
|
|
32230
32396
|
for (const log of logs) {
|
|
32231
32397
|
const line = JSON.stringify(compactRuntimeLogEntry(log));
|
|
32232
|
-
|
|
32398
|
+
fs10.appendFileSync(filePath, `${line}
|
|
32233
32399
|
`, "utf8");
|
|
32234
32400
|
written += 1;
|
|
32235
32401
|
}
|
|
@@ -32237,11 +32403,11 @@ function appendRuntimeLogs(projectRoot, logs) {
|
|
|
32237
32403
|
}
|
|
32238
32404
|
function writeRuntimeLogState(projectRoot, state) {
|
|
32239
32405
|
const statePath = getRuntimeLogStatePath(projectRoot);
|
|
32240
|
-
|
|
32406
|
+
fs10.mkdirSync(path11.dirname(statePath), { recursive: true });
|
|
32241
32407
|
const tempPath = `${statePath}.${process.pid}.${Date.now()}.tmp`;
|
|
32242
|
-
|
|
32408
|
+
fs10.writeFileSync(tempPath, `${JSON.stringify(state, null, 2)}
|
|
32243
32409
|
`, "utf8");
|
|
32244
|
-
|
|
32410
|
+
fs10.renameSync(tempPath, statePath);
|
|
32245
32411
|
}
|
|
32246
32412
|
function writeRuntimeLogFailureState(projectRoot, options) {
|
|
32247
32413
|
const nowIso = new Date(options.nowMs()).toISOString();
|
|
@@ -32273,13 +32439,13 @@ function isNonRetryableRuntimeLogError(error2) {
|
|
|
32273
32439
|
);
|
|
32274
32440
|
}
|
|
32275
32441
|
function getRuntimeLogDir(projectRoot) {
|
|
32276
|
-
return
|
|
32442
|
+
return path11.join(projectRoot, ".maker", "logs", "runtime");
|
|
32277
32443
|
}
|
|
32278
32444
|
function getRuntimeLogStatePath(projectRoot) {
|
|
32279
|
-
return
|
|
32445
|
+
return path11.join(getRuntimeLogDir(projectRoot), "state.json");
|
|
32280
32446
|
}
|
|
32281
32447
|
function getRuntimeLogPath(projectRoot) {
|
|
32282
|
-
return
|
|
32448
|
+
return path11.join(getRuntimeLogDir(projectRoot), MERGED_RUNTIME_LOG_FILE);
|
|
32283
32449
|
}
|
|
32284
32450
|
function resolveNextRuntimeLogCursor(result) {
|
|
32285
32451
|
const maxLogTime = result.logs.reduce((max, log) => {
|
|
@@ -32404,8 +32570,8 @@ function compactRuntimeLogEntry(entry) {
|
|
|
32404
32570
|
}
|
|
32405
32571
|
|
|
32406
32572
|
// src/maker/server/proxyAssets.ts
|
|
32407
|
-
import
|
|
32408
|
-
import
|
|
32573
|
+
import fs11 from "node:fs";
|
|
32574
|
+
import path12 from "node:path";
|
|
32409
32575
|
var IMAGE_ASSET_DIRS = ["assets/image"];
|
|
32410
32576
|
var VIDEO_ASSET_DIRS = ["assets/video"];
|
|
32411
32577
|
var AUDIO_ASSET_DIRS = ["assets/audio"];
|
|
@@ -32649,8 +32815,8 @@ async function materializeAsset(options) {
|
|
|
32649
32815
|
};
|
|
32650
32816
|
}
|
|
32651
32817
|
const bytes = Buffer.from(await response.arrayBuffer());
|
|
32652
|
-
|
|
32653
|
-
|
|
32818
|
+
fs11.mkdirSync(path12.dirname(absolutePath), { recursive: true });
|
|
32819
|
+
fs11.writeFileSync(absolutePath, bytes);
|
|
32654
32820
|
return { localPath: relativePath, absolutePath, download: { success: true } };
|
|
32655
32821
|
} catch (error2) {
|
|
32656
32822
|
return {
|
|
@@ -32664,12 +32830,12 @@ async function materializeAsset(options) {
|
|
|
32664
32830
|
function createUniqueAssetPath(options) {
|
|
32665
32831
|
const stem = `${sanitizeAssetBaseName(options.baseName)}_${formatAssetTimestamp(options.now)}`;
|
|
32666
32832
|
for (let index = 1; index <= 9999; index += 1) {
|
|
32667
|
-
const relativePath =
|
|
32833
|
+
const relativePath = path12.posix.join(
|
|
32668
32834
|
options.relativeDir,
|
|
32669
32835
|
`${stem}${index === 1 ? "" : `_${index}`}.${options.extension}`
|
|
32670
32836
|
);
|
|
32671
|
-
const absolutePath =
|
|
32672
|
-
if (!
|
|
32837
|
+
const absolutePath = path12.join(options.targetDir, ...relativePath.split("/"));
|
|
32838
|
+
if (!fs11.existsSync(absolutePath)) {
|
|
32673
32839
|
return { relativePath, absolutePath };
|
|
32674
32840
|
}
|
|
32675
32841
|
}
|
|
@@ -32752,7 +32918,7 @@ function findRegistryAssetByName(value, registry2, assetDirs) {
|
|
|
32752
32918
|
if (!isKnownAssetPath(localPath, assetDirs)) {
|
|
32753
32919
|
return false;
|
|
32754
32920
|
}
|
|
32755
|
-
const basename =
|
|
32921
|
+
const basename = path12.posix.basename(localPath);
|
|
32756
32922
|
const stem = basename.replace(/\.[^.]+$/, "");
|
|
32757
32923
|
return basename === value || stem === value || record2.name === value || record2.taskId === value;
|
|
32758
32924
|
});
|
|
@@ -32765,13 +32931,13 @@ function findRegistryAssetByName(value, registry2, assetDirs) {
|
|
|
32765
32931
|
}
|
|
32766
32932
|
function findLocalAssetByName(targetDir, value, assetDirs) {
|
|
32767
32933
|
var _a3;
|
|
32768
|
-
const hasExtension = Boolean(
|
|
32934
|
+
const hasExtension = Boolean(path12.extname(value));
|
|
32769
32935
|
const candidates = [];
|
|
32770
32936
|
for (const assetDir of assetDirs) {
|
|
32771
|
-
const absoluteDir =
|
|
32937
|
+
const absoluteDir = path12.join(targetDir, ...assetDir.split("/"));
|
|
32772
32938
|
let entries;
|
|
32773
32939
|
try {
|
|
32774
|
-
entries =
|
|
32940
|
+
entries = fs11.readdirSync(absoluteDir);
|
|
32775
32941
|
} catch {
|
|
32776
32942
|
continue;
|
|
32777
32943
|
}
|
|
@@ -32780,11 +32946,11 @@ function findLocalAssetByName(targetDir, value, assetDirs) {
|
|
|
32780
32946
|
if (hasExtension ? entry !== value : stem !== value && !stem.startsWith(`${value}_`)) {
|
|
32781
32947
|
continue;
|
|
32782
32948
|
}
|
|
32783
|
-
const absolutePath =
|
|
32949
|
+
const absolutePath = path12.join(absoluteDir, entry);
|
|
32784
32950
|
try {
|
|
32785
32951
|
candidates.push({
|
|
32786
|
-
localPath:
|
|
32787
|
-
mtimeMs:
|
|
32952
|
+
localPath: path12.posix.join(assetDir, entry),
|
|
32953
|
+
mtimeMs: fs11.statSync(absolutePath).mtimeMs
|
|
32788
32954
|
});
|
|
32789
32955
|
} catch {
|
|
32790
32956
|
}
|
|
@@ -32794,7 +32960,7 @@ function findLocalAssetByName(targetDir, value, assetDirs) {
|
|
|
32794
32960
|
return (_a3 = candidates[0]) == null ? void 0 : _a3.localPath;
|
|
32795
32961
|
}
|
|
32796
32962
|
function isKnownAssetPath(relativePath, assetDirs) {
|
|
32797
|
-
if (relativePath.startsWith("../") ||
|
|
32963
|
+
if (relativePath.startsWith("../") || path12.isAbsolute(relativePath)) {
|
|
32798
32964
|
return false;
|
|
32799
32965
|
}
|
|
32800
32966
|
return assetDirs.some(
|
|
@@ -32808,31 +32974,31 @@ function upsertGeneratedAssetRecord(targetDir, localPath, record2) {
|
|
|
32808
32974
|
const registry2 = readGeneratedAssetRegistry(targetDir);
|
|
32809
32975
|
registry2[localPath] = record2;
|
|
32810
32976
|
const registryPath = getGeneratedAssetRegistryPath(targetDir);
|
|
32811
|
-
|
|
32812
|
-
|
|
32977
|
+
fs11.mkdirSync(path12.dirname(registryPath), { recursive: true });
|
|
32978
|
+
fs11.writeFileSync(registryPath, `${JSON.stringify(registry2, null, 2)}
|
|
32813
32979
|
`, "utf8");
|
|
32814
32980
|
}
|
|
32815
32981
|
function readGeneratedAssetRegistry(targetDir) {
|
|
32816
32982
|
const registryPath = getGeneratedAssetRegistryPath(targetDir);
|
|
32817
|
-
if (!
|
|
32983
|
+
if (!fs11.existsSync(registryPath)) {
|
|
32818
32984
|
return {};
|
|
32819
32985
|
}
|
|
32820
32986
|
try {
|
|
32821
|
-
const parsed = JSON.parse(
|
|
32987
|
+
const parsed = JSON.parse(fs11.readFileSync(registryPath, "utf8"));
|
|
32822
32988
|
return isRecord(parsed) ? parsed : {};
|
|
32823
32989
|
} catch {
|
|
32824
32990
|
return {};
|
|
32825
32991
|
}
|
|
32826
32992
|
}
|
|
32827
32993
|
function getGeneratedAssetRegistryPath(targetDir) {
|
|
32828
|
-
return
|
|
32994
|
+
return path12.join(targetDir, ".maker", "assets", "generated-assets.json");
|
|
32829
32995
|
}
|
|
32830
32996
|
function normalizeAssetRegistryKey(targetDir, value) {
|
|
32831
32997
|
if (/^https?:\/\//i.test(value) || value.startsWith("data:")) {
|
|
32832
32998
|
return void 0;
|
|
32833
32999
|
}
|
|
32834
|
-
const relative =
|
|
32835
|
-
return relative.split(
|
|
33000
|
+
const relative = path12.isAbsolute(value) ? path12.relative(targetDir, value) : value;
|
|
33001
|
+
return relative.split(path12.sep).join("/");
|
|
32836
33002
|
}
|
|
32837
33003
|
function isRecord(value) {
|
|
32838
33004
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -32861,7 +33027,7 @@ function extensionFromUrl(url2) {
|
|
|
32861
33027
|
}
|
|
32862
33028
|
try {
|
|
32863
33029
|
const pathname = new URL(url2).pathname;
|
|
32864
|
-
const extension =
|
|
33030
|
+
const extension = path12.extname(pathname).replace(/^\./, "").toLowerCase();
|
|
32865
33031
|
return extension || void 0;
|
|
32866
33032
|
} catch {
|
|
32867
33033
|
return void 0;
|
|
@@ -32869,7 +33035,7 @@ function extensionFromUrl(url2) {
|
|
|
32869
33035
|
}
|
|
32870
33036
|
|
|
32871
33037
|
// src/maker/server/mcp.ts
|
|
32872
|
-
var VERSION = true ? "0.0.17-beta.
|
|
33038
|
+
var VERSION = true ? "0.0.17-beta.3" : "dev";
|
|
32873
33039
|
var DEFAULT_BUILD_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
32874
33040
|
var DEFAULT_PROXY_RETRY_ATTEMPTS = 5;
|
|
32875
33041
|
var DEFAULT_PROXY_RETRY_DELAY_MS = 30 * 1e3;
|
|
@@ -33009,12 +33175,14 @@ async function listRemoteProxyTools(options) {
|
|
|
33009
33175
|
env: options.env,
|
|
33010
33176
|
exposedTools: MAKER_REMOTE_PROXY_EXPOSED_TOOL_NAMES
|
|
33011
33177
|
});
|
|
33012
|
-
const transport =
|
|
33013
|
-
|
|
33014
|
-
|
|
33015
|
-
|
|
33016
|
-
|
|
33017
|
-
|
|
33178
|
+
const transport = trackMakerChildTransport(
|
|
33179
|
+
new StdioClientTransport({
|
|
33180
|
+
command: proxy.command,
|
|
33181
|
+
args: proxy.args,
|
|
33182
|
+
env: mergeStringEnv(process.env, proxy.envVars),
|
|
33183
|
+
stderr: "pipe"
|
|
33184
|
+
})
|
|
33185
|
+
);
|
|
33018
33186
|
const client = new Client(
|
|
33019
33187
|
{
|
|
33020
33188
|
name: "taptap-maker-tool-list-forwarder",
|
|
@@ -33045,12 +33213,14 @@ async function callRemoteProxyTool(options) {
|
|
|
33045
33213
|
});
|
|
33046
33214
|
const result = await retryMakerProxyOperation(
|
|
33047
33215
|
async () => {
|
|
33048
|
-
const transport =
|
|
33049
|
-
|
|
33050
|
-
|
|
33051
|
-
|
|
33052
|
-
|
|
33053
|
-
|
|
33216
|
+
const transport = trackMakerChildTransport(
|
|
33217
|
+
new StdioClientTransport({
|
|
33218
|
+
command: proxy.command,
|
|
33219
|
+
args: proxy.args,
|
|
33220
|
+
env: mergeStringEnv(process.env, proxy.envVars),
|
|
33221
|
+
stderr: "pipe"
|
|
33222
|
+
})
|
|
33223
|
+
);
|
|
33054
33224
|
const client = new Client(
|
|
33055
33225
|
{
|
|
33056
33226
|
name: "taptap-maker-tool-call-forwarder",
|
|
@@ -33220,6 +33390,37 @@ async function startMakerMcpServer() {
|
|
|
33220
33390
|
});
|
|
33221
33391
|
const transport = new StdioServerTransport();
|
|
33222
33392
|
await server.connect(transport);
|
|
33393
|
+
installMakerServerExitHandlers();
|
|
33394
|
+
}
|
|
33395
|
+
var MAKER_SERVER_SHUTDOWN_TIMEOUT_MS = 3e3;
|
|
33396
|
+
function installMakerServerExitHandlers() {
|
|
33397
|
+
let exiting = false;
|
|
33398
|
+
const shutdown = async (source) => {
|
|
33399
|
+
if (exiting) {
|
|
33400
|
+
return;
|
|
33401
|
+
}
|
|
33402
|
+
exiting = true;
|
|
33403
|
+
logLifecycleEvent(source, "Maker MCP server is exiting; closing active child transports.");
|
|
33404
|
+
const timeout = new Promise((resolve) => {
|
|
33405
|
+
var _a3;
|
|
33406
|
+
const timer = setTimeout(resolve, MAKER_SERVER_SHUTDOWN_TIMEOUT_MS);
|
|
33407
|
+
(_a3 = timer.unref) == null ? void 0 : _a3.call(timer);
|
|
33408
|
+
});
|
|
33409
|
+
await Promise.race([closeTrackedMakerChildTransports(), timeout]);
|
|
33410
|
+
process.exit(0);
|
|
33411
|
+
};
|
|
33412
|
+
process.stdin.once("end", () => {
|
|
33413
|
+
void shutdown("maker-server-stdin-end");
|
|
33414
|
+
});
|
|
33415
|
+
process.stdin.once("close", () => {
|
|
33416
|
+
void shutdown("maker-server-stdin-close");
|
|
33417
|
+
});
|
|
33418
|
+
process.once("SIGINT", () => {
|
|
33419
|
+
void shutdown("maker-server-sigint");
|
|
33420
|
+
});
|
|
33421
|
+
process.once("SIGTERM", () => {
|
|
33422
|
+
void shutdown("maker-server-sigterm");
|
|
33423
|
+
});
|
|
33223
33424
|
}
|
|
33224
33425
|
async function formatStatus(options = {}) {
|
|
33225
33426
|
var _a3;
|
|
@@ -33227,7 +33428,7 @@ async function formatStatus(options = {}) {
|
|
|
33227
33428
|
const env = getMakerEnvironment(void 0, targetDir);
|
|
33228
33429
|
const identify = identifyMakerProject({ cwd: targetDir });
|
|
33229
33430
|
const mcpCwd = process.cwd();
|
|
33230
|
-
const mcpCwdIdentify =
|
|
33431
|
+
const mcpCwdIdentify = path13.resolve(mcpCwd) === path13.resolve(targetDir) ? identify : identifyMakerProject({ cwd: mcpCwd });
|
|
33231
33432
|
const gitDirectoryStatus = inspectMakerDirectoryGitStatus(targetDir);
|
|
33232
33433
|
const remoteSyncText = identify.projectRoot && gitDirectoryStatus.isUsableMakerGitRepo && !options.skipRemoteSync ? await formatMakerRemoteSyncStatusSafely(identify.projectRoot) : identify.projectRoot && gitDirectoryStatus.isUsableMakerGitRepo ? formatMakerRemoteSyncSkipped() : "";
|
|
33233
33434
|
const pat = loadPat();
|
|
@@ -33347,10 +33548,10 @@ function formatMakerToolRegistrationCwdStatus(options) {
|
|
|
33347
33548
|
if (!options.projectRoot) {
|
|
33348
33549
|
return "";
|
|
33349
33550
|
}
|
|
33350
|
-
const mcpCwd =
|
|
33351
|
-
const targetDir =
|
|
33352
|
-
const projectRoot =
|
|
33353
|
-
const mcpProjectRoot = options.mcpProjectRoot ?
|
|
33551
|
+
const mcpCwd = path13.resolve(options.mcpCwd);
|
|
33552
|
+
const targetDir = path13.resolve(options.targetDir);
|
|
33553
|
+
const projectRoot = path13.resolve(options.projectRoot);
|
|
33554
|
+
const mcpProjectRoot = options.mcpProjectRoot ? path13.resolve(options.mcpProjectRoot) : void 0;
|
|
33354
33555
|
if (mcpProjectRoot === projectRoot) {
|
|
33355
33556
|
return "";
|
|
33356
33557
|
}
|
|
@@ -33512,7 +33713,7 @@ function formatAiDialogueDirectoryHint(targetDir) {
|
|
|
33512
33713
|
}
|
|
33513
33714
|
function resolveMakerToolTargetDir(targetDir) {
|
|
33514
33715
|
if (targetDir) {
|
|
33515
|
-
return
|
|
33716
|
+
return path13.resolve(targetDir);
|
|
33516
33717
|
}
|
|
33517
33718
|
return process.cwd();
|
|
33518
33719
|
}
|
|
@@ -33612,14 +33813,14 @@ function formatStatusProjectList(projects) {
|
|
|
33612
33813
|
].filter((line) => line !== void 0).join("\n");
|
|
33613
33814
|
}
|
|
33614
33815
|
function formatClonePartialStateLines(targetDir) {
|
|
33615
|
-
const resolvedTargetDir =
|
|
33816
|
+
const resolvedTargetDir = path13.resolve(targetDir);
|
|
33616
33817
|
const identify = identifyMakerProject({ cwd: resolvedTargetDir });
|
|
33617
33818
|
const gitStatus = inspectMakerDirectoryGitStatus(resolvedTargetDir);
|
|
33618
33819
|
const devKitStatus = inspectAiDevKit(resolvedTargetDir);
|
|
33619
|
-
const stagedDevKitGitignorePath =
|
|
33820
|
+
const stagedDevKitGitignorePath = path13.join(resolvedTargetDir, DEV_KIT_GITIGNORE_STAGING_FILE);
|
|
33620
33821
|
const projectBound = Boolean(identify.projectId);
|
|
33621
33822
|
const gitInitialized = Boolean(
|
|
33622
|
-
gitStatus.isOwnGitRoot ||
|
|
33823
|
+
gitStatus.isOwnGitRoot || fs12.existsSync(path13.join(resolvedTargetDir, ".git"))
|
|
33623
33824
|
);
|
|
33624
33825
|
const safeToRetry = !projectBound;
|
|
33625
33826
|
return [
|
|
@@ -33633,7 +33834,7 @@ function formatClonePartialStateLines(targetDir) {
|
|
|
33633
33834
|
identify.configPath ? `- config: ${identify.configPath}` : "",
|
|
33634
33835
|
`- ai_dev_kit_present: ${devKitStatus.ready ? "yes" : "no"}`,
|
|
33635
33836
|
`- ai_dev_kit_missing_entries: ${devKitStatus.missingEntries.join(", ") || "(none)"}`,
|
|
33636
|
-
`- staged_dev_kit_gitignore: ${
|
|
33837
|
+
`- staged_dev_kit_gitignore: ${fs12.existsSync(stagedDevKitGitignorePath) ? "yes" : "no"}`,
|
|
33637
33838
|
`- safe_to_retry: ${safeToRetry ? "yes" : "no"}`,
|
|
33638
33839
|
safeToRetry ? "- next_step: 可以直接重试 taptap-maker init;如果连续失败,建议换一个全新的独立目录重新 clone。" : "- next_step: 当前目录已经有 Maker 绑定信息;先运行 taptap-maker doctor 或读取 maker://status 确认状态。"
|
|
33639
33840
|
].filter(Boolean);
|
|
@@ -33706,7 +33907,7 @@ function resolveEmbeddedProxyCommand(options) {
|
|
|
33706
33907
|
}
|
|
33707
33908
|
return {
|
|
33708
33909
|
command: process.execPath,
|
|
33709
|
-
args: [
|
|
33910
|
+
args: [path13.resolve(makerEntry), "__maker-proxy"]
|
|
33710
33911
|
};
|
|
33711
33912
|
}
|
|
33712
33913
|
function createToolProgressReporter(progressToken, extra, operationName) {
|
|
@@ -33908,12 +34109,14 @@ async function runRemoteBuildCurrentDirectory(options, targetDir) {
|
|
|
33908
34109
|
const timeoutMs = options.timeoutMs || DEFAULT_BUILD_TIMEOUT_MS;
|
|
33909
34110
|
const result = await retryMakerProxyOperation(
|
|
33910
34111
|
async () => {
|
|
33911
|
-
const transport =
|
|
33912
|
-
|
|
33913
|
-
|
|
33914
|
-
|
|
33915
|
-
|
|
33916
|
-
|
|
34112
|
+
const transport = trackMakerChildTransport(
|
|
34113
|
+
new StdioClientTransport({
|
|
34114
|
+
command: proxy.command,
|
|
34115
|
+
args: proxy.args,
|
|
34116
|
+
env: mergeStringEnv(process.env, proxy.envVars),
|
|
34117
|
+
stderr: "pipe"
|
|
34118
|
+
})
|
|
34119
|
+
);
|
|
33917
34120
|
const client = new Client(
|
|
33918
34121
|
{
|
|
33919
34122
|
name: "taptap-maker-build-forwarder",
|
|
@@ -34045,18 +34248,18 @@ async function attachRuntimeLogWatch(buildResult, startWatch) {
|
|
|
34045
34248
|
}
|
|
34046
34249
|
}
|
|
34047
34250
|
async function startRuntimeLogWatch(buildResult) {
|
|
34048
|
-
const runtimeDir =
|
|
34049
|
-
|
|
34050
|
-
const stdoutLog =
|
|
34051
|
-
const stderrLog =
|
|
34052
|
-
const pidFile =
|
|
34251
|
+
const runtimeDir = path13.join(buildResult.projectRoot, ".maker", "logs", "runtime");
|
|
34252
|
+
fs12.mkdirSync(runtimeDir, { recursive: true });
|
|
34253
|
+
const stdoutLog = path13.join(runtimeDir, "watcher.out.log");
|
|
34254
|
+
const stderrLog = path13.join(runtimeDir, "watcher.err.log");
|
|
34255
|
+
const pidFile = path13.join(runtimeDir, "watcher.pid");
|
|
34053
34256
|
const previous = stopExistingRuntimeLogWatcher(pidFile);
|
|
34054
|
-
const outFd =
|
|
34055
|
-
const errFd =
|
|
34257
|
+
const outFd = fs12.openSync(stdoutLog, "a");
|
|
34258
|
+
const errFd = fs12.openSync(stderrLog, "a");
|
|
34056
34259
|
const command = formatRuntimeLogWatchCommand(buildResult);
|
|
34057
34260
|
if (previous.previousStopError) {
|
|
34058
|
-
|
|
34059
|
-
|
|
34261
|
+
fs12.closeSync(outFd);
|
|
34262
|
+
fs12.closeSync(errFd);
|
|
34060
34263
|
return {
|
|
34061
34264
|
started: false,
|
|
34062
34265
|
command: command.text,
|
|
@@ -34119,18 +34322,18 @@ async function startRuntimeLogWatch(buildResult) {
|
|
|
34119
34322
|
...previous
|
|
34120
34323
|
};
|
|
34121
34324
|
} finally {
|
|
34122
|
-
|
|
34123
|
-
|
|
34325
|
+
fs12.closeSync(outFd);
|
|
34326
|
+
fs12.closeSync(errFd);
|
|
34124
34327
|
}
|
|
34125
34328
|
}
|
|
34126
34329
|
function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
|
|
34127
|
-
if (!
|
|
34330
|
+
if (!fs12.existsSync(pidFile)) {
|
|
34128
34331
|
return {};
|
|
34129
34332
|
}
|
|
34130
34333
|
const pidState = readRuntimeLogWatcherPidState(pidFile);
|
|
34131
34334
|
const pid = pidState == null ? void 0 : pidState.pid;
|
|
34132
34335
|
if (!Number.isInteger(pid) || pid <= 0) {
|
|
34133
|
-
|
|
34336
|
+
fs12.rmSync(pidFile, { force: true });
|
|
34134
34337
|
return {};
|
|
34135
34338
|
}
|
|
34136
34339
|
try {
|
|
@@ -34138,7 +34341,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
|
|
|
34138
34341
|
const processCommand = (options.getProcessCommand || getProcessCommand)(pid);
|
|
34139
34342
|
const verifiedCommand = getVerifiedRuntimeLogWatcherCommand(processCommand, pidState);
|
|
34140
34343
|
if (!verifiedCommand) {
|
|
34141
|
-
|
|
34344
|
+
fs12.rmSync(pidFile, { force: true });
|
|
34142
34345
|
return {
|
|
34143
34346
|
previousPid: pid,
|
|
34144
34347
|
previousStopped: false,
|
|
@@ -34148,7 +34351,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
|
|
|
34148
34351
|
process.kill(pid, "SIGTERM");
|
|
34149
34352
|
const stopped = (options.waitForExit || waitForProcessExit)(pid, WATCHER_STOP_TIMEOUT_MS);
|
|
34150
34353
|
if (stopped) {
|
|
34151
|
-
|
|
34354
|
+
fs12.rmSync(pidFile, { force: true });
|
|
34152
34355
|
return { previousPid: pid, previousStopped: true };
|
|
34153
34356
|
}
|
|
34154
34357
|
return {
|
|
@@ -34157,7 +34360,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
|
|
|
34157
34360
|
previousStopError: `process ${pid} did not exit after SIGTERM within ${WATCHER_STOP_TIMEOUT_MS}ms`
|
|
34158
34361
|
};
|
|
34159
34362
|
} catch (error2) {
|
|
34160
|
-
|
|
34363
|
+
fs12.rmSync(pidFile, { force: true });
|
|
34161
34364
|
const code = error2 && typeof error2 === "object" && "code" in error2 ? String(error2.code) : "";
|
|
34162
34365
|
if (code === "ESRCH") {
|
|
34163
34366
|
return { previousPid: pid, previousStopped: false };
|
|
@@ -34170,7 +34373,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
|
|
|
34170
34373
|
}
|
|
34171
34374
|
}
|
|
34172
34375
|
function readRuntimeLogWatcherPidState(pidFile) {
|
|
34173
|
-
const raw =
|
|
34376
|
+
const raw = fs12.readFileSync(pidFile, "utf8").trim();
|
|
34174
34377
|
if (!raw) {
|
|
34175
34378
|
return null;
|
|
34176
34379
|
}
|
|
@@ -34186,7 +34389,7 @@ function readRuntimeLogWatcherPidState(pidFile) {
|
|
|
34186
34389
|
}
|
|
34187
34390
|
}
|
|
34188
34391
|
function writeRuntimeLogWatcherPidFile(pidFile, state) {
|
|
34189
|
-
|
|
34392
|
+
fs12.writeFileSync(pidFile, `${JSON.stringify(state, null, 2)}
|
|
34190
34393
|
`, "utf8");
|
|
34191
34394
|
}
|
|
34192
34395
|
function getProcessCommand(pid) {
|
|
@@ -34272,10 +34475,10 @@ function formatRuntimeLogWatchCommand(buildResult) {
|
|
|
34272
34475
|
};
|
|
34273
34476
|
}
|
|
34274
34477
|
function resolveMakerCliEntry() {
|
|
34275
|
-
return process.argv[1] ||
|
|
34478
|
+
return process.argv[1] || path13.resolve(process.cwd(), "dist", "maker.js");
|
|
34276
34479
|
}
|
|
34277
34480
|
function getRuntimeLogFilePath(projectRoot) {
|
|
34278
|
-
return
|
|
34481
|
+
return path13.join(projectRoot, ".maker", "logs", "runtime", "runtime.log");
|
|
34279
34482
|
}
|
|
34280
34483
|
async function refreshMakerPreview(buildResult) {
|
|
34281
34484
|
const makerEnv = buildResult.env === "rnd" || buildResult.env === "production" ? buildResult.env : void 0;
|
|
@@ -34326,12 +34529,14 @@ async function refreshMakerPreview(buildResult) {
|
|
|
34326
34529
|
}
|
|
34327
34530
|
function createRemoteRuntimeLogClient(proxy, timeoutMs = 60 * 1e3, options = {}) {
|
|
34328
34531
|
let client;
|
|
34329
|
-
const createTransport = options.createTransport || (() =>
|
|
34330
|
-
|
|
34331
|
-
|
|
34332
|
-
|
|
34333
|
-
|
|
34334
|
-
|
|
34532
|
+
const createTransport = options.createTransport || (() => trackMakerChildTransport(
|
|
34533
|
+
new HiddenStdioClientTransport({
|
|
34534
|
+
command: proxy.command,
|
|
34535
|
+
args: proxy.args,
|
|
34536
|
+
env: mergeStringEnv(process.env, proxy.envVars),
|
|
34537
|
+
stderr: "pipe"
|
|
34538
|
+
})
|
|
34539
|
+
));
|
|
34335
34540
|
const createClient = options.createClient || (() => new Client(
|
|
34336
34541
|
{
|
|
34337
34542
|
name: "taptap-maker-runtime-log-forwarder",
|
|
@@ -34406,7 +34611,7 @@ function createBuildArgs(projectRoot, options) {
|
|
|
34406
34611
|
if (options.scriptsPath) {
|
|
34407
34612
|
buildArgs.scriptsPath = options.scriptsPath;
|
|
34408
34613
|
}
|
|
34409
|
-
if (!options.entry && !options.scriptsPath && !options.entryClient && !options.entryServer && !options.multiplayer &&
|
|
34614
|
+
if (!options.entry && !options.scriptsPath && !options.entryClient && !options.entryServer && !options.multiplayer && fs12.existsSync(path13.join(projectRoot, "scripts", "main.lua"))) {
|
|
34410
34615
|
buildArgs.entry = "main.lua";
|
|
34411
34616
|
buildArgs.scriptsPath = "scripts";
|
|
34412
34617
|
}
|
|
@@ -34418,7 +34623,7 @@ function createBuildArgs(projectRoot, options) {
|
|
|
34418
34623
|
}
|
|
34419
34624
|
if (options.multiplayer) {
|
|
34420
34625
|
buildArgs.multiplayer = options.multiplayer;
|
|
34421
|
-
} else if (!
|
|
34626
|
+
} else if (!fs12.existsSync(path13.join(projectRoot, ".project", "settings.json"))) {
|
|
34422
34627
|
buildArgs.multiplayer = { enabled: false };
|
|
34423
34628
|
}
|
|
34424
34629
|
return buildArgs;
|
|
@@ -34593,11 +34798,11 @@ function formatRuntimeLogWatchNextActionLines(result) {
|
|
|
34593
34798
|
((_a3 = result.runtimeLogWatch) == null ? void 0 : _a3.pid) ? `- watch_pid: ${result.runtimeLogWatch.pid}` : "",
|
|
34594
34799
|
`- watch_command: ${command}`,
|
|
34595
34800
|
((_b = result.runtimeLogWatch) == null ? void 0 : _b.command) ? `- actual_watch_command: ${result.runtimeLogWatch.command}` : "",
|
|
34596
|
-
`- local_file: ${
|
|
34801
|
+
`- local_file: ${path13.join(result.projectRoot, ".maker", "logs", "runtime", "runtime.log")}`,
|
|
34597
34802
|
((_c = result.runtimeLogWatch) == null ? void 0 : _c.stdoutLog) ? `- watcher_stdout: ${result.runtimeLogWatch.stdoutLog}` : "",
|
|
34598
34803
|
((_d = result.runtimeLogWatch) == null ? void 0 : _d.stderrLog) ? `- watcher_stderr: ${result.runtimeLogWatch.stderrLog}` : "",
|
|
34599
34804
|
((_e = result.runtimeLogWatch) == null ? void 0 : _e.pidFile) ? `- watcher_pid_file: ${result.runtimeLogWatch.pidFile}` : "",
|
|
34600
|
-
`- state_file: ${
|
|
34805
|
+
`- state_file: ${path13.join(result.projectRoot, ".maker", "logs", "runtime", "state.json")}`,
|
|
34601
34806
|
((_f = result.runtimeLogWatch) == null ? void 0 : _f.previousPid) ? `- previous_watch_pid: ${result.runtimeLogWatch.previousPid}` : "",
|
|
34602
34807
|
((_g = result.runtimeLogWatch) == null ? void 0 : _g.previousStopped) !== void 0 ? `- previous_watch_stopped: ${result.runtimeLogWatch.previousStopped ? "yes" : "no"}` : "",
|
|
34603
34808
|
((_h = result.runtimeLogWatch) == null ? void 0 : _h.previousStopError) ? `- previous_watch_stop_error: ${result.runtimeLogWatch.previousStopError}` : "",
|
|
@@ -34714,9 +34919,9 @@ function indent(value) {
|
|
|
34714
34919
|
// src/maker/cli/commands.ts
|
|
34715
34920
|
import { spawnSync as spawnSync8 } from "node:child_process";
|
|
34716
34921
|
import crypto2 from "node:crypto";
|
|
34717
|
-
import
|
|
34922
|
+
import fs13 from "node:fs";
|
|
34718
34923
|
import os4 from "node:os";
|
|
34719
|
-
import
|
|
34924
|
+
import path14 from "node:path";
|
|
34720
34925
|
import readline from "node:readline/promises";
|
|
34721
34926
|
import { stdin as input, stdout as output } from "node:process";
|
|
34722
34927
|
|
|
@@ -34886,6 +35091,10 @@ async function runMakerCli(argv) {
|
|
|
34886
35091
|
printHelp();
|
|
34887
35092
|
return;
|
|
34888
35093
|
}
|
|
35094
|
+
if (parsed.options.help || parsed.options.h) {
|
|
35095
|
+
printHelp();
|
|
35096
|
+
return;
|
|
35097
|
+
}
|
|
34889
35098
|
if (command === "init") {
|
|
34890
35099
|
await runInit(parsed, ctx);
|
|
34891
35100
|
return;
|
|
@@ -34983,7 +35192,7 @@ function toOptionKey(value) {
|
|
|
34983
35192
|
}
|
|
34984
35193
|
async function runInit(parsed, ctx) {
|
|
34985
35194
|
rejectPackageOption(parsed);
|
|
34986
|
-
const targetDir =
|
|
35195
|
+
const targetDir = path14.resolve(stringOption(parsed, "target_dir") || process.cwd());
|
|
34987
35196
|
const env = makerEnvOption(parsed);
|
|
34988
35197
|
const skipConfirm = booleanOption(parsed, "skip_confirm");
|
|
34989
35198
|
const skipMcpInstall = booleanOption(parsed, "skip_mcp_install");
|
|
@@ -35076,7 +35285,7 @@ async function runInit(parsed, ctx) {
|
|
|
35076
35285
|
}
|
|
35077
35286
|
async function runDoctor(parsed, ctx) {
|
|
35078
35287
|
var _a3, _b;
|
|
35079
|
-
const targetDir =
|
|
35288
|
+
const targetDir = path14.resolve(stringOption(parsed, "target_dir") || process.cwd());
|
|
35080
35289
|
const env = makerEnvOption(parsed);
|
|
35081
35290
|
const git = checkGitEnvironment();
|
|
35082
35291
|
const python = checkMakerPythonEnvironment();
|
|
@@ -35088,6 +35297,10 @@ async function runDoctor(parsed, ctx) {
|
|
|
35088
35297
|
const projectRoot = identify.projectRoot || targetDir;
|
|
35089
35298
|
const devKit = inspectAiDevKit(projectRoot);
|
|
35090
35299
|
const devKitUpdate = await checkAiDevKitUpdate(projectRoot, { environment: env });
|
|
35300
|
+
const orphanProcessCheck = inspectMakerOrphanProcesses();
|
|
35301
|
+
const mcpToolsAvailability = inspectMakerMcpToolsAvailability({
|
|
35302
|
+
makerProjectDir: identify.projectRoot
|
|
35303
|
+
});
|
|
35091
35304
|
if (ctx.json) {
|
|
35092
35305
|
writeJson({
|
|
35093
35306
|
env,
|
|
@@ -35100,7 +35313,9 @@ async function runDoctor(parsed, ctx) {
|
|
|
35100
35313
|
lua_lsp: luaLsp,
|
|
35101
35314
|
project: identify,
|
|
35102
35315
|
dev_kit: devKit,
|
|
35103
|
-
dev_kit_update: devKitUpdate
|
|
35316
|
+
dev_kit_update: devKitUpdate,
|
|
35317
|
+
mcp_tools_availability: mcpToolsAvailability,
|
|
35318
|
+
orphan_process_check: orphanProcessCheck
|
|
35104
35319
|
});
|
|
35105
35320
|
return;
|
|
35106
35321
|
}
|
|
@@ -35134,11 +35349,118 @@ async function runDoctor(parsed, ctx) {
|
|
|
35134
35349
|
`- update_available: ${devKitUpdate.updateAvailable ? "yes" : "no"}`,
|
|
35135
35350
|
devKitUpdate.versionCheckError ? `- version_check: ${devKitUpdate.versionCheckError}` : "",
|
|
35136
35351
|
"",
|
|
35352
|
+
formatMakerMcpToolsAvailability(mcpToolsAvailability),
|
|
35353
|
+
"",
|
|
35354
|
+
formatMakerOrphanProcessStatus(orphanProcessCheck),
|
|
35355
|
+
"",
|
|
35137
35356
|
formatMakerSkillStatus({ projectRoot }),
|
|
35138
35357
|
""
|
|
35139
35358
|
].filter(Boolean).join("\n")
|
|
35140
35359
|
);
|
|
35141
35360
|
}
|
|
35361
|
+
function inspectMakerMcpToolsAvailability(options) {
|
|
35362
|
+
const aiPwd = path14.resolve(process.cwd());
|
|
35363
|
+
const aiPwdIdentify = identifyMakerProject({ cwd: aiPwd });
|
|
35364
|
+
const makerProjectDir = options.makerProjectDir ? path14.resolve(options.makerProjectDir) : void 0;
|
|
35365
|
+
if (!makerProjectDir) {
|
|
35366
|
+
return {
|
|
35367
|
+
tools_visibility: "refresh_ai_client_if_missing",
|
|
35368
|
+
pwd_alignment: "not_bound",
|
|
35369
|
+
ai_pwd: aiPwd,
|
|
35370
|
+
ai_pwd_project_dir: aiPwdIdentify.projectRoot
|
|
35371
|
+
};
|
|
35372
|
+
}
|
|
35373
|
+
return {
|
|
35374
|
+
tools_visibility: "refresh_ai_client_if_missing",
|
|
35375
|
+
pwd_alignment: aiPwdIdentify.projectRoot && samePath2(aiPwdIdentify.projectRoot, makerProjectDir) ? "same_project" : "cwd_mismatch",
|
|
35376
|
+
maker_project_dir: makerProjectDir,
|
|
35377
|
+
ai_pwd: aiPwd,
|
|
35378
|
+
ai_pwd_project_dir: aiPwdIdentify.projectRoot
|
|
35379
|
+
};
|
|
35380
|
+
}
|
|
35381
|
+
function formatMakerMcpToolsAvailability(availability) {
|
|
35382
|
+
const lines = [
|
|
35383
|
+
"Maker MCP tools availability",
|
|
35384
|
+
`- tools_visibility: ${availability.tools_visibility}`,
|
|
35385
|
+
"- hint: If Maker proxy tools are missing in this AI chat, this is common after install.",
|
|
35386
|
+
"- next_action: Restart the AI client or open a new AI conversation; /mcp clients can Reconnect taptap-maker.",
|
|
35387
|
+
`- pwd_alignment: ${availability.pwd_alignment}`
|
|
35388
|
+
];
|
|
35389
|
+
if (availability.pwd_alignment === "cwd_mismatch") {
|
|
35390
|
+
lines.push(`- maker_project_dir: ${availability.maker_project_dir}`);
|
|
35391
|
+
lines.push(`- ai_pwd: ${availability.ai_pwd}`);
|
|
35392
|
+
lines.push(`- ai_pwd_project_dir: ${availability.ai_pwd_project_dir || "(none)"}`);
|
|
35393
|
+
lines.push(
|
|
35394
|
+
"- impact: Maker proxy tools may not appear because tools/list uses the AI client pwd."
|
|
35395
|
+
);
|
|
35396
|
+
lines.push(
|
|
35397
|
+
"- next_action: Run the AI client from the Maker project directory, or reinstall MCP with --target-dir."
|
|
35398
|
+
);
|
|
35399
|
+
}
|
|
35400
|
+
return lines.join("\n");
|
|
35401
|
+
}
|
|
35402
|
+
function samePath2(left, right) {
|
|
35403
|
+
return normalizePathForCompare2(left) === normalizePathForCompare2(right);
|
|
35404
|
+
}
|
|
35405
|
+
function normalizePathForCompare2(value) {
|
|
35406
|
+
const resolved = path14.resolve(value);
|
|
35407
|
+
try {
|
|
35408
|
+
return fs13.realpathSync.native(resolved);
|
|
35409
|
+
} catch {
|
|
35410
|
+
return resolved;
|
|
35411
|
+
}
|
|
35412
|
+
}
|
|
35413
|
+
function inspectMakerOrphanProcesses() {
|
|
35414
|
+
if (process.platform === "win32") {
|
|
35415
|
+
return { status: "not_supported_on_windows", processes: [] };
|
|
35416
|
+
}
|
|
35417
|
+
const result = spawnSync8("ps", ["-axo", "pid,ppid,pcpu,etime,command"], {
|
|
35418
|
+
encoding: "utf8"
|
|
35419
|
+
});
|
|
35420
|
+
if (result.status !== 0 || typeof result.stdout !== "string") {
|
|
35421
|
+
return { status: "check_failed", processes: [] };
|
|
35422
|
+
}
|
|
35423
|
+
const processes = result.stdout.split(/\r?\n/).slice(1).map((line) => parseMakerProcessLine(line)).filter((processInfo) => Boolean(processInfo));
|
|
35424
|
+
return { status: "ok", processes };
|
|
35425
|
+
}
|
|
35426
|
+
function parseMakerProcessLine(line) {
|
|
35427
|
+
const match = line.trim().match(/^(\d+)\s+(\d+)\s+([0-9.]+)\s+(\S+)\s+(.+)$/);
|
|
35428
|
+
if (!match) {
|
|
35429
|
+
return null;
|
|
35430
|
+
}
|
|
35431
|
+
const [, pid, ppid, cpu, elapsed, command] = match;
|
|
35432
|
+
if (ppid !== "1") {
|
|
35433
|
+
return null;
|
|
35434
|
+
}
|
|
35435
|
+
if (/\blogs\b.*\bwatch\b/.test(command)) {
|
|
35436
|
+
return null;
|
|
35437
|
+
}
|
|
35438
|
+
if (!/\bmaker\.js\b/.test(command) && !/\btaptap-maker\b/.test(command)) {
|
|
35439
|
+
return null;
|
|
35440
|
+
}
|
|
35441
|
+
return { pid, ppid, cpu, elapsed, command };
|
|
35442
|
+
}
|
|
35443
|
+
function formatMakerOrphanProcessStatus(check2) {
|
|
35444
|
+
const lines = ["Maker orphan process check"];
|
|
35445
|
+
if (check2.status === "not_supported_on_windows") {
|
|
35446
|
+
return [...lines, "- orphan_processes: not_supported_on_windows"].join("\n");
|
|
35447
|
+
}
|
|
35448
|
+
if (check2.status === "check_failed") {
|
|
35449
|
+
return [...lines, "- orphan_processes: check_failed"].join("\n");
|
|
35450
|
+
}
|
|
35451
|
+
if (check2.processes.length === 0) {
|
|
35452
|
+
return [...lines, "- orphan_processes: none"].join("\n");
|
|
35453
|
+
}
|
|
35454
|
+
for (const processInfo of check2.processes) {
|
|
35455
|
+
lines.push(
|
|
35456
|
+
`- pid: ${processInfo.pid} ppid: ${processInfo.ppid} cpu: ${processInfo.cpu} elapsed: ${processInfo.elapsed}`
|
|
35457
|
+
);
|
|
35458
|
+
lines.push(` command: ${processInfo.command}`);
|
|
35459
|
+
}
|
|
35460
|
+
lines.push("- action: safe_to_kill_orphan_maker_processes");
|
|
35461
|
+
lines.push("- note: these PPID=1 Maker processes are detached from the AI client.");
|
|
35462
|
+
return lines.join("\n");
|
|
35463
|
+
}
|
|
35142
35464
|
function ensureInitPythonReady(ctx, targetDir, env) {
|
|
35143
35465
|
const initial = checkMakerPythonEnvironment();
|
|
35144
35466
|
if (initial.ready) {
|
|
@@ -35401,7 +35723,7 @@ async function runPatSet(parsed, ctx) {
|
|
|
35401
35723
|
}
|
|
35402
35724
|
async function resolvePatSet(parsed, ctx) {
|
|
35403
35725
|
if (booleanOption(parsed, "pat_stdin") || booleanOption(parsed, "pat_from_stdin")) {
|
|
35404
|
-
const pat =
|
|
35726
|
+
const pat = fs13.readFileSync(0, "utf8").trim();
|
|
35405
35727
|
if (!pat) {
|
|
35406
35728
|
throw new Error("No PAT found on stdin.");
|
|
35407
35729
|
}
|
|
@@ -35431,7 +35753,7 @@ async function runMcpInstall(parsed, ctx) {
|
|
|
35431
35753
|
env: makerEnvOption(parsed),
|
|
35432
35754
|
pkg: MAKER_NPM_PACKAGE,
|
|
35433
35755
|
mcpName: stringOption(parsed, "name") || DEFAULT_MCP_NAME,
|
|
35434
|
-
cwd: explicitTargetDir ?
|
|
35756
|
+
cwd: explicitTargetDir ? path14.resolve(explicitTargetDir) : void 0
|
|
35435
35757
|
});
|
|
35436
35758
|
if (ctx.json) {
|
|
35437
35759
|
writeJson(results);
|
|
@@ -35534,7 +35856,7 @@ function getMcpVerifyNextSteps(mode, commandText) {
|
|
|
35534
35856
|
];
|
|
35535
35857
|
}
|
|
35536
35858
|
async function runDevKitUpdate(parsed, ctx) {
|
|
35537
|
-
const targetDir =
|
|
35859
|
+
const targetDir = path14.resolve(stringOption(parsed, "target_dir") || process.cwd());
|
|
35538
35860
|
const result = await installAiDevKit({
|
|
35539
35861
|
targetDir,
|
|
35540
35862
|
preserveExisting: false,
|
|
@@ -35546,7 +35868,7 @@ async function runDevKitUpdate(parsed, ctx) {
|
|
|
35546
35868
|
emitDevKitSkillInstallerFailure(ctx, result.skillInstaller, "AI skills install failed");
|
|
35547
35869
|
}
|
|
35548
35870
|
async function runLogsWatch(parsed, ctx) {
|
|
35549
|
-
const targetDir =
|
|
35871
|
+
const targetDir = path14.resolve(stringOption(parsed, "target_dir") || process.cwd());
|
|
35550
35872
|
const intervalMs = parseDurationMs(stringOption(parsed, "interval") || "5s");
|
|
35551
35873
|
const timeoutMs = numberOption(parsed, "timeout_ms") ?? 60 * 1e3;
|
|
35552
35874
|
const maxPolls = numberOption(parsed, "max_polls");
|
|
@@ -35556,9 +35878,9 @@ async function runLogsWatch(parsed, ctx) {
|
|
|
35556
35878
|
serverUrl: stringOption(parsed, "server_url"),
|
|
35557
35879
|
env: makerEnvOption(parsed)
|
|
35558
35880
|
});
|
|
35559
|
-
const runtimeDir =
|
|
35560
|
-
const runtimeLog =
|
|
35561
|
-
const pidFile =
|
|
35881
|
+
const runtimeDir = path14.join(proxy.projectRoot, ".maker", "logs", "runtime");
|
|
35882
|
+
const runtimeLog = path14.join(runtimeDir, "runtime.log");
|
|
35883
|
+
const pidFile = path14.join(runtimeDir, "watcher.pid");
|
|
35562
35884
|
const replacedWatcher = registerRuntimeLogWatcherProcess(pidFile);
|
|
35563
35885
|
const runtimeLogClient = createRemoteRuntimeLogClient(proxy, timeoutMs);
|
|
35564
35886
|
emit(ctx, "logs_watch_start", "Maker runtime log watcher started", {
|
|
@@ -35603,10 +35925,10 @@ async function runLogsWatch(parsed, ctx) {
|
|
|
35603
35925
|
}
|
|
35604
35926
|
}
|
|
35605
35927
|
function registerRuntimeLogWatcherProcess(pidFile) {
|
|
35606
|
-
|
|
35928
|
+
fs13.mkdirSync(path14.dirname(pidFile), { recursive: true });
|
|
35607
35929
|
const existingPid = readPidFile(pidFile);
|
|
35608
35930
|
const previous = existingPid && existingPid !== process.pid ? stopExistingRuntimeLogWatcher(pidFile) : {};
|
|
35609
|
-
|
|
35931
|
+
fs13.writeFileSync(
|
|
35610
35932
|
pidFile,
|
|
35611
35933
|
`${JSON.stringify(
|
|
35612
35934
|
{
|
|
@@ -35624,10 +35946,10 @@ function registerRuntimeLogWatcherProcess(pidFile) {
|
|
|
35624
35946
|
return previous;
|
|
35625
35947
|
}
|
|
35626
35948
|
function readPidFile(pidFile) {
|
|
35627
|
-
if (!
|
|
35949
|
+
if (!fs13.existsSync(pidFile)) {
|
|
35628
35950
|
return void 0;
|
|
35629
35951
|
}
|
|
35630
|
-
const raw =
|
|
35952
|
+
const raw = fs13.readFileSync(pidFile, "utf8").trim();
|
|
35631
35953
|
let pid = Number(raw);
|
|
35632
35954
|
if (!Number.isInteger(pid) || pid <= 0) {
|
|
35633
35955
|
try {
|
|
@@ -35647,7 +35969,7 @@ function installRuntimeLogWatcherPidCleanup(pidFile) {
|
|
|
35647
35969
|
}
|
|
35648
35970
|
cleaned = true;
|
|
35649
35971
|
if (readPidFile(pidFile) === process.pid) {
|
|
35650
|
-
|
|
35972
|
+
fs13.rmSync(pidFile, { force: true });
|
|
35651
35973
|
}
|
|
35652
35974
|
};
|
|
35653
35975
|
process.once("exit", cleanup);
|
|
@@ -35756,7 +36078,7 @@ async function prepareDevKit(targetDir, ctx, options = {}) {
|
|
|
35756
36078
|
onStart: (event) => emitSkillInstallerStart(ctx, event)
|
|
35757
36079
|
});
|
|
35758
36080
|
writeDevKitStagedGitignore(
|
|
35759
|
-
|
|
36081
|
+
path14.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE),
|
|
35760
36082
|
listPresentDevKitManagedEntries(targetDir)
|
|
35761
36083
|
);
|
|
35762
36084
|
if (options.finalizeGitignore) {
|
|
@@ -35773,7 +36095,7 @@ async function prepareDevKit(targetDir, ctx, options = {}) {
|
|
|
35773
36095
|
);
|
|
35774
36096
|
} catch (error2) {
|
|
35775
36097
|
writeDevKitStagedGitignore(
|
|
35776
|
-
|
|
36098
|
+
path14.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE),
|
|
35777
36099
|
listPresentDevKitManagedEntries(targetDir)
|
|
35778
36100
|
);
|
|
35779
36101
|
if (options.finalizeGitignore) {
|
|
@@ -35861,7 +36183,7 @@ function installMcpConfig(ide, options) {
|
|
|
35861
36183
|
}
|
|
35862
36184
|
function installMcpConfigUnsafe(ide, options) {
|
|
35863
36185
|
if (ide === "codex") {
|
|
35864
|
-
const configPath =
|
|
36186
|
+
const configPath = path14.join(os4.homedir(), ".codex", "config.toml");
|
|
35865
36187
|
mergeCodexMcpConfig(configPath, options);
|
|
35866
36188
|
return {
|
|
35867
36189
|
ide,
|
|
@@ -35871,7 +36193,7 @@ function installMcpConfigUnsafe(ide, options) {
|
|
|
35871
36193
|
};
|
|
35872
36194
|
}
|
|
35873
36195
|
if (ide === "cursor") {
|
|
35874
|
-
const configPath =
|
|
36196
|
+
const configPath = path14.join(os4.homedir(), ".cursor", "mcp.json");
|
|
35875
36197
|
mergeJsonMcpConfig(configPath, options);
|
|
35876
36198
|
return {
|
|
35877
36199
|
ide,
|
|
@@ -35887,7 +36209,7 @@ function installMcpConfigUnsafe(ide, options) {
|
|
|
35887
36209
|
return { ide, ok: true, message: "✓ Claude Code MCP config updated with claude mcp add" };
|
|
35888
36210
|
}
|
|
35889
36211
|
}
|
|
35890
|
-
const configPath =
|
|
36212
|
+
const configPath = path14.join(os4.homedir(), ".claude.json");
|
|
35891
36213
|
mergeJsonMcpConfig(configPath, options);
|
|
35892
36214
|
return {
|
|
35893
36215
|
ide,
|
|
@@ -35904,13 +36226,13 @@ function mergeJsonMcpConfig(configPath, options) {
|
|
|
35904
36226
|
const mcpServers = asObject(existing.mcpServers);
|
|
35905
36227
|
mcpServers[options.mcpName] = createJsonMcpServerConfig(options);
|
|
35906
36228
|
existing.mcpServers = mcpServers;
|
|
35907
|
-
|
|
35908
|
-
|
|
36229
|
+
fs13.mkdirSync(path14.dirname(configPath), { recursive: true });
|
|
36230
|
+
fs13.writeFileSync(configPath, `${JSON.stringify(existing, null, 2)}
|
|
35909
36231
|
`, "utf8");
|
|
35910
36232
|
}
|
|
35911
36233
|
function mergeCodexMcpConfig(configPath, options) {
|
|
35912
36234
|
const backupPath = backupIfExists(configPath);
|
|
35913
|
-
const existing =
|
|
36235
|
+
const existing = fs13.existsSync(configPath) ? fs13.readFileSync(configPath, "utf8") : "";
|
|
35914
36236
|
const sectionPattern = createCodexMcpSectionPattern(options.mcpName);
|
|
35915
36237
|
const withoutOld = existing.replace(sectionPattern, "").trimEnd();
|
|
35916
36238
|
const launch = getNpxCliCommand(options.pkg);
|
|
@@ -35924,9 +36246,9 @@ function mergeCodexMcpConfig(configPath, options) {
|
|
|
35924
36246
|
`TAPTAP_MCP_ENV = "${options.env}"`,
|
|
35925
36247
|
""
|
|
35926
36248
|
].join("\n");
|
|
35927
|
-
|
|
35928
|
-
|
|
35929
|
-
const updated =
|
|
36249
|
+
fs13.mkdirSync(path14.dirname(configPath), { recursive: true });
|
|
36250
|
+
fs13.writeFileSync(configPath, [withoutOld, section].filter(Boolean).join("\n\n"), "utf8");
|
|
36251
|
+
const updated = fs13.readFileSync(configPath, "utf8");
|
|
35930
36252
|
const duplicates = findCodexMcpTableDuplicates(updated, options.mcpName);
|
|
35931
36253
|
if (duplicates.length > 0) {
|
|
35932
36254
|
restoreBackup(configPath, backupPath);
|
|
@@ -36043,10 +36365,10 @@ function rejectPackageOption(parsed) {
|
|
|
36043
36365
|
}
|
|
36044
36366
|
}
|
|
36045
36367
|
function readJsonObject(filePath) {
|
|
36046
|
-
if (!
|
|
36368
|
+
if (!fs13.existsSync(filePath)) {
|
|
36047
36369
|
return {};
|
|
36048
36370
|
}
|
|
36049
|
-
return JSON.parse(
|
|
36371
|
+
return JSON.parse(fs13.readFileSync(filePath, "utf8"));
|
|
36050
36372
|
}
|
|
36051
36373
|
function asObject(value) {
|
|
36052
36374
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
@@ -36055,26 +36377,26 @@ function asObject(value) {
|
|
|
36055
36377
|
return {};
|
|
36056
36378
|
}
|
|
36057
36379
|
function backupIfExists(filePath) {
|
|
36058
|
-
if (!
|
|
36380
|
+
if (!fs13.existsSync(filePath)) {
|
|
36059
36381
|
return void 0;
|
|
36060
36382
|
}
|
|
36061
36383
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:]/g, "").replace(/\..+$/, "");
|
|
36062
36384
|
const backupPath = `${filePath}.bak.${stamp}`;
|
|
36063
|
-
|
|
36385
|
+
fs13.copyFileSync(filePath, backupPath);
|
|
36064
36386
|
return backupPath;
|
|
36065
36387
|
}
|
|
36066
36388
|
function restoreBackup(filePath, backupPath) {
|
|
36067
36389
|
if (backupPath) {
|
|
36068
|
-
|
|
36390
|
+
fs13.copyFileSync(backupPath, filePath);
|
|
36069
36391
|
return;
|
|
36070
36392
|
}
|
|
36071
|
-
|
|
36393
|
+
fs13.rmSync(filePath, { force: true });
|
|
36072
36394
|
}
|
|
36073
36395
|
function saveInitState(targetDir, state) {
|
|
36074
|
-
|
|
36075
|
-
const key = crypto2.createHash("sha256").update(
|
|
36076
|
-
|
|
36077
|
-
|
|
36396
|
+
fs13.mkdirSync(getMakerHome(), { recursive: true });
|
|
36397
|
+
const key = crypto2.createHash("sha256").update(path14.resolve(targetDir)).digest("hex").slice(0, 16);
|
|
36398
|
+
fs13.writeFileSync(
|
|
36399
|
+
path14.join(getMakerHome(), `init-state-${key}.json`),
|
|
36078
36400
|
`${JSON.stringify({ ...state, updated_at: (/* @__PURE__ */ new Date()).toISOString() }, null, 2)}
|
|
36079
36401
|
`,
|
|
36080
36402
|
"utf8"
|
|
@@ -36151,13 +36473,22 @@ async function promptRequired(label) {
|
|
|
36151
36473
|
throw new Error(`${label} is required in non-interactive mode.`);
|
|
36152
36474
|
}
|
|
36153
36475
|
const rl = readline.createInterface({ input, output });
|
|
36476
|
+
let settled = false;
|
|
36477
|
+
const closed = new Promise((_, reject) => {
|
|
36478
|
+
rl.once("close", () => {
|
|
36479
|
+
if (!settled) {
|
|
36480
|
+
reject(new Error(`${label} input closed before a value was provided.`));
|
|
36481
|
+
}
|
|
36482
|
+
});
|
|
36483
|
+
});
|
|
36154
36484
|
try {
|
|
36155
|
-
const answer = await rl.question(`${label}: `);
|
|
36485
|
+
const answer = await Promise.race([rl.question(`${label}: `), closed]);
|
|
36156
36486
|
if (!answer.trim()) {
|
|
36157
36487
|
throw new Error(`${label} cannot be empty.`);
|
|
36158
36488
|
}
|
|
36159
36489
|
return answer.trim();
|
|
36160
36490
|
} finally {
|
|
36491
|
+
settled = true;
|
|
36161
36492
|
rl.close();
|
|
36162
36493
|
}
|
|
36163
36494
|
}
|
|
@@ -36210,7 +36541,7 @@ function makerEnvOption(parsed) {
|
|
|
36210
36541
|
return env;
|
|
36211
36542
|
}
|
|
36212
36543
|
const targetDir = stringOption(parsed, "target_dir");
|
|
36213
|
-
return getMakerEnvironment(void 0, targetDir ?
|
|
36544
|
+
return getMakerEnvironment(void 0, targetDir ? path14.resolve(targetDir) : process.cwd());
|
|
36214
36545
|
}
|
|
36215
36546
|
function mcpVerifyModeOption(parsed) {
|
|
36216
36547
|
const mode = stringOption(parsed, "mode") || "npx";
|
|
@@ -36287,69 +36618,6 @@ function formatCliError(error2) {
|
|
|
36287
36618
|
return error2 instanceof Error ? error2.message : String(error2);
|
|
36288
36619
|
}
|
|
36289
36620
|
|
|
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
36621
|
// src/mcp-proxy/config.ts
|
|
36354
36622
|
function readStdin() {
|
|
36355
36623
|
return new Promise((resolve, reject) => {
|
|
@@ -38279,6 +38547,8 @@ var LogWriter = class {
|
|
|
38279
38547
|
// src/mcp-proxy/proxy.ts
|
|
38280
38548
|
var VERSION2 = typeof __PROXY_VERSION__ !== "undefined" ? __PROXY_VERSION__ : "dev";
|
|
38281
38549
|
var LOCAL_PROXY_TAG = "local";
|
|
38550
|
+
var DEFAULT_RECONNECT_INTERVAL_MS = 5e3;
|
|
38551
|
+
var MAX_RECONNECT_INTERVAL_MS = 60 * 1e3;
|
|
38282
38552
|
var TapTapMCPProxy = class {
|
|
38283
38553
|
constructor(config2) {
|
|
38284
38554
|
this.connected = false;
|
|
@@ -38286,6 +38556,7 @@ var TapTapMCPProxy = class {
|
|
|
38286
38556
|
this.reconnectTimer = null;
|
|
38287
38557
|
this.healthCheckTimer = null;
|
|
38288
38558
|
this.pendingRequests = [];
|
|
38559
|
+
this.reconnectDelayMs = DEFAULT_RECONNECT_INTERVAL_MS;
|
|
38289
38560
|
// 会话验证相关
|
|
38290
38561
|
this.sessionValidated = false;
|
|
38291
38562
|
this.lastValidationTime = 0;
|
|
@@ -38294,15 +38565,15 @@ var TapTapMCPProxy = class {
|
|
|
38294
38565
|
this.config = config2;
|
|
38295
38566
|
this.cookieJar = new CookieJar(((_a3 = config2.options) == null ? void 0 : _a3.verbose) ?? false);
|
|
38296
38567
|
this.logWriter = this.createLogWriter();
|
|
38297
|
-
this.client =
|
|
38298
|
-
{ name: "taptap-proxy-client", version: "1.0.0" },
|
|
38299
|
-
{ capabilities: {} }
|
|
38300
|
-
);
|
|
38568
|
+
this.client = this.createClient();
|
|
38301
38569
|
this.server = new Server(
|
|
38302
38570
|
{ name: "taptap-proxy", version: "1.0.0" },
|
|
38303
38571
|
{ capabilities: { tools: {}, resources: {} } }
|
|
38304
38572
|
);
|
|
38305
38573
|
}
|
|
38574
|
+
createClient() {
|
|
38575
|
+
return new Client({ name: "taptap-proxy-client", version: "1.0.0" }, { capabilities: {} });
|
|
38576
|
+
}
|
|
38306
38577
|
/**
|
|
38307
38578
|
* 创建文件日志写入器
|
|
38308
38579
|
*/
|
|
@@ -38471,7 +38742,7 @@ var TapTapMCPProxy = class {
|
|
|
38471
38742
|
* 连接到 TapTap MCP Server
|
|
38472
38743
|
*/
|
|
38473
38744
|
async connectToServer() {
|
|
38474
|
-
var _a3, _b;
|
|
38745
|
+
var _a3, _b, _c;
|
|
38475
38746
|
this.log("info", `Connecting to ${this.config.server.url}...`);
|
|
38476
38747
|
try {
|
|
38477
38748
|
const cookieEnabled = ((_a3 = this.config.options) == null ? void 0 : _a3.enable_cookie_sticky) ?? true;
|
|
@@ -38492,6 +38763,7 @@ var TapTapMCPProxy = class {
|
|
|
38492
38763
|
this.connected = true;
|
|
38493
38764
|
this.sessionValidated = true;
|
|
38494
38765
|
this.lastValidationTime = Date.now();
|
|
38766
|
+
this.reconnectDelayMs = ((_c = this.config.options) == null ? void 0 : _c.reconnect_interval) ?? DEFAULT_RECONNECT_INTERVAL_MS;
|
|
38495
38767
|
this.log("info", "✅ Connected and session validated");
|
|
38496
38768
|
this.startHealthCheck();
|
|
38497
38769
|
if (this.reconnecting) {
|
|
@@ -38542,7 +38814,7 @@ var TapTapMCPProxy = class {
|
|
|
38542
38814
|
* 启动定期健康检查
|
|
38543
38815
|
*/
|
|
38544
38816
|
startHealthCheck() {
|
|
38545
|
-
var _a3;
|
|
38817
|
+
var _a3, _b, _c;
|
|
38546
38818
|
this.stopHealthCheck();
|
|
38547
38819
|
const interval = ((_a3 = this.config.options) == null ? void 0 : _a3.health_check_interval) ?? this.SESSION_VALIDATION_INTERVAL;
|
|
38548
38820
|
this.healthCheckTimer = setInterval(async () => {
|
|
@@ -38559,6 +38831,7 @@ var TapTapMCPProxy = class {
|
|
|
38559
38831
|
}
|
|
38560
38832
|
}
|
|
38561
38833
|
}, interval);
|
|
38834
|
+
(_c = (_b = this.healthCheckTimer).unref) == null ? void 0 : _c.call(_b);
|
|
38562
38835
|
this.log("debug", `Health check started (interval: ${interval}ms)`);
|
|
38563
38836
|
}
|
|
38564
38837
|
/**
|
|
@@ -38618,10 +38891,11 @@ var TapTapMCPProxy = class {
|
|
|
38618
38891
|
* 重连到 TapTap Server
|
|
38619
38892
|
*/
|
|
38620
38893
|
async reconnectToServer() {
|
|
38621
|
-
var _a3, _b
|
|
38894
|
+
var _a3, _b;
|
|
38622
38895
|
if (this.reconnecting) return;
|
|
38623
38896
|
this.reconnecting = true;
|
|
38624
38897
|
this.clearReconnectTimer();
|
|
38898
|
+
this.stopHealthCheck();
|
|
38625
38899
|
const cookieEnabled = ((_a3 = this.config.options) == null ? void 0 : _a3.enable_cookie_sticky) ?? true;
|
|
38626
38900
|
if (cookieEnabled && this.cookieJar.hasCookies) {
|
|
38627
38901
|
this.cookieJar.clear();
|
|
@@ -38630,14 +38904,12 @@ var TapTapMCPProxy = class {
|
|
|
38630
38904
|
}
|
|
38631
38905
|
}
|
|
38632
38906
|
try {
|
|
38633
|
-
this.client
|
|
38634
|
-
|
|
38635
|
-
{ capabilities: {} }
|
|
38636
|
-
);
|
|
38907
|
+
await this.closeClientSafely("reconnect-old-client");
|
|
38908
|
+
this.client = this.createClient();
|
|
38637
38909
|
await this.connectToServer();
|
|
38638
38910
|
this.log("info", "✅ Reconnected successfully");
|
|
38639
38911
|
} catch (error2) {
|
|
38640
|
-
const interval =
|
|
38912
|
+
const interval = this.reconnectDelayMs;
|
|
38641
38913
|
this.log("error", `❌ Reconnect failed: ${this.formatError(error2)}`);
|
|
38642
38914
|
this.log("info", `Will retry in ${interval / 1e3}s...`);
|
|
38643
38915
|
this.reconnecting = false;
|
|
@@ -38648,12 +38920,18 @@ var TapTapMCPProxy = class {
|
|
|
38648
38920
|
* 调度重连
|
|
38649
38921
|
*/
|
|
38650
38922
|
scheduleReconnect() {
|
|
38651
|
-
var _a3;
|
|
38923
|
+
var _a3, _b, _c;
|
|
38652
38924
|
this.clearReconnectTimer();
|
|
38653
|
-
const
|
|
38925
|
+
const configuredInterval = ((_a3 = this.config.options) == null ? void 0 : _a3.reconnect_interval) ?? DEFAULT_RECONNECT_INTERVAL_MS;
|
|
38926
|
+
const interval = this.reconnectDelayMs || configuredInterval;
|
|
38654
38927
|
this.reconnectTimer = setTimeout(() => {
|
|
38655
38928
|
this.reconnectToServer();
|
|
38656
38929
|
}, interval);
|
|
38930
|
+
(_c = (_b = this.reconnectTimer).unref) == null ? void 0 : _c.call(_b);
|
|
38931
|
+
this.reconnectDelayMs = Math.min(
|
|
38932
|
+
Math.max(interval * 2, configuredInterval),
|
|
38933
|
+
MAX_RECONNECT_INTERVAL_MS
|
|
38934
|
+
);
|
|
38657
38935
|
}
|
|
38658
38936
|
/**
|
|
38659
38937
|
* 清除重连定时器
|
|
@@ -38678,6 +38956,17 @@ var TapTapMCPProxy = class {
|
|
|
38678
38956
|
const req = this.pendingRequests.shift();
|
|
38679
38957
|
req.reject(timeout);
|
|
38680
38958
|
}
|
|
38959
|
+
void this.closeClientSafely("cleanup");
|
|
38960
|
+
}
|
|
38961
|
+
async closeClientSafely(source) {
|
|
38962
|
+
try {
|
|
38963
|
+
await this.client.close();
|
|
38964
|
+
} catch (error2) {
|
|
38965
|
+
this.log(
|
|
38966
|
+
"warning",
|
|
38967
|
+
`Failed to close proxy client during ${source}: ${this.formatError(error2)}`
|
|
38968
|
+
);
|
|
38969
|
+
}
|
|
38681
38970
|
}
|
|
38682
38971
|
/**
|
|
38683
38972
|
* 检测是否是需要重连的错误(网络错误或会话无效)
|
|
@@ -38933,12 +39222,15 @@ async function startEmbeddedProxy() {
|
|
|
38933
39222
|
const config2 = await loadConfig();
|
|
38934
39223
|
const proxy = new TapTapMCPProxy(config2);
|
|
38935
39224
|
await proxy.start();
|
|
38936
|
-
const cleanup = () => {
|
|
39225
|
+
const cleanup = (source = "proxy-signal") => {
|
|
39226
|
+
logLifecycleEvent(source, "Embedded Maker proxy received shutdown signal; exiting.");
|
|
38937
39227
|
proxy.cleanup();
|
|
38938
39228
|
process.exit(0);
|
|
38939
39229
|
};
|
|
38940
|
-
|
|
38941
|
-
|
|
39230
|
+
installProxyStdinExitHandler(proxy);
|
|
39231
|
+
installParentDeathWatchdog(proxy);
|
|
39232
|
+
process.on("SIGINT", () => cleanup("proxy-sigint"));
|
|
39233
|
+
process.on("SIGTERM", () => cleanup("proxy-sigterm"));
|
|
38942
39234
|
}
|
|
38943
39235
|
function printHelp2() {
|
|
38944
39236
|
process.stdout.write(
|
|
@@ -38978,24 +39270,75 @@ function printHelp2() {
|
|
|
38978
39270
|
}
|
|
38979
39271
|
main().catch((error2) => {
|
|
38980
39272
|
logCrash("main.catch", error2);
|
|
38981
|
-
|
|
39273
|
+
safeWriteStderr(`❌ ${formatCliError(error2)}
|
|
38982
39274
|
`);
|
|
38983
39275
|
process.exit(1);
|
|
38984
39276
|
});
|
|
38985
39277
|
function installCrashLogging() {
|
|
39278
|
+
installStdioErrorHandler(process.stdout, "stdout-error");
|
|
39279
|
+
installStdioErrorHandler(process.stderr, "stderr-error");
|
|
39280
|
+
installStdinErrorHandler();
|
|
39281
|
+
let handlingFatalError = false;
|
|
38986
39282
|
process.on("uncaughtException", (error2) => {
|
|
38987
39283
|
logCrash("uncaughtException", error2);
|
|
38988
|
-
|
|
39284
|
+
if (isDisconnectedStdioError(error2)) {
|
|
39285
|
+
logLifecycleEvent("uncaughtException-stdio-closed", "Maker stdio disconnected; exiting.");
|
|
39286
|
+
process.exit(0);
|
|
39287
|
+
}
|
|
39288
|
+
if (handlingFatalError) {
|
|
39289
|
+
logCrash("uncaughtException-recursive", error2);
|
|
39290
|
+
process.exit(1);
|
|
39291
|
+
}
|
|
39292
|
+
handlingFatalError = true;
|
|
39293
|
+
safeWriteStderr(`❌ Uncaught Maker MCP error: ${error2.message}
|
|
38989
39294
|
`);
|
|
39295
|
+
handlingFatalError = false;
|
|
38990
39296
|
});
|
|
38991
39297
|
process.on("unhandledRejection", (reason) => {
|
|
38992
39298
|
logCrash("unhandledRejection", reason);
|
|
38993
|
-
|
|
39299
|
+
if (isDisconnectedStdioError(reason)) {
|
|
39300
|
+
logLifecycleEvent("unhandledRejection-stdio-closed", "Maker stdio disconnected; exiting.");
|
|
39301
|
+
process.exit(0);
|
|
39302
|
+
}
|
|
39303
|
+
if (handlingFatalError) {
|
|
39304
|
+
logCrash("unhandledRejection-recursive", reason);
|
|
39305
|
+
process.exit(1);
|
|
39306
|
+
}
|
|
39307
|
+
handlingFatalError = true;
|
|
39308
|
+
safeWriteStderr(
|
|
38994
39309
|
`❌ Unhandled Maker MCP rejection: ${reason instanceof Error ? reason.message : String(reason)}
|
|
38995
39310
|
`
|
|
38996
39311
|
);
|
|
39312
|
+
handlingFatalError = false;
|
|
39313
|
+
});
|
|
39314
|
+
}
|
|
39315
|
+
function installStdioErrorHandler(stream, source) {
|
|
39316
|
+
stream.on("error", (error2) => {
|
|
39317
|
+
logCrash(source, error2);
|
|
39318
|
+
if (isDisconnectedStdioError(error2)) {
|
|
39319
|
+
process.exit(0);
|
|
39320
|
+
}
|
|
38997
39321
|
});
|
|
38998
39322
|
}
|
|
39323
|
+
function installStdinErrorHandler() {
|
|
39324
|
+
process.stdin.on("error", (error2) => {
|
|
39325
|
+
logCrash("stdin-error", error2);
|
|
39326
|
+
if (isDisconnectedStdioError(error2)) {
|
|
39327
|
+
logLifecycleEvent("stdin-error-disconnected", "Maker stdin became unreadable; exiting.");
|
|
39328
|
+
process.exit(0);
|
|
39329
|
+
}
|
|
39330
|
+
});
|
|
39331
|
+
}
|
|
39332
|
+
function safeWriteStderr(message) {
|
|
39333
|
+
try {
|
|
39334
|
+
process.stderr.write(message);
|
|
39335
|
+
} catch (error2) {
|
|
39336
|
+
logCrash("stderr-write-failed", error2);
|
|
39337
|
+
if (isDisconnectedStdioError(error2)) {
|
|
39338
|
+
process.exit(0);
|
|
39339
|
+
}
|
|
39340
|
+
}
|
|
39341
|
+
}
|
|
38999
39342
|
function logCrash(source, error2) {
|
|
39000
39343
|
try {
|
|
39001
39344
|
appendMakerCrashLog(source, error2);
|