@taptap/maker 0.0.16 → 0.0.17-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/maker.js +774 -365
- package/package.json +1 -1
- package/skills/taptap-maker-local/SKILL.md +2 -1
package/dist/maker.js
CHANGED
|
@@ -13003,8 +13003,8 @@ var require_cross_spawn = __commonJS({
|
|
|
13003
13003
|
|
|
13004
13004
|
// src/maker/server/mcp.ts
|
|
13005
13005
|
import { execFileSync, spawn as spawn4, spawnSync as spawnSync6 } from "node:child_process";
|
|
13006
|
-
import
|
|
13007
|
-
import
|
|
13006
|
+
import fs12 from "node:fs";
|
|
13007
|
+
import path13 from "node:path";
|
|
13008
13008
|
|
|
13009
13009
|
// node_modules/zod/v3/helpers/util.js
|
|
13010
13010
|
var util;
|
|
@@ -28305,17 +28305,177 @@ var HiddenStdioClientTransport = class {
|
|
|
28305
28305
|
}
|
|
28306
28306
|
};
|
|
28307
28307
|
|
|
28308
|
+
// src/maker/server/childTransports.ts
|
|
28309
|
+
var activeMakerChildTransports = /* @__PURE__ */ new Set();
|
|
28310
|
+
function trackMakerChildTransport(transport) {
|
|
28311
|
+
activeMakerChildTransports.add(transport);
|
|
28312
|
+
const originalClose = transport.close.bind(transport);
|
|
28313
|
+
let closed = false;
|
|
28314
|
+
transport.close = async () => {
|
|
28315
|
+
if (closed) {
|
|
28316
|
+
return;
|
|
28317
|
+
}
|
|
28318
|
+
closed = true;
|
|
28319
|
+
activeMakerChildTransports.delete(transport);
|
|
28320
|
+
await originalClose();
|
|
28321
|
+
};
|
|
28322
|
+
return transport;
|
|
28323
|
+
}
|
|
28324
|
+
async function closeTrackedMakerChildTransports() {
|
|
28325
|
+
const transports = [...activeMakerChildTransports];
|
|
28326
|
+
activeMakerChildTransports.clear();
|
|
28327
|
+
await Promise.all(transports.map((transport) => transport.close().catch(() => {
|
|
28328
|
+
})));
|
|
28329
|
+
}
|
|
28330
|
+
|
|
28331
|
+
// src/maker/crashLog.ts
|
|
28332
|
+
import fs3 from "node:fs";
|
|
28333
|
+
import path3 from "node:path";
|
|
28334
|
+
var DEFAULT_MAX_BYTES = 1024 * 1024;
|
|
28335
|
+
var DEFAULT_MAX_ENTRY_BYTES = 16 * 1024;
|
|
28336
|
+
function appendMakerCrashLog(source, error2, options = {}) {
|
|
28337
|
+
const makerHome = getMakerHome();
|
|
28338
|
+
fs3.mkdirSync(makerHome, { recursive: true });
|
|
28339
|
+
const logPath = path3.join(makerHome, "mcp-crash.log");
|
|
28340
|
+
const maxBytes = positiveInteger(options.maxBytes) || resolveEnvBytes("TAPTAP_MAKER_CRASH_LOG_MAX_BYTES", DEFAULT_MAX_BYTES);
|
|
28341
|
+
const maxEntryBytes = positiveInteger(options.maxEntryBytes) || resolveEnvBytes("TAPTAP_MAKER_CRASH_LOG_MAX_ENTRY_BYTES", DEFAULT_MAX_ENTRY_BYTES);
|
|
28342
|
+
const message = error2 instanceof Error ? error2.stack || error2.message : String(error2);
|
|
28343
|
+
const entry = truncateUtf8(
|
|
28344
|
+
[`[${(/* @__PURE__ */ new Date()).toISOString()}] ${source}`, message, ""].join("\n"),
|
|
28345
|
+
Math.min(maxEntryBytes, maxBytes)
|
|
28346
|
+
);
|
|
28347
|
+
const entryBytes = Buffer.byteLength(entry, "utf8");
|
|
28348
|
+
rotateIfNeeded(logPath, maxBytes, entryBytes);
|
|
28349
|
+
fs3.appendFileSync(logPath, entry, "utf8");
|
|
28350
|
+
}
|
|
28351
|
+
function rotateIfNeeded(logPath, maxBytes, incomingBytes) {
|
|
28352
|
+
if (!fs3.existsSync(logPath)) {
|
|
28353
|
+
return;
|
|
28354
|
+
}
|
|
28355
|
+
const currentBytes = fs3.statSync(logPath).size;
|
|
28356
|
+
if (currentBytes + incomingBytes <= maxBytes) {
|
|
28357
|
+
return;
|
|
28358
|
+
}
|
|
28359
|
+
const rotatedPath = `${logPath}.1`;
|
|
28360
|
+
writeFileTail(logPath, rotatedPath, maxBytes);
|
|
28361
|
+
fs3.writeFileSync(logPath, "", "utf8");
|
|
28362
|
+
}
|
|
28363
|
+
function writeFileTail(sourcePath, targetPath, maxBytes) {
|
|
28364
|
+
const size = fs3.statSync(sourcePath).size;
|
|
28365
|
+
const bytesToRead = Math.min(size, maxBytes);
|
|
28366
|
+
const start = Math.max(0, size - bytesToRead);
|
|
28367
|
+
const fd = fs3.openSync(sourcePath, "r");
|
|
28368
|
+
try {
|
|
28369
|
+
const buffer = Buffer.alloc(bytesToRead);
|
|
28370
|
+
fs3.readSync(fd, buffer, 0, bytesToRead, start);
|
|
28371
|
+
fs3.writeFileSync(targetPath, buffer);
|
|
28372
|
+
} finally {
|
|
28373
|
+
fs3.closeSync(fd);
|
|
28374
|
+
}
|
|
28375
|
+
}
|
|
28376
|
+
function truncateUtf8(value, maxBytes) {
|
|
28377
|
+
if (Buffer.byteLength(value, "utf8") <= maxBytes) {
|
|
28378
|
+
return value;
|
|
28379
|
+
}
|
|
28380
|
+
const suffix = `
|
|
28381
|
+
[truncated to ${maxBytes} bytes]
|
|
28382
|
+
`;
|
|
28383
|
+
const suffixBytes = Buffer.byteLength(suffix, "utf8");
|
|
28384
|
+
const prefixBytes = Math.max(0, maxBytes - suffixBytes);
|
|
28385
|
+
return `${Buffer.from(value, "utf8").subarray(0, prefixBytes).toString("utf8")}${suffix}`;
|
|
28386
|
+
}
|
|
28387
|
+
function resolveEnvBytes(key, fallback) {
|
|
28388
|
+
return positiveInteger(Number(process.env[key])) || fallback;
|
|
28389
|
+
}
|
|
28390
|
+
function positiveInteger(value) {
|
|
28391
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.floor(value) : void 0;
|
|
28392
|
+
}
|
|
28393
|
+
|
|
28394
|
+
// src/maker/lifecycle.ts
|
|
28395
|
+
var DISCONNECTED_STDIO_CODES = /* @__PURE__ */ new Set(["EPIPE", "ERR_STREAM_DESTROYED", "ECONNRESET"]);
|
|
28396
|
+
function isDisconnectedStdioError(error2) {
|
|
28397
|
+
if (!error2 || typeof error2 !== "object") {
|
|
28398
|
+
return false;
|
|
28399
|
+
}
|
|
28400
|
+
const code = error2.code;
|
|
28401
|
+
if (typeof code === "string" && DISCONNECTED_STDIO_CODES.has(code)) {
|
|
28402
|
+
return true;
|
|
28403
|
+
}
|
|
28404
|
+
const message = error2 instanceof Error ? error2.message.toLowerCase() : "";
|
|
28405
|
+
return message.includes("epipe") || message.includes("stream destroyed");
|
|
28406
|
+
}
|
|
28407
|
+
function shouldExitForParentDeath(options) {
|
|
28408
|
+
if ((options.platform === "darwin" || options.platform === "linux") && options.initialPpid > 1 && options.currentPpid === 1) {
|
|
28409
|
+
return true;
|
|
28410
|
+
}
|
|
28411
|
+
try {
|
|
28412
|
+
options.probeParent();
|
|
28413
|
+
return false;
|
|
28414
|
+
} catch (error2) {
|
|
28415
|
+
return Boolean(
|
|
28416
|
+
error2 && typeof error2 === "object" && error2.code === "ESRCH" && options.initialPpid > 1
|
|
28417
|
+
);
|
|
28418
|
+
}
|
|
28419
|
+
}
|
|
28420
|
+
function installProxyStdinExitHandler(proxy, stdin = process.stdin, exit = (code) => process.exit(code)) {
|
|
28421
|
+
let exiting = false;
|
|
28422
|
+
const exitOnStdinClosed = () => {
|
|
28423
|
+
if (exiting) {
|
|
28424
|
+
return;
|
|
28425
|
+
}
|
|
28426
|
+
exiting = true;
|
|
28427
|
+
logLifecycleEvent("proxy-stdin-closed", "Embedded Maker proxy stdin closed; exiting.");
|
|
28428
|
+
proxy.cleanup();
|
|
28429
|
+
exit(0);
|
|
28430
|
+
};
|
|
28431
|
+
stdin.once("end", exitOnStdinClosed);
|
|
28432
|
+
stdin.once("close", exitOnStdinClosed);
|
|
28433
|
+
}
|
|
28434
|
+
function installParentDeathWatchdog(proxy, options = {}) {
|
|
28435
|
+
var _a3;
|
|
28436
|
+
const initialPpid = options.initialPpid ?? process.ppid;
|
|
28437
|
+
const getCurrentPpid = options.getCurrentPpid ?? (() => process.ppid);
|
|
28438
|
+
const exit = options.exit ?? ((code) => process.exit(code));
|
|
28439
|
+
let exiting = false;
|
|
28440
|
+
const timer = setInterval(() => {
|
|
28441
|
+
if (exiting) {
|
|
28442
|
+
return;
|
|
28443
|
+
}
|
|
28444
|
+
const shouldExit = shouldExitForParentDeath({
|
|
28445
|
+
initialPpid,
|
|
28446
|
+
currentPpid: getCurrentPpid(),
|
|
28447
|
+
platform: process.platform,
|
|
28448
|
+
probeParent: () => process.kill(initialPpid, 0)
|
|
28449
|
+
});
|
|
28450
|
+
if (!shouldExit) {
|
|
28451
|
+
return;
|
|
28452
|
+
}
|
|
28453
|
+
exiting = true;
|
|
28454
|
+
logLifecycleEvent("proxy-parent-dead", "Embedded Maker proxy parent process is gone; exiting.");
|
|
28455
|
+
proxy.cleanup();
|
|
28456
|
+
exit(0);
|
|
28457
|
+
}, options.intervalMs ?? 15e3);
|
|
28458
|
+
(_a3 = timer.unref) == null ? void 0 : _a3.call(timer);
|
|
28459
|
+
return timer;
|
|
28460
|
+
}
|
|
28461
|
+
function logLifecycleEvent(source, message) {
|
|
28462
|
+
try {
|
|
28463
|
+
appendMakerCrashLog(`lifecycle:${source}`, message);
|
|
28464
|
+
} catch {
|
|
28465
|
+
}
|
|
28466
|
+
}
|
|
28467
|
+
|
|
28308
28468
|
// src/maker/cli/projects.ts
|
|
28309
28469
|
import { spawn as spawn3, spawnSync as spawnSync3 } from "node:child_process";
|
|
28310
|
-
import
|
|
28311
|
-
import
|
|
28470
|
+
import fs6 from "node:fs";
|
|
28471
|
+
import path7 from "node:path";
|
|
28312
28472
|
|
|
28313
28473
|
// src/maker/config.ts
|
|
28314
|
-
import
|
|
28315
|
-
import
|
|
28474
|
+
import fs4 from "node:fs";
|
|
28475
|
+
import path5 from "node:path";
|
|
28316
28476
|
|
|
28317
28477
|
// src/core/utils/env.ts
|
|
28318
|
-
import * as
|
|
28478
|
+
import * as path4 from "node:path";
|
|
28319
28479
|
import * as os2 from "node:os";
|
|
28320
28480
|
import process5 from "node:process";
|
|
28321
28481
|
var ENVIRONMENT_ENDPOINTS = {
|
|
@@ -28411,11 +28571,11 @@ var EnvConfig = class {
|
|
|
28411
28571
|
// --------------------------------------------------------------------------
|
|
28412
28572
|
/** 缓存目录 */
|
|
28413
28573
|
static get cacheDir() {
|
|
28414
|
-
return getEnv("TAPTAP_MCP_CACHE_DIR",
|
|
28574
|
+
return getEnv("TAPTAP_MCP_CACHE_DIR", path4.join(os2.tmpdir(), "taptap-mcp", "cache"));
|
|
28415
28575
|
}
|
|
28416
28576
|
/** 临时文件目录 */
|
|
28417
28577
|
static get tempDir() {
|
|
28418
|
-
return getEnv("TAPTAP_MCP_TEMP_DIR",
|
|
28578
|
+
return getEnv("TAPTAP_MCP_TEMP_DIR", path4.join(os2.tmpdir(), "taptap-mcp", "temp"));
|
|
28419
28579
|
}
|
|
28420
28580
|
/** 工作区根目录 */
|
|
28421
28581
|
static get workspaceRoot() {
|
|
@@ -28556,7 +28716,7 @@ var MAKER_ENDPOINTS = {
|
|
|
28556
28716
|
remoteMcpServerUrl: "https://fuping.agnt.xd.com/mcp/v1"
|
|
28557
28717
|
}
|
|
28558
28718
|
};
|
|
28559
|
-
var MAKER_PROJECT_ENV_CONFIG_FILE =
|
|
28719
|
+
var MAKER_PROJECT_ENV_CONFIG_FILE = path5.join(".maker", "taptap-maker.local.json");
|
|
28560
28720
|
var makerEnvironmentOverride;
|
|
28561
28721
|
var MAKER_ENV_OVERRIDES = {
|
|
28562
28722
|
apiBase: {
|
|
@@ -28621,13 +28781,13 @@ function getMakerApiBaseUrl(environment) {
|
|
|
28621
28781
|
return requireMakerEndpoint("apiBase", endpoints.apiBase, environment).replace(/\/$/, "");
|
|
28622
28782
|
}
|
|
28623
28783
|
function getMakerProjectEnvironmentConfigPath(cwd = process.cwd()) {
|
|
28624
|
-
let current =
|
|
28784
|
+
let current = path5.resolve(cwd);
|
|
28625
28785
|
for (; ; ) {
|
|
28626
|
-
const candidate =
|
|
28627
|
-
if (
|
|
28786
|
+
const candidate = path5.join(current, MAKER_PROJECT_ENV_CONFIG_FILE);
|
|
28787
|
+
if (fs4.existsSync(candidate)) {
|
|
28628
28788
|
return candidate;
|
|
28629
28789
|
}
|
|
28630
|
-
const parent =
|
|
28790
|
+
const parent = path5.dirname(current);
|
|
28631
28791
|
if (parent === current) {
|
|
28632
28792
|
return void 0;
|
|
28633
28793
|
}
|
|
@@ -28658,7 +28818,7 @@ function getProjectLocalEnvironment(cwd) {
|
|
|
28658
28818
|
return void 0;
|
|
28659
28819
|
}
|
|
28660
28820
|
try {
|
|
28661
|
-
const raw =
|
|
28821
|
+
const raw = fs4.readFileSync(configPath, "utf8");
|
|
28662
28822
|
const data = JSON.parse(raw);
|
|
28663
28823
|
const env = data.env || data.environment;
|
|
28664
28824
|
return env === "rnd" || env === "production" ? env : void 0;
|
|
@@ -28924,9 +29084,9 @@ function formatGitMissingMessage(environment) {
|
|
|
28924
29084
|
|
|
28925
29085
|
// src/maker/cli/devKit.ts
|
|
28926
29086
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
28927
|
-
import
|
|
29087
|
+
import fs5 from "node:fs";
|
|
28928
29088
|
import os3 from "node:os";
|
|
28929
|
-
import
|
|
29089
|
+
import path6 from "node:path";
|
|
28930
29090
|
|
|
28931
29091
|
// src/maker/fetchTimeout.ts
|
|
28932
29092
|
var DEFAULT_SHORT_FETCH_TIMEOUT_MS = 10 * 1e3;
|
|
@@ -28957,7 +29117,7 @@ var AI_DEV_KIT_URLS = {
|
|
|
28957
29117
|
rnd: "https://urhox-demo-platform.spark.xd.com/ai-dev-kit/rnd/latest/ai-dev-kit.zip"
|
|
28958
29118
|
};
|
|
28959
29119
|
var DEFAULT_AI_DEV_KIT_URL = AI_DEV_KIT_URLS.production;
|
|
28960
|
-
var AI_DEV_KIT_VERSION_METADATA_FILE =
|
|
29120
|
+
var AI_DEV_KIT_VERSION_METADATA_FILE = path6.join(".maker", "ai-dev-kit-version.json");
|
|
28961
29121
|
var AI_DEV_KIT_DOWNLOAD_ENV = {
|
|
28962
29122
|
production: "pd",
|
|
28963
29123
|
rnd: "rnd"
|
|
@@ -28995,9 +29155,9 @@ var DEV_KIT_MANAGED_ENTRY_CANDIDATES = [
|
|
|
28995
29155
|
var SKIPPED_TOP_LEVEL_ENTRIES = /* @__PURE__ */ new Set(["scripts", ".DS_Store", "ai-dev-kit.zip"]);
|
|
28996
29156
|
var SKILL_INSTALLER_OUTPUT_ENTRIES = [".claude", ".codex", ".cursor", ".gemini"];
|
|
28997
29157
|
function inspectAiDevKit(targetDir) {
|
|
28998
|
-
const resolvedTargetDir =
|
|
29158
|
+
const resolvedTargetDir = path6.resolve(targetDir);
|
|
28999
29159
|
const presentEntries = DEV_KIT_REQUIRED_ENTRIES.filter(
|
|
29000
|
-
(entry) =>
|
|
29160
|
+
(entry) => fs5.existsSync(path6.join(resolvedTargetDir, entry))
|
|
29001
29161
|
);
|
|
29002
29162
|
const missingEntries = DEV_KIT_REQUIRED_ENTRIES.filter(
|
|
29003
29163
|
(entry) => !presentEntries.includes(entry)
|
|
@@ -29012,16 +29172,16 @@ function inspectAiDevKit(targetDir) {
|
|
|
29012
29172
|
};
|
|
29013
29173
|
}
|
|
29014
29174
|
function getAiDevKitVersionMetadataPath(targetDir) {
|
|
29015
|
-
return
|
|
29175
|
+
return path6.join(path6.resolve(targetDir), AI_DEV_KIT_VERSION_METADATA_FILE);
|
|
29016
29176
|
}
|
|
29017
29177
|
function readAiDevKitVersionMetadata(targetDir) {
|
|
29018
29178
|
const metadataPath = getAiDevKitVersionMetadataPath(targetDir);
|
|
29019
|
-
if (!
|
|
29179
|
+
if (!fs5.existsSync(metadataPath)) {
|
|
29020
29180
|
return void 0;
|
|
29021
29181
|
}
|
|
29022
29182
|
try {
|
|
29023
29183
|
const data = JSON.parse(
|
|
29024
|
-
|
|
29184
|
+
fs5.readFileSync(metadataPath, "utf8")
|
|
29025
29185
|
);
|
|
29026
29186
|
if (data.env !== "production" && data.env !== "rnd" || !isValidDevKitVersion(data.version) || typeof data.source_url !== "string" || typeof data.installed_at !== "string") {
|
|
29027
29187
|
return void 0;
|
|
@@ -29033,8 +29193,8 @@ function readAiDevKitVersionMetadata(targetDir) {
|
|
|
29033
29193
|
}
|
|
29034
29194
|
function writeAiDevKitVersionMetadata(targetDir, metadata) {
|
|
29035
29195
|
const metadataPath = getAiDevKitVersionMetadataPath(targetDir);
|
|
29036
|
-
|
|
29037
|
-
|
|
29196
|
+
fs5.mkdirSync(path6.dirname(metadataPath), { recursive: true });
|
|
29197
|
+
fs5.writeFileSync(metadataPath, `${JSON.stringify(metadata, null, 2)}
|
|
29038
29198
|
`, "utf8");
|
|
29039
29199
|
}
|
|
29040
29200
|
async function fetchAiDevKitVersions(options = {}) {
|
|
@@ -29089,7 +29249,7 @@ async function resolveAiDevKitDownload(options = {}) {
|
|
|
29089
29249
|
}
|
|
29090
29250
|
async function checkAiDevKitUpdate(targetDir, options = {}) {
|
|
29091
29251
|
var _a3;
|
|
29092
|
-
const resolvedTargetDir =
|
|
29252
|
+
const resolvedTargetDir = path6.resolve(targetDir);
|
|
29093
29253
|
const installed = readAiDevKitVersionMetadata(resolvedTargetDir);
|
|
29094
29254
|
const download = await resolveAiDevKitDownload({
|
|
29095
29255
|
environment: options.environment,
|
|
@@ -29107,24 +29267,24 @@ async function checkAiDevKitUpdate(targetDir, options = {}) {
|
|
|
29107
29267
|
};
|
|
29108
29268
|
}
|
|
29109
29269
|
function listPresentDevKitManagedEntries(targetDir) {
|
|
29110
|
-
const resolvedTargetDir =
|
|
29270
|
+
const resolvedTargetDir = path6.resolve(targetDir);
|
|
29111
29271
|
return DEV_KIT_MANAGED_ENTRY_CANDIDATES.filter(
|
|
29112
|
-
(entry) =>
|
|
29272
|
+
(entry) => fs5.existsSync(path6.join(resolvedTargetDir, entry))
|
|
29113
29273
|
);
|
|
29114
29274
|
}
|
|
29115
29275
|
async function installAiDevKit(options = {}) {
|
|
29116
29276
|
var _a3;
|
|
29117
|
-
const targetDir =
|
|
29118
|
-
|
|
29277
|
+
const targetDir = path6.resolve(options.targetDir || ".");
|
|
29278
|
+
fs5.mkdirSync(targetDir, { recursive: true });
|
|
29119
29279
|
const download = options.sourceDir ? void 0 : options.url ? void 0 : await resolveAiDevKitDownload({
|
|
29120
29280
|
environment: options.environment,
|
|
29121
29281
|
fetchImpl: options.fetchImpl,
|
|
29122
29282
|
versionCheckTimeoutMs: options.versionCheckTimeoutMs
|
|
29123
29283
|
});
|
|
29124
29284
|
const downloadUrl = options.url || (download == null ? void 0 : download.url) || resolveDefaultAiDevKitUrl(options.environment);
|
|
29125
|
-
const preparedSource = options.sourceDir ?
|
|
29285
|
+
const preparedSource = options.sourceDir ? path6.resolve(options.sourceDir) : await downloadAndExtractDevKit(downloadUrl, options.fetchImpl, options.downloadTimeoutMs);
|
|
29126
29286
|
const sourceDir = resolveDevKitRoot(preparedSource);
|
|
29127
|
-
const entries =
|
|
29287
|
+
const entries = fs5.readdirSync(sourceDir, { withFileTypes: true });
|
|
29128
29288
|
const installedEntries = [];
|
|
29129
29289
|
const skippedEntries = [];
|
|
29130
29290
|
if (options.replaceManagedEntries) {
|
|
@@ -29138,7 +29298,7 @@ async function installAiDevKit(options = {}) {
|
|
|
29138
29298
|
skippedEntries.push(entry.name);
|
|
29139
29299
|
continue;
|
|
29140
29300
|
}
|
|
29141
|
-
copyEntry(
|
|
29301
|
+
copyEntry(path6.join(sourceDir, entry.name), path6.join(targetDir, entry.name), {
|
|
29142
29302
|
preserveExisting: options.preserveExisting
|
|
29143
29303
|
});
|
|
29144
29304
|
installedEntries.push(entry.name);
|
|
@@ -29152,7 +29312,7 @@ async function installAiDevKit(options = {}) {
|
|
|
29152
29312
|
installedEntries.push(entry);
|
|
29153
29313
|
}
|
|
29154
29314
|
}
|
|
29155
|
-
const stagedGitignorePath =
|
|
29315
|
+
const stagedGitignorePath = path6.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE);
|
|
29156
29316
|
writeDevKitStagedGitignore(stagedGitignorePath, [
|
|
29157
29317
|
...installedEntries,
|
|
29158
29318
|
...listPresentSkillInstallerOutputEntries(targetDir)
|
|
@@ -29168,7 +29328,7 @@ async function installAiDevKit(options = {}) {
|
|
|
29168
29328
|
sourceDir,
|
|
29169
29329
|
installedEntries: installedEntries.sort(),
|
|
29170
29330
|
skippedEntries: skippedEntries.sort(),
|
|
29171
|
-
gitignorePath:
|
|
29331
|
+
gitignorePath: path6.join(targetDir, ".gitignore"),
|
|
29172
29332
|
stagedGitignorePath,
|
|
29173
29333
|
skillInstaller,
|
|
29174
29334
|
download,
|
|
@@ -29176,11 +29336,11 @@ async function installAiDevKit(options = {}) {
|
|
|
29176
29336
|
};
|
|
29177
29337
|
}
|
|
29178
29338
|
function inspectAiDevKitSkillInstallStatus(targetDir) {
|
|
29179
|
-
const resolvedTargetDir =
|
|
29339
|
+
const resolvedTargetDir = path6.resolve(targetDir);
|
|
29180
29340
|
const targets = SKILL_INSTALLER_OUTPUT_ENTRIES.map((entry) => {
|
|
29181
|
-
const skillsDir =
|
|
29182
|
-
const present =
|
|
29183
|
-
const skillCount = present ?
|
|
29341
|
+
const skillsDir = path6.join(resolvedTargetDir, entry, "skills");
|
|
29342
|
+
const present = fs5.existsSync(skillsDir) && fs5.statSync(skillsDir).isDirectory();
|
|
29343
|
+
const skillCount = present ? fs5.readdirSync(skillsDir, { withFileTypes: true }).filter((item) => item.isDirectory() || item.isSymbolicLink()).length : 0;
|
|
29184
29344
|
return {
|
|
29185
29345
|
name: entry.replace(/^\./, ""),
|
|
29186
29346
|
path: skillsDir,
|
|
@@ -29203,15 +29363,15 @@ function createDevKitGitignoreBlock(entries) {
|
|
|
29203
29363
|
return [DEV_KIT_IGNORE_BEGIN, ...ignoreEntries, DEV_KIT_IGNORE_END].join("\n");
|
|
29204
29364
|
}
|
|
29205
29365
|
function writeDevKitStagedGitignore(stagedGitignorePath, entries) {
|
|
29206
|
-
|
|
29366
|
+
fs5.writeFileSync(stagedGitignorePath, `${createDevKitGitignoreBlock(entries)}
|
|
29207
29367
|
`, "utf8");
|
|
29208
29368
|
}
|
|
29209
29369
|
function ensureMakerAssetPolicyInstructionFiles(targetDir) {
|
|
29210
|
-
const resolvedTargetDir =
|
|
29211
|
-
|
|
29212
|
-
const agentsPath =
|
|
29213
|
-
const existingAgents =
|
|
29214
|
-
|
|
29370
|
+
const resolvedTargetDir = path6.resolve(targetDir);
|
|
29371
|
+
fs5.mkdirSync(resolvedTargetDir, { recursive: true });
|
|
29372
|
+
const agentsPath = path6.join(resolvedTargetDir, AGENTS_INSTRUCTION_FILE);
|
|
29373
|
+
const existingAgents = fs5.existsSync(agentsPath) ? fs5.readFileSync(agentsPath, "utf8") : "";
|
|
29374
|
+
fs5.writeFileSync(agentsPath, prependMakerAssetPolicyBlock(existingAgents), "utf8");
|
|
29215
29375
|
return [AGENTS_INSTRUCTION_FILE];
|
|
29216
29376
|
}
|
|
29217
29377
|
function prependMakerAssetPolicyBlock(existing) {
|
|
@@ -29266,7 +29426,7 @@ function createMakerAssetPolicyBlock() {
|
|
|
29266
29426
|
].join("\n");
|
|
29267
29427
|
}
|
|
29268
29428
|
function mergeDevKitGitignoreBlock(gitignorePath, block) {
|
|
29269
|
-
const existing =
|
|
29429
|
+
const existing = fs5.existsSync(gitignorePath) ? fs5.readFileSync(gitignorePath, "utf8") : "";
|
|
29270
29430
|
const withoutOldBlock = existing.replace(
|
|
29271
29431
|
new RegExp(
|
|
29272
29432
|
`${escapeRegExp(DEV_KIT_IGNORE_BEGIN)}[\\s\\S]*?${escapeRegExp(DEV_KIT_IGNORE_END)}\\n?`,
|
|
@@ -29275,38 +29435,38 @@ function mergeDevKitGitignoreBlock(gitignorePath, block) {
|
|
|
29275
29435
|
""
|
|
29276
29436
|
).trimEnd();
|
|
29277
29437
|
const next = [withoutOldBlock, block, ""].filter((part) => part.length > 0).join("\n\n");
|
|
29278
|
-
|
|
29438
|
+
fs5.writeFileSync(gitignorePath, next, "utf8");
|
|
29279
29439
|
}
|
|
29280
29440
|
function finalizeStagedDevKitGitignore(targetDir) {
|
|
29281
|
-
const stagedGitignorePath =
|
|
29282
|
-
if (!
|
|
29441
|
+
const stagedGitignorePath = path6.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE);
|
|
29442
|
+
if (!fs5.existsSync(stagedGitignorePath)) {
|
|
29283
29443
|
return false;
|
|
29284
29444
|
}
|
|
29285
|
-
const block =
|
|
29445
|
+
const block = fs5.readFileSync(stagedGitignorePath, "utf8").trim();
|
|
29286
29446
|
if (block.length > 0) {
|
|
29287
|
-
mergeDevKitGitignoreBlock(
|
|
29447
|
+
mergeDevKitGitignoreBlock(path6.join(targetDir, ".gitignore"), block);
|
|
29288
29448
|
}
|
|
29289
|
-
|
|
29449
|
+
fs5.rmSync(stagedGitignorePath, { force: true });
|
|
29290
29450
|
return true;
|
|
29291
29451
|
}
|
|
29292
29452
|
function copyEntry(source, target, options = {}) {
|
|
29293
|
-
const stat =
|
|
29453
|
+
const stat = fs5.statSync(source);
|
|
29294
29454
|
if (stat.isDirectory()) {
|
|
29295
|
-
|
|
29296
|
-
for (const child of
|
|
29455
|
+
fs5.mkdirSync(target, { recursive: true });
|
|
29456
|
+
for (const child of fs5.readdirSync(source)) {
|
|
29297
29457
|
if (child === ".DS_Store") {
|
|
29298
29458
|
continue;
|
|
29299
29459
|
}
|
|
29300
|
-
copyEntry(
|
|
29460
|
+
copyEntry(path6.join(source, child), path6.join(target, child), options);
|
|
29301
29461
|
}
|
|
29302
29462
|
return;
|
|
29303
29463
|
}
|
|
29304
29464
|
if (stat.isFile()) {
|
|
29305
|
-
if (options.preserveExisting &&
|
|
29465
|
+
if (options.preserveExisting && fs5.existsSync(target)) {
|
|
29306
29466
|
return;
|
|
29307
29467
|
}
|
|
29308
|
-
|
|
29309
|
-
|
|
29468
|
+
fs5.mkdirSync(path6.dirname(target), { recursive: true });
|
|
29469
|
+
fs5.copyFileSync(source, target);
|
|
29310
29470
|
}
|
|
29311
29471
|
}
|
|
29312
29472
|
function replaceDevKitManagedEntries(targetDir, sourceEntryNames) {
|
|
@@ -29316,11 +29476,11 @@ function replaceDevKitManagedEntries(targetDir, sourceEntryNames) {
|
|
|
29316
29476
|
candidates.add(entry);
|
|
29317
29477
|
}
|
|
29318
29478
|
}
|
|
29319
|
-
for (const entry of readManagedGitignoreEntries(
|
|
29479
|
+
for (const entry of readManagedGitignoreEntries(path6.join(targetDir, ".gitignore"))) {
|
|
29320
29480
|
candidates.add(entry);
|
|
29321
29481
|
}
|
|
29322
29482
|
for (const entry of readManagedGitignoreEntries(
|
|
29323
|
-
|
|
29483
|
+
path6.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE)
|
|
29324
29484
|
)) {
|
|
29325
29485
|
candidates.add(entry);
|
|
29326
29486
|
}
|
|
@@ -29331,14 +29491,14 @@ function replaceDevKitManagedEntries(targetDir, sourceEntryNames) {
|
|
|
29331
29491
|
if (!DEV_KIT_MANAGED_ENTRY_CANDIDATES.includes(entry)) {
|
|
29332
29492
|
continue;
|
|
29333
29493
|
}
|
|
29334
|
-
|
|
29494
|
+
fs5.rmSync(path6.join(targetDir, entry), { recursive: true, force: true });
|
|
29335
29495
|
}
|
|
29336
29496
|
}
|
|
29337
29497
|
function readManagedGitignoreEntries(gitignorePath) {
|
|
29338
|
-
if (!
|
|
29498
|
+
if (!fs5.existsSync(gitignorePath)) {
|
|
29339
29499
|
return [];
|
|
29340
29500
|
}
|
|
29341
|
-
const content =
|
|
29501
|
+
const content = fs5.readFileSync(gitignorePath, "utf8");
|
|
29342
29502
|
const blockPattern = new RegExp(
|
|
29343
29503
|
`${escapeRegExp(DEV_KIT_IGNORE_BEGIN)}\\n([\\s\\S]*?)\\n${escapeRegExp(DEV_KIT_IGNORE_END)}`,
|
|
29344
29504
|
"g"
|
|
@@ -29357,8 +29517,8 @@ function readManagedGitignoreEntries(gitignorePath) {
|
|
|
29357
29517
|
}
|
|
29358
29518
|
function installAiDevKitSkills(targetDir, options = {}) {
|
|
29359
29519
|
var _a3;
|
|
29360
|
-
const toolsDir =
|
|
29361
|
-
if (!
|
|
29520
|
+
const toolsDir = path6.join(targetDir, "tools");
|
|
29521
|
+
if (!fs5.existsSync(toolsDir) || !fs5.statSync(toolsDir).isDirectory()) {
|
|
29362
29522
|
return {
|
|
29363
29523
|
ok: false,
|
|
29364
29524
|
status: "skipped",
|
|
@@ -29370,8 +29530,8 @@ function installAiDevKitSkills(targetDir, options = {}) {
|
|
|
29370
29530
|
}
|
|
29371
29531
|
const isWindows = process.platform === "win32";
|
|
29372
29532
|
const scriptName = isWindows ? "install-skills.ps1" : "install-skills.sh";
|
|
29373
|
-
const scriptPath =
|
|
29374
|
-
if (!
|
|
29533
|
+
const scriptPath = path6.join(toolsDir, scriptName);
|
|
29534
|
+
if (!fs5.existsSync(scriptPath)) {
|
|
29375
29535
|
return {
|
|
29376
29536
|
ok: false,
|
|
29377
29537
|
status: "skipped",
|
|
@@ -29433,7 +29593,7 @@ function runDevKitSkillInstallerForInstall(targetDir, options = {}) {
|
|
|
29433
29593
|
}
|
|
29434
29594
|
function listPresentSkillInstallerOutputEntries(targetDir) {
|
|
29435
29595
|
return SKILL_INSTALLER_OUTPUT_ENTRIES.filter(
|
|
29436
|
-
(entry) =>
|
|
29596
|
+
(entry) => fs5.existsSync(path6.join(targetDir, entry))
|
|
29437
29597
|
);
|
|
29438
29598
|
}
|
|
29439
29599
|
function getAiDevKitVersionsUrl(environment) {
|
|
@@ -29465,16 +29625,16 @@ function writeResolvedDevKitVersionMetadata(targetDir, environment, sourceUrl, c
|
|
|
29465
29625
|
return metadata;
|
|
29466
29626
|
}
|
|
29467
29627
|
async function downloadAndExtractDevKit(url2, fetchImpl = fetch, timeoutMs = DEFAULT_DOWNLOAD_FETCH_TIMEOUT_MS) {
|
|
29468
|
-
const tempDir =
|
|
29469
|
-
const zipPath =
|
|
29628
|
+
const tempDir = fs5.mkdtempSync(path6.join(os3.tmpdir(), "taptap-maker-ai-dev-kit-"));
|
|
29629
|
+
const zipPath = path6.join(tempDir, "ai-dev-kit.zip");
|
|
29470
29630
|
const response = await fetchWithTimeout(fetchImpl, url2, {}, timeoutMs, "AI dev kit download");
|
|
29471
29631
|
if (!response.ok) {
|
|
29472
29632
|
throw new Error(`AI dev kit download failed: HTTP ${response.status} ${response.statusText}`);
|
|
29473
29633
|
}
|
|
29474
29634
|
const payload = Buffer.from(await response.arrayBuffer());
|
|
29475
|
-
|
|
29635
|
+
fs5.writeFileSync(zipPath, payload);
|
|
29476
29636
|
extractZip(zipPath, tempDir);
|
|
29477
|
-
|
|
29637
|
+
fs5.rmSync(zipPath, { force: true });
|
|
29478
29638
|
return tempDir;
|
|
29479
29639
|
}
|
|
29480
29640
|
function extractZip(zipPath, targetDir) {
|
|
@@ -29602,11 +29762,11 @@ function shellQuote(value) {
|
|
|
29602
29762
|
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
29603
29763
|
}
|
|
29604
29764
|
function resolveDevKitRoot(sourceDir) {
|
|
29605
|
-
const directEntries =
|
|
29765
|
+
const directEntries = fs5.existsSync(sourceDir) ? fs5.readdirSync(sourceDir) : [];
|
|
29606
29766
|
if (looksLikeDevKitRoot(sourceDir)) {
|
|
29607
29767
|
return sourceDir;
|
|
29608
29768
|
}
|
|
29609
|
-
const childDirs = directEntries.map((entry) =>
|
|
29769
|
+
const childDirs = directEntries.map((entry) => path6.join(sourceDir, entry)).filter((entryPath) => fs5.existsSync(entryPath) && fs5.statSync(entryPath).isDirectory());
|
|
29610
29770
|
for (const childDir of childDirs) {
|
|
29611
29771
|
if (looksLikeDevKitRoot(childDir)) {
|
|
29612
29772
|
return childDir;
|
|
@@ -29615,7 +29775,7 @@ function resolveDevKitRoot(sourceDir) {
|
|
|
29615
29775
|
throw new Error(`AI dev kit root not found under ${sourceDir}`);
|
|
29616
29776
|
}
|
|
29617
29777
|
function looksLikeDevKitRoot(dir) {
|
|
29618
|
-
return
|
|
29778
|
+
return fs5.existsSync(path6.join(dir, "engine-docs")) || fs5.existsSync(path6.join(dir, ".emmylua")) || fs5.existsSync(path6.join(dir, "urhox-libs"));
|
|
29619
29779
|
}
|
|
29620
29780
|
function formatIgnoreEntry(entry) {
|
|
29621
29781
|
if (entry === ".DS_Store") {
|
|
@@ -29733,7 +29893,7 @@ async function listMakerProjects(options) {
|
|
|
29733
29893
|
}
|
|
29734
29894
|
async function cloneMakerProject(options) {
|
|
29735
29895
|
var _a3, _b, _c, _d, _e, _f, _g, _h;
|
|
29736
|
-
const target =
|
|
29896
|
+
const target = path7.resolve(options.targetDir);
|
|
29737
29897
|
ensureTargetCanBindApp(target, options.appId);
|
|
29738
29898
|
const warnings = createPreCloneWarnings(target);
|
|
29739
29899
|
(_a3 = options.onProgress) == null ? void 0 : _a3.call(options, {
|
|
@@ -29899,7 +30059,7 @@ async function pushMakerProject(options) {
|
|
|
29899
30059
|
phase: "prepare",
|
|
29900
30060
|
message: "Preparing Maker project push"
|
|
29901
30061
|
});
|
|
29902
|
-
const requestedCwd =
|
|
30062
|
+
const requestedCwd = path7.resolve(options.cwd);
|
|
29903
30063
|
const workspace = resolveUsableMakerGitWorkspace(requestedCwd);
|
|
29904
30064
|
const cwd = workspace.projectRoot;
|
|
29905
30065
|
const project = loadProjectConfig(cwd);
|
|
@@ -30530,7 +30690,7 @@ function makeAuthenticatedGitUrl(gitUrl, pat) {
|
|
|
30530
30690
|
return gitUrl.replace(/^https:\/\//, `https://git:${encodeURIComponent(pat)}@`);
|
|
30531
30691
|
}
|
|
30532
30692
|
async function fetchAndCheckoutTarget(target, authUrl, pat, onProgress) {
|
|
30533
|
-
if (
|
|
30693
|
+
if (fs6.existsSync(target) && hasDirectoryEntries(target)) {
|
|
30534
30694
|
onProgress == null ? void 0 : onProgress({
|
|
30535
30695
|
progress: 10,
|
|
30536
30696
|
total: 100,
|
|
@@ -30577,23 +30737,23 @@ function emitFirstCloneWaitNotice(onProgress, phase) {
|
|
|
30577
30737
|
});
|
|
30578
30738
|
}
|
|
30579
30739
|
function hasDirectoryEntries(target) {
|
|
30580
|
-
if (!
|
|
30740
|
+
if (!fs6.existsSync(target)) {
|
|
30581
30741
|
return false;
|
|
30582
30742
|
}
|
|
30583
|
-
return
|
|
30743
|
+
return fs6.readdirSync(target).length > 0;
|
|
30584
30744
|
}
|
|
30585
30745
|
function listLocalFiles(root) {
|
|
30586
|
-
if (!
|
|
30746
|
+
if (!fs6.existsSync(root)) {
|
|
30587
30747
|
return [];
|
|
30588
30748
|
}
|
|
30589
30749
|
const files = [];
|
|
30590
30750
|
const visit = (dir, relativeDir) => {
|
|
30591
|
-
for (const entry of
|
|
30751
|
+
for (const entry of fs6.readdirSync(dir, { withFileTypes: true })) {
|
|
30592
30752
|
const relativePath = relativeDir ? `${relativeDir}/${entry.name}` : entry.name;
|
|
30593
30753
|
if (entry.name === ".git" || relativePath === ".maker-mcp" || relativePath.startsWith(".maker-mcp/") || entry.name === ".DS_Store") {
|
|
30594
30754
|
continue;
|
|
30595
30755
|
}
|
|
30596
|
-
const fullPath =
|
|
30756
|
+
const fullPath = path7.join(dir, entry.name);
|
|
30597
30757
|
if (entry.isDirectory()) {
|
|
30598
30758
|
visit(fullPath, relativePath);
|
|
30599
30759
|
continue;
|
|
@@ -30607,10 +30767,10 @@ function listLocalFiles(root) {
|
|
|
30607
30767
|
return files;
|
|
30608
30768
|
}
|
|
30609
30769
|
function listPreCloneNoticeFiles(root) {
|
|
30610
|
-
if (!
|
|
30770
|
+
if (!fs6.existsSync(root)) {
|
|
30611
30771
|
return [];
|
|
30612
30772
|
}
|
|
30613
|
-
return
|
|
30773
|
+
return fs6.readdirSync(root, { withFileTypes: true }).filter((entry) => !isIgnorablePreCloneEntry(entry.name)).map((entry) => entry.name).sort();
|
|
30614
30774
|
}
|
|
30615
30775
|
function createPreCloneWarnings(target) {
|
|
30616
30776
|
const preCloneLocalFiles = listPreCloneNoticeFiles(target);
|
|
@@ -30733,7 +30893,7 @@ function ensureOwnGitRoot(repoDir) {
|
|
|
30733
30893
|
);
|
|
30734
30894
|
}
|
|
30735
30895
|
function inspectMakerDirectoryGitStatus(cwd) {
|
|
30736
|
-
const targetDir =
|
|
30896
|
+
const targetDir = path7.resolve(cwd);
|
|
30737
30897
|
const gitRoot = resolveGitRoot(targetDir);
|
|
30738
30898
|
const gitDir = resolveGitDir(targetDir);
|
|
30739
30899
|
const makerBinding = findMakerProjectBinding(targetDir);
|
|
@@ -30806,16 +30966,16 @@ function formatMakerGitRootMismatch(status) {
|
|
|
30806
30966
|
}
|
|
30807
30967
|
function findMakerProjectBinding(startDir) {
|
|
30808
30968
|
var _a3;
|
|
30809
|
-
let current =
|
|
30969
|
+
let current = path7.resolve(startDir);
|
|
30810
30970
|
while (current.length > 0) {
|
|
30811
30971
|
const configPath = getProjectConfigPath(current);
|
|
30812
|
-
if (
|
|
30972
|
+
if (fs6.existsSync(configPath) && ((_a3 = loadProjectConfig(current)) == null ? void 0 : _a3.project_id)) {
|
|
30813
30973
|
return {
|
|
30814
30974
|
projectRoot: current,
|
|
30815
30975
|
configPath
|
|
30816
30976
|
};
|
|
30817
30977
|
}
|
|
30818
|
-
const parent =
|
|
30978
|
+
const parent = path7.dirname(current);
|
|
30819
30979
|
if (parent === current) {
|
|
30820
30980
|
return null;
|
|
30821
30981
|
}
|
|
@@ -30825,7 +30985,7 @@ function findMakerProjectBinding(startDir) {
|
|
|
30825
30985
|
}
|
|
30826
30986
|
function resolveGitRoot(cwd) {
|
|
30827
30987
|
try {
|
|
30828
|
-
return
|
|
30988
|
+
return path7.resolve(readGitSync(["-C", cwd, "rev-parse", "--show-toplevel"]).trim());
|
|
30829
30989
|
} catch {
|
|
30830
30990
|
return void 0;
|
|
30831
30991
|
}
|
|
@@ -30833,7 +30993,7 @@ function resolveGitRoot(cwd) {
|
|
|
30833
30993
|
function resolveGitDir(cwd) {
|
|
30834
30994
|
try {
|
|
30835
30995
|
const gitDir = readGitSync(["-C", cwd, "rev-parse", "--git-dir"]).trim();
|
|
30836
|
-
return
|
|
30996
|
+
return path7.isAbsolute(gitDir) ? path7.resolve(gitDir) : path7.resolve(cwd, gitDir);
|
|
30837
30997
|
} catch {
|
|
30838
30998
|
return void 0;
|
|
30839
30999
|
}
|
|
@@ -30842,9 +31002,9 @@ function samePath(left, right) {
|
|
|
30842
31002
|
return normalizePathForCompare(left) === normalizePathForCompare(right);
|
|
30843
31003
|
}
|
|
30844
31004
|
function normalizePathForCompare(value) {
|
|
30845
|
-
const resolved =
|
|
31005
|
+
const resolved = path7.resolve(value);
|
|
30846
31006
|
try {
|
|
30847
|
-
return
|
|
31007
|
+
return fs6.realpathSync.native(resolved);
|
|
30848
31008
|
} catch {
|
|
30849
31009
|
return resolved;
|
|
30850
31010
|
}
|
|
@@ -30957,7 +31117,7 @@ async function runGitCaptureWithTransientRetry(args, options = {}) {
|
|
|
30957
31117
|
async function runWithTransientRetry(operation, options) {
|
|
30958
31118
|
var _a3;
|
|
30959
31119
|
let retries = 0;
|
|
30960
|
-
const maxRetries =
|
|
31120
|
+
const maxRetries = 5;
|
|
30961
31121
|
for (; ; ) {
|
|
30962
31122
|
try {
|
|
30963
31123
|
await operation();
|
|
@@ -30975,7 +31135,7 @@ async function runWithTransientRetry(operation, options) {
|
|
|
30975
31135
|
phase: options.stage,
|
|
30976
31136
|
message: formatGitRetryProgressMessage(options.stage, decision, retries, maxRetries)
|
|
30977
31137
|
});
|
|
30978
|
-
await sleep(
|
|
31138
|
+
await sleep(getMakerGitRetryDelayMs() * retries);
|
|
30979
31139
|
}
|
|
30980
31140
|
}
|
|
30981
31141
|
}
|
|
@@ -31018,9 +31178,9 @@ function appendRetryExhausted(error2, retryAttempts, decision) {
|
|
|
31018
31178
|
].filter(Boolean).join("\n")
|
|
31019
31179
|
);
|
|
31020
31180
|
}
|
|
31021
|
-
function
|
|
31181
|
+
function getMakerGitRetryDelayMs() {
|
|
31022
31182
|
const value = Number.parseInt(process.env.TAPTAP_MAKER_GIT_RETRY_DELAY_MS || "", 10);
|
|
31023
|
-
return Number.isFinite(value) && value >= 0 ? value :
|
|
31183
|
+
return Number.isFinite(value) && value >= 0 ? value : 5e3;
|
|
31024
31184
|
}
|
|
31025
31185
|
function sleep(ms) {
|
|
31026
31186
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -31210,8 +31370,8 @@ async function requestTapAuthWithPat(manualPat, environment, options = {}) {
|
|
|
31210
31370
|
|
|
31211
31371
|
// src/maker/system/python.ts
|
|
31212
31372
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
31213
|
-
import
|
|
31214
|
-
import
|
|
31373
|
+
import fs7 from "node:fs";
|
|
31374
|
+
import path8 from "node:path";
|
|
31215
31375
|
var PYTHON_INFO_SCRIPT = [
|
|
31216
31376
|
"import json, sys",
|
|
31217
31377
|
'print(json.dumps({"executable": sys.executable, "version": ".".join(map(str, sys.version_info[:3]))}))'
|
|
@@ -31220,16 +31380,16 @@ var DEFAULT_PYTHON_VERSION = "3.12";
|
|
|
31220
31380
|
var MINIMUM_PYTHON_VERSION = "3.8";
|
|
31221
31381
|
var RECOMMENDED_PYTHON_VERSION = "3.12";
|
|
31222
31382
|
function getMakerPythonConfigPath() {
|
|
31223
|
-
return
|
|
31383
|
+
return path8.join(getMakerHome(), "python.json");
|
|
31224
31384
|
}
|
|
31225
31385
|
function getMakerUvInstallRoot() {
|
|
31226
|
-
return
|
|
31386
|
+
return path8.join(getMakerHome(), "bin");
|
|
31227
31387
|
}
|
|
31228
31388
|
function getMakerUvPath(platform = process.platform) {
|
|
31229
|
-
return
|
|
31389
|
+
return path8.join(getMakerUvInstallRoot(), platform === "win32" ? "uv.exe" : "uv");
|
|
31230
31390
|
}
|
|
31231
31391
|
function getMakerUvPythonInstallDir() {
|
|
31232
|
-
return
|
|
31392
|
+
return path8.join(getMakerHome(), "python", "uv");
|
|
31233
31393
|
}
|
|
31234
31394
|
function checkMakerPythonEnvironment(options = {}) {
|
|
31235
31395
|
const platform = options.platform || process.platform;
|
|
@@ -31245,7 +31405,7 @@ function checkMakerPythonEnvironment(options = {}) {
|
|
|
31245
31405
|
pathCommand,
|
|
31246
31406
|
uv: {
|
|
31247
31407
|
path: uvPath,
|
|
31248
|
-
installed:
|
|
31408
|
+
installed: fs7.existsSync(uvPath),
|
|
31249
31409
|
version: readUvVersion(uvPath, runner)
|
|
31250
31410
|
}
|
|
31251
31411
|
};
|
|
@@ -31467,10 +31627,10 @@ function resultToEnvironment(result, base) {
|
|
|
31467
31627
|
}
|
|
31468
31628
|
function ensureUvInstalled(platform, runner) {
|
|
31469
31629
|
const uvPath = getMakerUvPath(platform);
|
|
31470
|
-
if (
|
|
31630
|
+
if (fs7.existsSync(uvPath)) {
|
|
31471
31631
|
return uvPath;
|
|
31472
31632
|
}
|
|
31473
|
-
|
|
31633
|
+
fs7.mkdirSync(getMakerUvInstallRoot(), { recursive: true });
|
|
31474
31634
|
const env = {
|
|
31475
31635
|
...process.env,
|
|
31476
31636
|
INSTALLER_NO_MODIFY_PATH: "1",
|
|
@@ -31493,13 +31653,13 @@ function ensureUvInstalled(platform, runner) {
|
|
|
31493
31653
|
if (install.status !== 0) {
|
|
31494
31654
|
throw new Error(formatSetupFailure("uv installer failed", install));
|
|
31495
31655
|
}
|
|
31496
|
-
if (!
|
|
31497
|
-
const nestedUvPath =
|
|
31656
|
+
if (!fs7.existsSync(uvPath)) {
|
|
31657
|
+
const nestedUvPath = path8.join(
|
|
31498
31658
|
getMakerUvInstallRoot(),
|
|
31499
31659
|
"bin",
|
|
31500
31660
|
platform === "win32" ? "uv.exe" : "uv"
|
|
31501
31661
|
);
|
|
31502
|
-
if (
|
|
31662
|
+
if (fs7.existsSync(nestedUvPath)) {
|
|
31503
31663
|
return nestedUvPath;
|
|
31504
31664
|
}
|
|
31505
31665
|
throw new Error(`uv installer finished, but ${uvPath} was not created.`);
|
|
@@ -31510,11 +31670,11 @@ function createUvPythonEnv() {
|
|
|
31510
31670
|
return {
|
|
31511
31671
|
...process.env,
|
|
31512
31672
|
UV_PYTHON_INSTALL_DIR: getMakerUvPythonInstallDir(),
|
|
31513
|
-
UV_CACHE_DIR:
|
|
31673
|
+
UV_CACHE_DIR: path8.join(getMakerHome(), "cache", "uv")
|
|
31514
31674
|
};
|
|
31515
31675
|
}
|
|
31516
31676
|
function readUvVersion(uvPath, runner) {
|
|
31517
|
-
if (!
|
|
31677
|
+
if (!fs7.existsSync(uvPath)) {
|
|
31518
31678
|
return void 0;
|
|
31519
31679
|
}
|
|
31520
31680
|
const result = runner(uvPath, ["--version"], { encoding: "utf8" });
|
|
@@ -31567,11 +31727,11 @@ function parseVersionTuple(version2) {
|
|
|
31567
31727
|
}
|
|
31568
31728
|
function loadPythonRuntimeConfig() {
|
|
31569
31729
|
const configPath = getMakerPythonConfigPath();
|
|
31570
|
-
if (!
|
|
31730
|
+
if (!fs7.existsSync(configPath)) {
|
|
31571
31731
|
return void 0;
|
|
31572
31732
|
}
|
|
31573
31733
|
try {
|
|
31574
|
-
const data = JSON.parse(
|
|
31734
|
+
const data = JSON.parse(fs7.readFileSync(configPath, "utf8"));
|
|
31575
31735
|
if (typeof data.python === "string" || data.status === "setup_failed") {
|
|
31576
31736
|
return data;
|
|
31577
31737
|
}
|
|
@@ -31590,8 +31750,8 @@ function savePythonRuntimeConfig(environment) {
|
|
|
31590
31750
|
version: environment.version,
|
|
31591
31751
|
saved_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
31592
31752
|
};
|
|
31593
|
-
|
|
31594
|
-
|
|
31753
|
+
fs7.mkdirSync(path8.dirname(getMakerPythonConfigPath()), { recursive: true });
|
|
31754
|
+
fs7.writeFileSync(getMakerPythonConfigPath(), JSON.stringify(config2, null, 2), "utf8");
|
|
31595
31755
|
}
|
|
31596
31756
|
function savePythonSetupFailure(error2) {
|
|
31597
31757
|
const config2 = {
|
|
@@ -31599,8 +31759,8 @@ function savePythonSetupFailure(error2) {
|
|
|
31599
31759
|
error: error2 instanceof Error ? error2.message : String(error2),
|
|
31600
31760
|
saved_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
31601
31761
|
};
|
|
31602
|
-
|
|
31603
|
-
|
|
31762
|
+
fs7.mkdirSync(path8.dirname(getMakerPythonConfigPath()), { recursive: true });
|
|
31763
|
+
fs7.writeFileSync(getMakerPythonConfigPath(), JSON.stringify(config2, null, 2), "utf8");
|
|
31604
31764
|
}
|
|
31605
31765
|
function formatSetupFailure(message, result) {
|
|
31606
31766
|
var _a3, _b, _c;
|
|
@@ -31615,17 +31775,21 @@ function formatSetupFailure(message, result) {
|
|
|
31615
31775
|
|
|
31616
31776
|
// src/maker/system/luaLsp.ts
|
|
31617
31777
|
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
31618
|
-
import
|
|
31619
|
-
import
|
|
31778
|
+
import fs8 from "node:fs";
|
|
31779
|
+
import path9 from "node:path";
|
|
31620
31780
|
var LUA_LSP_PACKAGE = "maker-lua-lsp";
|
|
31621
31781
|
var LUA_LSP_IDES = "codex,cursor,claude";
|
|
31622
31782
|
var LUA_LSP_SETUP_TIMEOUT_MS = 12e4;
|
|
31783
|
+
var LUA_LSP_PROBE_TIMEOUT_MS = 5e3;
|
|
31623
31784
|
var PYTHON_SCRIPTS_DIR_SCRIPT = [
|
|
31624
31785
|
"import sysconfig",
|
|
31625
31786
|
'print(sysconfig.get_path("scripts") or "")'
|
|
31626
31787
|
].join("; ");
|
|
31627
31788
|
function getMakerLuaLspConfigPath() {
|
|
31628
|
-
return
|
|
31789
|
+
return path9.join(getMakerHome(), "lua-lsp.json");
|
|
31790
|
+
}
|
|
31791
|
+
function getMakerLuaLspVenvDir() {
|
|
31792
|
+
return path9.join(getMakerHome(), "lua-lsp-venv");
|
|
31629
31793
|
}
|
|
31630
31794
|
function checkMakerLuaLspEnvironment(options = {}) {
|
|
31631
31795
|
const runner = options.spawn || spawnSync5;
|
|
@@ -31642,6 +31806,23 @@ function checkMakerLuaLspEnvironment(options = {}) {
|
|
|
31642
31806
|
nextAction: "本地 Lua 诊断需要 Python 环境。请先运行 `taptap-maker python setup`,它会继续准备 maker-lua-lsp。"
|
|
31643
31807
|
};
|
|
31644
31808
|
}
|
|
31809
|
+
const saved = loadLuaLspRuntimeConfig();
|
|
31810
|
+
if (saved == null ? void 0 : saved.command) {
|
|
31811
|
+
const version3 = readLuaLspVersion(saved.command, runner);
|
|
31812
|
+
if (version3) {
|
|
31813
|
+
return {
|
|
31814
|
+
...base,
|
|
31815
|
+
ready: true,
|
|
31816
|
+
status: "ready",
|
|
31817
|
+
command: saved.command,
|
|
31818
|
+
version: version3,
|
|
31819
|
+
python: saved.python || python.python,
|
|
31820
|
+
scriptsDir: path9.dirname(saved.command),
|
|
31821
|
+
missing: [],
|
|
31822
|
+
nextAction: "maker-lua-lsp 已安装;本地 Lua 诊断可用。"
|
|
31823
|
+
};
|
|
31824
|
+
}
|
|
31825
|
+
}
|
|
31645
31826
|
const resolved = resolveLuaLspCommand(python, platform, runner);
|
|
31646
31827
|
const command = resolved.command || LUA_LSP_PACKAGE;
|
|
31647
31828
|
const version2 = readLuaLspVersion(command, runner);
|
|
@@ -31658,7 +31839,6 @@ function checkMakerLuaLspEnvironment(options = {}) {
|
|
|
31658
31839
|
nextAction: "maker-lua-lsp 已安装;本地 Lua 诊断可用。"
|
|
31659
31840
|
};
|
|
31660
31841
|
}
|
|
31661
|
-
const saved = loadLuaLspRuntimeConfig();
|
|
31662
31842
|
if ((saved == null ? void 0 : saved.status) === "setup_failed") {
|
|
31663
31843
|
return {
|
|
31664
31844
|
...base,
|
|
@@ -31700,7 +31880,20 @@ function setupMakerLuaLspEnvironment(options = {}) {
|
|
|
31700
31880
|
saveLuaLspRuntimeConfig(environment2);
|
|
31701
31881
|
return { changed: false, environment: environment2, python };
|
|
31702
31882
|
}
|
|
31703
|
-
const
|
|
31883
|
+
const venv = ensureLuaLspVenv(python, platform, runner);
|
|
31884
|
+
if (venv.result && venv.result.status !== 0) {
|
|
31885
|
+
const environment2 = formatLuaLspSetupFailure(
|
|
31886
|
+
platform,
|
|
31887
|
+
python,
|
|
31888
|
+
"maker-lua-lsp venv creation failed",
|
|
31889
|
+
venv.result,
|
|
31890
|
+
venv.command,
|
|
31891
|
+
venv.scriptsDir
|
|
31892
|
+
);
|
|
31893
|
+
saveLuaLspRuntimeConfig(environment2);
|
|
31894
|
+
return { changed: false, environment: environment2, python };
|
|
31895
|
+
}
|
|
31896
|
+
const pipInstall = runner(venv.python, ["-m", "pip", "install", "--upgrade", LUA_LSP_PACKAGE], {
|
|
31704
31897
|
encoding: "utf8",
|
|
31705
31898
|
timeout: LUA_LSP_SETUP_TIMEOUT_MS
|
|
31706
31899
|
});
|
|
@@ -31709,13 +31902,23 @@ function setupMakerLuaLspEnvironment(options = {}) {
|
|
|
31709
31902
|
platform,
|
|
31710
31903
|
python,
|
|
31711
31904
|
"maker-lua-lsp pip install failed",
|
|
31712
|
-
pipInstall
|
|
31905
|
+
pipInstall,
|
|
31906
|
+
venv.command,
|
|
31907
|
+
venv.scriptsDir
|
|
31713
31908
|
);
|
|
31714
31909
|
saveLuaLspRuntimeConfig(environment2);
|
|
31715
31910
|
return { changed: false, environment: environment2, python };
|
|
31716
31911
|
}
|
|
31717
|
-
const resolved = resolveLuaLspCommand(
|
|
31718
|
-
|
|
31912
|
+
const resolved = resolveLuaLspCommand(
|
|
31913
|
+
{
|
|
31914
|
+
...python,
|
|
31915
|
+
python: venv.python
|
|
31916
|
+
},
|
|
31917
|
+
platform,
|
|
31918
|
+
runner
|
|
31919
|
+
);
|
|
31920
|
+
const command = resolved.command || venv.command;
|
|
31921
|
+
const scriptsDir = resolved.scriptsDir || venv.scriptsDir;
|
|
31719
31922
|
const ideInstall = runner(command, ["install", "--ide", LUA_LSP_IDES], {
|
|
31720
31923
|
encoding: "utf8",
|
|
31721
31924
|
timeout: LUA_LSP_SETUP_TIMEOUT_MS
|
|
@@ -31727,7 +31930,7 @@ function setupMakerLuaLspEnvironment(options = {}) {
|
|
|
31727
31930
|
"maker-lua-lsp IDE install failed",
|
|
31728
31931
|
ideInstall,
|
|
31729
31932
|
command,
|
|
31730
|
-
|
|
31933
|
+
scriptsDir
|
|
31731
31934
|
);
|
|
31732
31935
|
saveLuaLspRuntimeConfig(environment2);
|
|
31733
31936
|
return { changed: false, environment: environment2, python };
|
|
@@ -31739,7 +31942,7 @@ function setupMakerLuaLspEnvironment(options = {}) {
|
|
|
31739
31942
|
command,
|
|
31740
31943
|
version: readLuaLspVersion(command, runner),
|
|
31741
31944
|
python: python.python,
|
|
31742
|
-
scriptsDir
|
|
31945
|
+
scriptsDir,
|
|
31743
31946
|
missing: [],
|
|
31744
31947
|
nextAction: "maker-lua-lsp 已安装并完成 Codex/Cursor/Claude 配置。"
|
|
31745
31948
|
};
|
|
@@ -31790,19 +31993,61 @@ function createLuaLspBase(platform) {
|
|
|
31790
31993
|
};
|
|
31791
31994
|
}
|
|
31792
31995
|
function resolveLuaLspCommand(python, platform, runner) {
|
|
31996
|
+
const venvCommand = getLuaLspVenvCommand(platform);
|
|
31997
|
+
if (fs8.existsSync(venvCommand)) {
|
|
31998
|
+
return { command: venvCommand, scriptsDir: path9.dirname(venvCommand) };
|
|
31999
|
+
}
|
|
31793
32000
|
const scriptsDir = readPythonScriptsDir(python.python, runner);
|
|
31794
32001
|
if (scriptsDir) {
|
|
31795
|
-
const command =
|
|
32002
|
+
const command = path9.join(
|
|
31796
32003
|
scriptsDir,
|
|
31797
32004
|
platform === "win32" ? "maker-lua-lsp.exe" : "maker-lua-lsp"
|
|
31798
32005
|
);
|
|
31799
|
-
if (
|
|
32006
|
+
if (fs8.existsSync(command)) {
|
|
31800
32007
|
return { command, scriptsDir };
|
|
31801
32008
|
}
|
|
31802
32009
|
return { scriptsDir };
|
|
31803
32010
|
}
|
|
31804
32011
|
return {};
|
|
31805
32012
|
}
|
|
32013
|
+
function ensureLuaLspVenv(python, platform, runner) {
|
|
32014
|
+
const venvDir = getMakerLuaLspVenvDir();
|
|
32015
|
+
const venvPython = getLuaLspVenvPython(platform);
|
|
32016
|
+
const scriptsDir = getLuaLspVenvScriptsDir(platform);
|
|
32017
|
+
const command = getLuaLspVenvCommand(platform);
|
|
32018
|
+
if (!isLuaLspVenvComplete(platform)) {
|
|
32019
|
+
const result = runner(python.python || "", ["-m", "venv", venvDir], {
|
|
32020
|
+
encoding: "utf8",
|
|
32021
|
+
timeout: LUA_LSP_SETUP_TIMEOUT_MS
|
|
32022
|
+
});
|
|
32023
|
+
if (result.status !== 0) {
|
|
32024
|
+
return { python: venvPython, scriptsDir, command, result };
|
|
32025
|
+
}
|
|
32026
|
+
}
|
|
32027
|
+
return { python: venvPython, scriptsDir, command };
|
|
32028
|
+
}
|
|
32029
|
+
function isLuaLspVenvComplete(platform) {
|
|
32030
|
+
return fs8.existsSync(getLuaLspVenvPython(platform)) && fs8.existsSync(getLuaLspVenvConfigPath());
|
|
32031
|
+
}
|
|
32032
|
+
function getLuaLspVenvConfigPath() {
|
|
32033
|
+
return path9.join(getMakerLuaLspVenvDir(), "pyvenv.cfg");
|
|
32034
|
+
}
|
|
32035
|
+
function getLuaLspVenvPython(platform) {
|
|
32036
|
+
return path9.join(
|
|
32037
|
+
getMakerLuaLspVenvDir(),
|
|
32038
|
+
platform === "win32" ? "Scripts" : "bin",
|
|
32039
|
+
platform === "win32" ? "python.exe" : "python"
|
|
32040
|
+
);
|
|
32041
|
+
}
|
|
32042
|
+
function getLuaLspVenvScriptsDir(platform) {
|
|
32043
|
+
return path9.join(getMakerLuaLspVenvDir(), platform === "win32" ? "Scripts" : "bin");
|
|
32044
|
+
}
|
|
32045
|
+
function getLuaLspVenvCommand(platform) {
|
|
32046
|
+
return path9.join(
|
|
32047
|
+
getLuaLspVenvScriptsDir(platform),
|
|
32048
|
+
platform === "win32" ? "maker-lua-lsp.exe" : "maker-lua-lsp"
|
|
32049
|
+
);
|
|
32050
|
+
}
|
|
31806
32051
|
function readPythonScriptsDir(python, runner) {
|
|
31807
32052
|
if (!python) {
|
|
31808
32053
|
return void 0;
|
|
@@ -31811,8 +32056,18 @@ function readPythonScriptsDir(python, runner) {
|
|
|
31811
32056
|
return result.status === 0 ? result.stdout.trim().split(/\r?\n/)[0] || void 0 : void 0;
|
|
31812
32057
|
}
|
|
31813
32058
|
function readLuaLspVersion(command, runner) {
|
|
31814
|
-
const result = runner(command, ["--version"], {
|
|
31815
|
-
|
|
32059
|
+
const result = runner(command, ["--version"], {
|
|
32060
|
+
encoding: "utf8",
|
|
32061
|
+
timeout: LUA_LSP_PROBE_TIMEOUT_MS
|
|
32062
|
+
});
|
|
32063
|
+
if (result.status === 0) {
|
|
32064
|
+
return result.stdout.trim() || "installed";
|
|
32065
|
+
}
|
|
32066
|
+
const help = runner(command, ["--help"], {
|
|
32067
|
+
encoding: "utf8",
|
|
32068
|
+
timeout: LUA_LSP_PROBE_TIMEOUT_MS
|
|
32069
|
+
});
|
|
32070
|
+
return help.status === 0 ? "installed" : void 0;
|
|
31816
32071
|
}
|
|
31817
32072
|
function formatLuaLspSetupFailure(platform, python, message, result, command, scriptsDir) {
|
|
31818
32073
|
var _a3, _b, _c;
|
|
@@ -31836,11 +32091,11 @@ function formatLuaLspSetupFailure(platform, python, message, result, command, sc
|
|
|
31836
32091
|
}
|
|
31837
32092
|
function loadLuaLspRuntimeConfig() {
|
|
31838
32093
|
const configPath = getMakerLuaLspConfigPath();
|
|
31839
|
-
if (!
|
|
32094
|
+
if (!fs8.existsSync(configPath)) {
|
|
31840
32095
|
return void 0;
|
|
31841
32096
|
}
|
|
31842
32097
|
try {
|
|
31843
|
-
return JSON.parse(
|
|
32098
|
+
return JSON.parse(fs8.readFileSync(configPath, "utf8"));
|
|
31844
32099
|
} catch {
|
|
31845
32100
|
return void 0;
|
|
31846
32101
|
}
|
|
@@ -31853,13 +32108,13 @@ function saveLuaLspRuntimeConfig(environment) {
|
|
|
31853
32108
|
error: environment.error,
|
|
31854
32109
|
saved_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
31855
32110
|
};
|
|
31856
|
-
|
|
31857
|
-
|
|
32111
|
+
fs8.mkdirSync(path9.dirname(getMakerLuaLspConfigPath()), { recursive: true });
|
|
32112
|
+
fs8.writeFileSync(getMakerLuaLspConfigPath(), JSON.stringify(config2, null, 2), "utf8");
|
|
31858
32113
|
}
|
|
31859
32114
|
|
|
31860
32115
|
// src/maker/cli/skill.ts
|
|
31861
|
-
import
|
|
31862
|
-
import
|
|
32116
|
+
import fs9 from "node:fs";
|
|
32117
|
+
import path10 from "node:path";
|
|
31863
32118
|
import { fileURLToPath } from "node:url";
|
|
31864
32119
|
var MAKER_LOCAL_SKILL_NAME = "taptap-maker-local";
|
|
31865
32120
|
var MAKER_DEV_KIT_GUIDE_SKILL_NAME = "taptap-maker-dev-kit-guide";
|
|
@@ -31878,7 +32133,7 @@ var BUNDLED_SKILLS = [
|
|
|
31878
32133
|
function formatMakerSkillStatus(_options = {}) {
|
|
31879
32134
|
const skillDocuments = BUNDLED_SKILLS.map((skill) => ({
|
|
31880
32135
|
name: skill.name,
|
|
31881
|
-
path:
|
|
32136
|
+
path: path10.join(resolveMakerSkillSourceDir(skill.name), "SKILL.md")
|
|
31882
32137
|
}));
|
|
31883
32138
|
return [
|
|
31884
32139
|
"TapTap Maker workflow guide documents",
|
|
@@ -31911,11 +32166,11 @@ function formatMakerSkillStatus(_options = {}) {
|
|
|
31911
32166
|
}
|
|
31912
32167
|
function resolveMakerSkillSourceDir(skillName = MAKER_LOCAL_SKILL_NAME) {
|
|
31913
32168
|
const candidates = [
|
|
31914
|
-
|
|
32169
|
+
path10.join(process.cwd(), "skills", skillName),
|
|
31915
32170
|
getBundledSkillSourceDir(skillName)
|
|
31916
32171
|
].filter(Boolean);
|
|
31917
32172
|
for (const candidate of candidates) {
|
|
31918
|
-
if (
|
|
32173
|
+
if (fs9.existsSync(path10.join(candidate, "SKILL.md"))) {
|
|
31919
32174
|
return candidate;
|
|
31920
32175
|
}
|
|
31921
32176
|
}
|
|
@@ -31928,13 +32183,13 @@ function getBundledSkillSourceDir(skillName) {
|
|
|
31928
32183
|
return null;
|
|
31929
32184
|
}
|
|
31930
32185
|
const bundlePath = fileURLToPath(__MAKER_BUNDLE_URL__);
|
|
31931
|
-
const packageRoot =
|
|
31932
|
-
return
|
|
32186
|
+
const packageRoot = path10.dirname(path10.dirname(bundlePath));
|
|
32187
|
+
return path10.join(packageRoot, "skills", skillName);
|
|
31933
32188
|
}
|
|
31934
32189
|
|
|
31935
32190
|
// src/maker/server/runtimeLogs.ts
|
|
31936
|
-
import
|
|
31937
|
-
import
|
|
32191
|
+
import fs10 from "node:fs";
|
|
32192
|
+
import path11 from "node:path";
|
|
31938
32193
|
var DEFAULT_RUNTIME_LOG_SINCE_SECONDS = 600;
|
|
31939
32194
|
var DEFAULT_RUNTIME_LOG_IDLE_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
31940
32195
|
var MAX_RUNTIME_LOG_WINDOW_SECONDS = 3600;
|
|
@@ -32075,19 +32330,19 @@ async function pullRuntimeLogs(options) {
|
|
|
32075
32330
|
}
|
|
32076
32331
|
function resetRuntimeLogs(projectRoot) {
|
|
32077
32332
|
const runtimeDir = getRuntimeLogDir(projectRoot);
|
|
32078
|
-
|
|
32333
|
+
fs10.mkdirSync(runtimeDir, { recursive: true });
|
|
32079
32334
|
for (const file2 of RUNTIME_LOG_FILES_TO_RESET) {
|
|
32080
|
-
|
|
32335
|
+
fs10.rmSync(path11.join(runtimeDir, file2), { force: true });
|
|
32081
32336
|
}
|
|
32082
32337
|
return runtimeDir;
|
|
32083
32338
|
}
|
|
32084
32339
|
function readRuntimeLogState(projectRoot) {
|
|
32085
32340
|
const statePath = getRuntimeLogStatePath(projectRoot);
|
|
32086
|
-
if (!
|
|
32341
|
+
if (!fs10.existsSync(statePath)) {
|
|
32087
32342
|
return null;
|
|
32088
32343
|
}
|
|
32089
32344
|
try {
|
|
32090
|
-
const state = JSON.parse(
|
|
32345
|
+
const state = JSON.parse(fs10.readFileSync(statePath, "utf8"));
|
|
32091
32346
|
return isRuntimeLogState(state) ? state : null;
|
|
32092
32347
|
} catch {
|
|
32093
32348
|
return null;
|
|
@@ -32115,9 +32370,9 @@ function normalizeRuntimeLogQueryResult(result) {
|
|
|
32115
32370
|
};
|
|
32116
32371
|
}
|
|
32117
32372
|
function writeRuntimeLogRawResponse(projectRoot, raw) {
|
|
32118
|
-
const rawPath =
|
|
32119
|
-
|
|
32120
|
-
|
|
32373
|
+
const rawPath = path11.join(getRuntimeLogDir(projectRoot), "last-query-runtime-logs-result.json");
|
|
32374
|
+
fs10.mkdirSync(path11.dirname(rawPath), { recursive: true });
|
|
32375
|
+
fs10.writeFileSync(
|
|
32121
32376
|
rawPath,
|
|
32122
32377
|
`${JSON.stringify({ capturedAt: (/* @__PURE__ */ new Date()).toISOString(), raw }, null, 2)}
|
|
32123
32378
|
`,
|
|
@@ -32126,7 +32381,7 @@ function writeRuntimeLogRawResponse(projectRoot, raw) {
|
|
|
32126
32381
|
return rawPath;
|
|
32127
32382
|
}
|
|
32128
32383
|
function appendRuntimeLogs(projectRoot, logs) {
|
|
32129
|
-
|
|
32384
|
+
fs10.mkdirSync(getRuntimeLogDir(projectRoot), { recursive: true });
|
|
32130
32385
|
if (logs.length === 0) {
|
|
32131
32386
|
return { files: [], written: 0 };
|
|
32132
32387
|
}
|
|
@@ -32134,7 +32389,7 @@ function appendRuntimeLogs(projectRoot, logs) {
|
|
|
32134
32389
|
let written = 0;
|
|
32135
32390
|
for (const log of logs) {
|
|
32136
32391
|
const line = JSON.stringify(compactRuntimeLogEntry(log));
|
|
32137
|
-
|
|
32392
|
+
fs10.appendFileSync(filePath, `${line}
|
|
32138
32393
|
`, "utf8");
|
|
32139
32394
|
written += 1;
|
|
32140
32395
|
}
|
|
@@ -32142,11 +32397,11 @@ function appendRuntimeLogs(projectRoot, logs) {
|
|
|
32142
32397
|
}
|
|
32143
32398
|
function writeRuntimeLogState(projectRoot, state) {
|
|
32144
32399
|
const statePath = getRuntimeLogStatePath(projectRoot);
|
|
32145
|
-
|
|
32400
|
+
fs10.mkdirSync(path11.dirname(statePath), { recursive: true });
|
|
32146
32401
|
const tempPath = `${statePath}.${process.pid}.${Date.now()}.tmp`;
|
|
32147
|
-
|
|
32402
|
+
fs10.writeFileSync(tempPath, `${JSON.stringify(state, null, 2)}
|
|
32148
32403
|
`, "utf8");
|
|
32149
|
-
|
|
32404
|
+
fs10.renameSync(tempPath, statePath);
|
|
32150
32405
|
}
|
|
32151
32406
|
function writeRuntimeLogFailureState(projectRoot, options) {
|
|
32152
32407
|
const nowIso = new Date(options.nowMs()).toISOString();
|
|
@@ -32178,13 +32433,13 @@ function isNonRetryableRuntimeLogError(error2) {
|
|
|
32178
32433
|
);
|
|
32179
32434
|
}
|
|
32180
32435
|
function getRuntimeLogDir(projectRoot) {
|
|
32181
|
-
return
|
|
32436
|
+
return path11.join(projectRoot, ".maker", "logs", "runtime");
|
|
32182
32437
|
}
|
|
32183
32438
|
function getRuntimeLogStatePath(projectRoot) {
|
|
32184
|
-
return
|
|
32439
|
+
return path11.join(getRuntimeLogDir(projectRoot), "state.json");
|
|
32185
32440
|
}
|
|
32186
32441
|
function getRuntimeLogPath(projectRoot) {
|
|
32187
|
-
return
|
|
32442
|
+
return path11.join(getRuntimeLogDir(projectRoot), MERGED_RUNTIME_LOG_FILE);
|
|
32188
32443
|
}
|
|
32189
32444
|
function resolveNextRuntimeLogCursor(result) {
|
|
32190
32445
|
const maxLogTime = result.logs.reduce((max, log) => {
|
|
@@ -32309,8 +32564,8 @@ function compactRuntimeLogEntry(entry) {
|
|
|
32309
32564
|
}
|
|
32310
32565
|
|
|
32311
32566
|
// src/maker/server/proxyAssets.ts
|
|
32312
|
-
import
|
|
32313
|
-
import
|
|
32567
|
+
import fs11 from "node:fs";
|
|
32568
|
+
import path12 from "node:path";
|
|
32314
32569
|
var IMAGE_ASSET_DIRS = ["assets/image"];
|
|
32315
32570
|
var VIDEO_ASSET_DIRS = ["assets/video"];
|
|
32316
32571
|
var AUDIO_ASSET_DIRS = ["assets/audio"];
|
|
@@ -32554,8 +32809,8 @@ async function materializeAsset(options) {
|
|
|
32554
32809
|
};
|
|
32555
32810
|
}
|
|
32556
32811
|
const bytes = Buffer.from(await response.arrayBuffer());
|
|
32557
|
-
|
|
32558
|
-
|
|
32812
|
+
fs11.mkdirSync(path12.dirname(absolutePath), { recursive: true });
|
|
32813
|
+
fs11.writeFileSync(absolutePath, bytes);
|
|
32559
32814
|
return { localPath: relativePath, absolutePath, download: { success: true } };
|
|
32560
32815
|
} catch (error2) {
|
|
32561
32816
|
return {
|
|
@@ -32569,12 +32824,12 @@ async function materializeAsset(options) {
|
|
|
32569
32824
|
function createUniqueAssetPath(options) {
|
|
32570
32825
|
const stem = `${sanitizeAssetBaseName(options.baseName)}_${formatAssetTimestamp(options.now)}`;
|
|
32571
32826
|
for (let index = 1; index <= 9999; index += 1) {
|
|
32572
|
-
const relativePath =
|
|
32827
|
+
const relativePath = path12.posix.join(
|
|
32573
32828
|
options.relativeDir,
|
|
32574
32829
|
`${stem}${index === 1 ? "" : `_${index}`}.${options.extension}`
|
|
32575
32830
|
);
|
|
32576
|
-
const absolutePath =
|
|
32577
|
-
if (!
|
|
32831
|
+
const absolutePath = path12.join(options.targetDir, ...relativePath.split("/"));
|
|
32832
|
+
if (!fs11.existsSync(absolutePath)) {
|
|
32578
32833
|
return { relativePath, absolutePath };
|
|
32579
32834
|
}
|
|
32580
32835
|
}
|
|
@@ -32657,7 +32912,7 @@ function findRegistryAssetByName(value, registry2, assetDirs) {
|
|
|
32657
32912
|
if (!isKnownAssetPath(localPath, assetDirs)) {
|
|
32658
32913
|
return false;
|
|
32659
32914
|
}
|
|
32660
|
-
const basename =
|
|
32915
|
+
const basename = path12.posix.basename(localPath);
|
|
32661
32916
|
const stem = basename.replace(/\.[^.]+$/, "");
|
|
32662
32917
|
return basename === value || stem === value || record2.name === value || record2.taskId === value;
|
|
32663
32918
|
});
|
|
@@ -32670,13 +32925,13 @@ function findRegistryAssetByName(value, registry2, assetDirs) {
|
|
|
32670
32925
|
}
|
|
32671
32926
|
function findLocalAssetByName(targetDir, value, assetDirs) {
|
|
32672
32927
|
var _a3;
|
|
32673
|
-
const hasExtension = Boolean(
|
|
32928
|
+
const hasExtension = Boolean(path12.extname(value));
|
|
32674
32929
|
const candidates = [];
|
|
32675
32930
|
for (const assetDir of assetDirs) {
|
|
32676
|
-
const absoluteDir =
|
|
32931
|
+
const absoluteDir = path12.join(targetDir, ...assetDir.split("/"));
|
|
32677
32932
|
let entries;
|
|
32678
32933
|
try {
|
|
32679
|
-
entries =
|
|
32934
|
+
entries = fs11.readdirSync(absoluteDir);
|
|
32680
32935
|
} catch {
|
|
32681
32936
|
continue;
|
|
32682
32937
|
}
|
|
@@ -32685,11 +32940,11 @@ function findLocalAssetByName(targetDir, value, assetDirs) {
|
|
|
32685
32940
|
if (hasExtension ? entry !== value : stem !== value && !stem.startsWith(`${value}_`)) {
|
|
32686
32941
|
continue;
|
|
32687
32942
|
}
|
|
32688
|
-
const absolutePath =
|
|
32943
|
+
const absolutePath = path12.join(absoluteDir, entry);
|
|
32689
32944
|
try {
|
|
32690
32945
|
candidates.push({
|
|
32691
|
-
localPath:
|
|
32692
|
-
mtimeMs:
|
|
32946
|
+
localPath: path12.posix.join(assetDir, entry),
|
|
32947
|
+
mtimeMs: fs11.statSync(absolutePath).mtimeMs
|
|
32693
32948
|
});
|
|
32694
32949
|
} catch {
|
|
32695
32950
|
}
|
|
@@ -32699,7 +32954,7 @@ function findLocalAssetByName(targetDir, value, assetDirs) {
|
|
|
32699
32954
|
return (_a3 = candidates[0]) == null ? void 0 : _a3.localPath;
|
|
32700
32955
|
}
|
|
32701
32956
|
function isKnownAssetPath(relativePath, assetDirs) {
|
|
32702
|
-
if (relativePath.startsWith("../") ||
|
|
32957
|
+
if (relativePath.startsWith("../") || path12.isAbsolute(relativePath)) {
|
|
32703
32958
|
return false;
|
|
32704
32959
|
}
|
|
32705
32960
|
return assetDirs.some(
|
|
@@ -32713,31 +32968,31 @@ function upsertGeneratedAssetRecord(targetDir, localPath, record2) {
|
|
|
32713
32968
|
const registry2 = readGeneratedAssetRegistry(targetDir);
|
|
32714
32969
|
registry2[localPath] = record2;
|
|
32715
32970
|
const registryPath = getGeneratedAssetRegistryPath(targetDir);
|
|
32716
|
-
|
|
32717
|
-
|
|
32971
|
+
fs11.mkdirSync(path12.dirname(registryPath), { recursive: true });
|
|
32972
|
+
fs11.writeFileSync(registryPath, `${JSON.stringify(registry2, null, 2)}
|
|
32718
32973
|
`, "utf8");
|
|
32719
32974
|
}
|
|
32720
32975
|
function readGeneratedAssetRegistry(targetDir) {
|
|
32721
32976
|
const registryPath = getGeneratedAssetRegistryPath(targetDir);
|
|
32722
|
-
if (!
|
|
32977
|
+
if (!fs11.existsSync(registryPath)) {
|
|
32723
32978
|
return {};
|
|
32724
32979
|
}
|
|
32725
32980
|
try {
|
|
32726
|
-
const parsed = JSON.parse(
|
|
32981
|
+
const parsed = JSON.parse(fs11.readFileSync(registryPath, "utf8"));
|
|
32727
32982
|
return isRecord(parsed) ? parsed : {};
|
|
32728
32983
|
} catch {
|
|
32729
32984
|
return {};
|
|
32730
32985
|
}
|
|
32731
32986
|
}
|
|
32732
32987
|
function getGeneratedAssetRegistryPath(targetDir) {
|
|
32733
|
-
return
|
|
32988
|
+
return path12.join(targetDir, ".maker", "assets", "generated-assets.json");
|
|
32734
32989
|
}
|
|
32735
32990
|
function normalizeAssetRegistryKey(targetDir, value) {
|
|
32736
32991
|
if (/^https?:\/\//i.test(value) || value.startsWith("data:")) {
|
|
32737
32992
|
return void 0;
|
|
32738
32993
|
}
|
|
32739
|
-
const relative =
|
|
32740
|
-
return relative.split(
|
|
32994
|
+
const relative = path12.isAbsolute(value) ? path12.relative(targetDir, value) : value;
|
|
32995
|
+
return relative.split(path12.sep).join("/");
|
|
32741
32996
|
}
|
|
32742
32997
|
function isRecord(value) {
|
|
32743
32998
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -32766,7 +33021,7 @@ function extensionFromUrl(url2) {
|
|
|
32766
33021
|
}
|
|
32767
33022
|
try {
|
|
32768
33023
|
const pathname = new URL(url2).pathname;
|
|
32769
|
-
const extension =
|
|
33024
|
+
const extension = path12.extname(pathname).replace(/^\./, "").toLowerCase();
|
|
32770
33025
|
return extension || void 0;
|
|
32771
33026
|
} catch {
|
|
32772
33027
|
return void 0;
|
|
@@ -32774,7 +33029,7 @@ function extensionFromUrl(url2) {
|
|
|
32774
33029
|
}
|
|
32775
33030
|
|
|
32776
33031
|
// src/maker/server/mcp.ts
|
|
32777
|
-
var VERSION = true ? "0.0.
|
|
33032
|
+
var VERSION = true ? "0.0.17-beta.2" : "dev";
|
|
32778
33033
|
var DEFAULT_BUILD_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
32779
33034
|
var DEFAULT_PROXY_RETRY_ATTEMPTS = 5;
|
|
32780
33035
|
var DEFAULT_PROXY_RETRY_DELAY_MS = 30 * 1e3;
|
|
@@ -32914,12 +33169,14 @@ async function listRemoteProxyTools(options) {
|
|
|
32914
33169
|
env: options.env,
|
|
32915
33170
|
exposedTools: MAKER_REMOTE_PROXY_EXPOSED_TOOL_NAMES
|
|
32916
33171
|
});
|
|
32917
|
-
const transport =
|
|
32918
|
-
|
|
32919
|
-
|
|
32920
|
-
|
|
32921
|
-
|
|
32922
|
-
|
|
33172
|
+
const transport = trackMakerChildTransport(
|
|
33173
|
+
new StdioClientTransport({
|
|
33174
|
+
command: proxy.command,
|
|
33175
|
+
args: proxy.args,
|
|
33176
|
+
env: mergeStringEnv(process.env, proxy.envVars),
|
|
33177
|
+
stderr: "pipe"
|
|
33178
|
+
})
|
|
33179
|
+
);
|
|
32923
33180
|
const client = new Client(
|
|
32924
33181
|
{
|
|
32925
33182
|
name: "taptap-maker-tool-list-forwarder",
|
|
@@ -32950,12 +33207,14 @@ async function callRemoteProxyTool(options) {
|
|
|
32950
33207
|
});
|
|
32951
33208
|
const result = await retryMakerProxyOperation(
|
|
32952
33209
|
async () => {
|
|
32953
|
-
const transport =
|
|
32954
|
-
|
|
32955
|
-
|
|
32956
|
-
|
|
32957
|
-
|
|
32958
|
-
|
|
33210
|
+
const transport = trackMakerChildTransport(
|
|
33211
|
+
new StdioClientTransport({
|
|
33212
|
+
command: proxy.command,
|
|
33213
|
+
args: proxy.args,
|
|
33214
|
+
env: mergeStringEnv(process.env, proxy.envVars),
|
|
33215
|
+
stderr: "pipe"
|
|
33216
|
+
})
|
|
33217
|
+
);
|
|
32959
33218
|
const client = new Client(
|
|
32960
33219
|
{
|
|
32961
33220
|
name: "taptap-maker-tool-call-forwarder",
|
|
@@ -33125,6 +33384,37 @@ async function startMakerMcpServer() {
|
|
|
33125
33384
|
});
|
|
33126
33385
|
const transport = new StdioServerTransport();
|
|
33127
33386
|
await server.connect(transport);
|
|
33387
|
+
installMakerServerExitHandlers();
|
|
33388
|
+
}
|
|
33389
|
+
var MAKER_SERVER_SHUTDOWN_TIMEOUT_MS = 3e3;
|
|
33390
|
+
function installMakerServerExitHandlers() {
|
|
33391
|
+
let exiting = false;
|
|
33392
|
+
const shutdown = async (source) => {
|
|
33393
|
+
if (exiting) {
|
|
33394
|
+
return;
|
|
33395
|
+
}
|
|
33396
|
+
exiting = true;
|
|
33397
|
+
logLifecycleEvent(source, "Maker MCP server is exiting; closing active child transports.");
|
|
33398
|
+
const timeout = new Promise((resolve) => {
|
|
33399
|
+
var _a3;
|
|
33400
|
+
const timer = setTimeout(resolve, MAKER_SERVER_SHUTDOWN_TIMEOUT_MS);
|
|
33401
|
+
(_a3 = timer.unref) == null ? void 0 : _a3.call(timer);
|
|
33402
|
+
});
|
|
33403
|
+
await Promise.race([closeTrackedMakerChildTransports(), timeout]);
|
|
33404
|
+
process.exit(0);
|
|
33405
|
+
};
|
|
33406
|
+
process.stdin.once("end", () => {
|
|
33407
|
+
void shutdown("maker-server-stdin-end");
|
|
33408
|
+
});
|
|
33409
|
+
process.stdin.once("close", () => {
|
|
33410
|
+
void shutdown("maker-server-stdin-close");
|
|
33411
|
+
});
|
|
33412
|
+
process.once("SIGINT", () => {
|
|
33413
|
+
void shutdown("maker-server-sigint");
|
|
33414
|
+
});
|
|
33415
|
+
process.once("SIGTERM", () => {
|
|
33416
|
+
void shutdown("maker-server-sigterm");
|
|
33417
|
+
});
|
|
33128
33418
|
}
|
|
33129
33419
|
async function formatStatus(options = {}) {
|
|
33130
33420
|
var _a3;
|
|
@@ -33132,7 +33422,7 @@ async function formatStatus(options = {}) {
|
|
|
33132
33422
|
const env = getMakerEnvironment(void 0, targetDir);
|
|
33133
33423
|
const identify = identifyMakerProject({ cwd: targetDir });
|
|
33134
33424
|
const mcpCwd = process.cwd();
|
|
33135
|
-
const mcpCwdIdentify =
|
|
33425
|
+
const mcpCwdIdentify = path13.resolve(mcpCwd) === path13.resolve(targetDir) ? identify : identifyMakerProject({ cwd: mcpCwd });
|
|
33136
33426
|
const gitDirectoryStatus = inspectMakerDirectoryGitStatus(targetDir);
|
|
33137
33427
|
const remoteSyncText = identify.projectRoot && gitDirectoryStatus.isUsableMakerGitRepo && !options.skipRemoteSync ? await formatMakerRemoteSyncStatusSafely(identify.projectRoot) : identify.projectRoot && gitDirectoryStatus.isUsableMakerGitRepo ? formatMakerRemoteSyncSkipped() : "";
|
|
33138
33428
|
const pat = loadPat();
|
|
@@ -33252,10 +33542,10 @@ function formatMakerToolRegistrationCwdStatus(options) {
|
|
|
33252
33542
|
if (!options.projectRoot) {
|
|
33253
33543
|
return "";
|
|
33254
33544
|
}
|
|
33255
|
-
const mcpCwd =
|
|
33256
|
-
const targetDir =
|
|
33257
|
-
const projectRoot =
|
|
33258
|
-
const mcpProjectRoot = options.mcpProjectRoot ?
|
|
33545
|
+
const mcpCwd = path13.resolve(options.mcpCwd);
|
|
33546
|
+
const targetDir = path13.resolve(options.targetDir);
|
|
33547
|
+
const projectRoot = path13.resolve(options.projectRoot);
|
|
33548
|
+
const mcpProjectRoot = options.mcpProjectRoot ? path13.resolve(options.mcpProjectRoot) : void 0;
|
|
33259
33549
|
if (mcpProjectRoot === projectRoot) {
|
|
33260
33550
|
return "";
|
|
33261
33551
|
}
|
|
@@ -33417,7 +33707,7 @@ function formatAiDialogueDirectoryHint(targetDir) {
|
|
|
33417
33707
|
}
|
|
33418
33708
|
function resolveMakerToolTargetDir(targetDir) {
|
|
33419
33709
|
if (targetDir) {
|
|
33420
|
-
return
|
|
33710
|
+
return path13.resolve(targetDir);
|
|
33421
33711
|
}
|
|
33422
33712
|
return process.cwd();
|
|
33423
33713
|
}
|
|
@@ -33517,14 +33807,14 @@ function formatStatusProjectList(projects) {
|
|
|
33517
33807
|
].filter((line) => line !== void 0).join("\n");
|
|
33518
33808
|
}
|
|
33519
33809
|
function formatClonePartialStateLines(targetDir) {
|
|
33520
|
-
const resolvedTargetDir =
|
|
33810
|
+
const resolvedTargetDir = path13.resolve(targetDir);
|
|
33521
33811
|
const identify = identifyMakerProject({ cwd: resolvedTargetDir });
|
|
33522
33812
|
const gitStatus = inspectMakerDirectoryGitStatus(resolvedTargetDir);
|
|
33523
33813
|
const devKitStatus = inspectAiDevKit(resolvedTargetDir);
|
|
33524
|
-
const stagedDevKitGitignorePath =
|
|
33814
|
+
const stagedDevKitGitignorePath = path13.join(resolvedTargetDir, DEV_KIT_GITIGNORE_STAGING_FILE);
|
|
33525
33815
|
const projectBound = Boolean(identify.projectId);
|
|
33526
33816
|
const gitInitialized = Boolean(
|
|
33527
|
-
gitStatus.isOwnGitRoot ||
|
|
33817
|
+
gitStatus.isOwnGitRoot || fs12.existsSync(path13.join(resolvedTargetDir, ".git"))
|
|
33528
33818
|
);
|
|
33529
33819
|
const safeToRetry = !projectBound;
|
|
33530
33820
|
return [
|
|
@@ -33538,7 +33828,7 @@ function formatClonePartialStateLines(targetDir) {
|
|
|
33538
33828
|
identify.configPath ? `- config: ${identify.configPath}` : "",
|
|
33539
33829
|
`- ai_dev_kit_present: ${devKitStatus.ready ? "yes" : "no"}`,
|
|
33540
33830
|
`- ai_dev_kit_missing_entries: ${devKitStatus.missingEntries.join(", ") || "(none)"}`,
|
|
33541
|
-
`- staged_dev_kit_gitignore: ${
|
|
33831
|
+
`- staged_dev_kit_gitignore: ${fs12.existsSync(stagedDevKitGitignorePath) ? "yes" : "no"}`,
|
|
33542
33832
|
`- safe_to_retry: ${safeToRetry ? "yes" : "no"}`,
|
|
33543
33833
|
safeToRetry ? "- next_step: 可以直接重试 taptap-maker init;如果连续失败,建议换一个全新的独立目录重新 clone。" : "- next_step: 当前目录已经有 Maker 绑定信息;先运行 taptap-maker doctor 或读取 maker://status 确认状态。"
|
|
33544
33834
|
].filter(Boolean);
|
|
@@ -33611,7 +33901,7 @@ function resolveEmbeddedProxyCommand(options) {
|
|
|
33611
33901
|
}
|
|
33612
33902
|
return {
|
|
33613
33903
|
command: process.execPath,
|
|
33614
|
-
args: [
|
|
33904
|
+
args: [path13.resolve(makerEntry), "__maker-proxy"]
|
|
33615
33905
|
};
|
|
33616
33906
|
}
|
|
33617
33907
|
function createToolProgressReporter(progressToken, extra, operationName) {
|
|
@@ -33813,12 +34103,14 @@ async function runRemoteBuildCurrentDirectory(options, targetDir) {
|
|
|
33813
34103
|
const timeoutMs = options.timeoutMs || DEFAULT_BUILD_TIMEOUT_MS;
|
|
33814
34104
|
const result = await retryMakerProxyOperation(
|
|
33815
34105
|
async () => {
|
|
33816
|
-
const transport =
|
|
33817
|
-
|
|
33818
|
-
|
|
33819
|
-
|
|
33820
|
-
|
|
33821
|
-
|
|
34106
|
+
const transport = trackMakerChildTransport(
|
|
34107
|
+
new StdioClientTransport({
|
|
34108
|
+
command: proxy.command,
|
|
34109
|
+
args: proxy.args,
|
|
34110
|
+
env: mergeStringEnv(process.env, proxy.envVars),
|
|
34111
|
+
stderr: "pipe"
|
|
34112
|
+
})
|
|
34113
|
+
);
|
|
33822
34114
|
const client = new Client(
|
|
33823
34115
|
{
|
|
33824
34116
|
name: "taptap-maker-build-forwarder",
|
|
@@ -33950,18 +34242,18 @@ async function attachRuntimeLogWatch(buildResult, startWatch) {
|
|
|
33950
34242
|
}
|
|
33951
34243
|
}
|
|
33952
34244
|
async function startRuntimeLogWatch(buildResult) {
|
|
33953
|
-
const runtimeDir =
|
|
33954
|
-
|
|
33955
|
-
const stdoutLog =
|
|
33956
|
-
const stderrLog =
|
|
33957
|
-
const pidFile =
|
|
34245
|
+
const runtimeDir = path13.join(buildResult.projectRoot, ".maker", "logs", "runtime");
|
|
34246
|
+
fs12.mkdirSync(runtimeDir, { recursive: true });
|
|
34247
|
+
const stdoutLog = path13.join(runtimeDir, "watcher.out.log");
|
|
34248
|
+
const stderrLog = path13.join(runtimeDir, "watcher.err.log");
|
|
34249
|
+
const pidFile = path13.join(runtimeDir, "watcher.pid");
|
|
33958
34250
|
const previous = stopExistingRuntimeLogWatcher(pidFile);
|
|
33959
|
-
const outFd =
|
|
33960
|
-
const errFd =
|
|
34251
|
+
const outFd = fs12.openSync(stdoutLog, "a");
|
|
34252
|
+
const errFd = fs12.openSync(stderrLog, "a");
|
|
33961
34253
|
const command = formatRuntimeLogWatchCommand(buildResult);
|
|
33962
34254
|
if (previous.previousStopError) {
|
|
33963
|
-
|
|
33964
|
-
|
|
34255
|
+
fs12.closeSync(outFd);
|
|
34256
|
+
fs12.closeSync(errFd);
|
|
33965
34257
|
return {
|
|
33966
34258
|
started: false,
|
|
33967
34259
|
command: command.text,
|
|
@@ -34024,18 +34316,18 @@ async function startRuntimeLogWatch(buildResult) {
|
|
|
34024
34316
|
...previous
|
|
34025
34317
|
};
|
|
34026
34318
|
} finally {
|
|
34027
|
-
|
|
34028
|
-
|
|
34319
|
+
fs12.closeSync(outFd);
|
|
34320
|
+
fs12.closeSync(errFd);
|
|
34029
34321
|
}
|
|
34030
34322
|
}
|
|
34031
34323
|
function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
|
|
34032
|
-
if (!
|
|
34324
|
+
if (!fs12.existsSync(pidFile)) {
|
|
34033
34325
|
return {};
|
|
34034
34326
|
}
|
|
34035
34327
|
const pidState = readRuntimeLogWatcherPidState(pidFile);
|
|
34036
34328
|
const pid = pidState == null ? void 0 : pidState.pid;
|
|
34037
34329
|
if (!Number.isInteger(pid) || pid <= 0) {
|
|
34038
|
-
|
|
34330
|
+
fs12.rmSync(pidFile, { force: true });
|
|
34039
34331
|
return {};
|
|
34040
34332
|
}
|
|
34041
34333
|
try {
|
|
@@ -34043,7 +34335,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
|
|
|
34043
34335
|
const processCommand = (options.getProcessCommand || getProcessCommand)(pid);
|
|
34044
34336
|
const verifiedCommand = getVerifiedRuntimeLogWatcherCommand(processCommand, pidState);
|
|
34045
34337
|
if (!verifiedCommand) {
|
|
34046
|
-
|
|
34338
|
+
fs12.rmSync(pidFile, { force: true });
|
|
34047
34339
|
return {
|
|
34048
34340
|
previousPid: pid,
|
|
34049
34341
|
previousStopped: false,
|
|
@@ -34053,7 +34345,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
|
|
|
34053
34345
|
process.kill(pid, "SIGTERM");
|
|
34054
34346
|
const stopped = (options.waitForExit || waitForProcessExit)(pid, WATCHER_STOP_TIMEOUT_MS);
|
|
34055
34347
|
if (stopped) {
|
|
34056
|
-
|
|
34348
|
+
fs12.rmSync(pidFile, { force: true });
|
|
34057
34349
|
return { previousPid: pid, previousStopped: true };
|
|
34058
34350
|
}
|
|
34059
34351
|
return {
|
|
@@ -34062,7 +34354,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
|
|
|
34062
34354
|
previousStopError: `process ${pid} did not exit after SIGTERM within ${WATCHER_STOP_TIMEOUT_MS}ms`
|
|
34063
34355
|
};
|
|
34064
34356
|
} catch (error2) {
|
|
34065
|
-
|
|
34357
|
+
fs12.rmSync(pidFile, { force: true });
|
|
34066
34358
|
const code = error2 && typeof error2 === "object" && "code" in error2 ? String(error2.code) : "";
|
|
34067
34359
|
if (code === "ESRCH") {
|
|
34068
34360
|
return { previousPid: pid, previousStopped: false };
|
|
@@ -34075,7 +34367,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
|
|
|
34075
34367
|
}
|
|
34076
34368
|
}
|
|
34077
34369
|
function readRuntimeLogWatcherPidState(pidFile) {
|
|
34078
|
-
const raw =
|
|
34370
|
+
const raw = fs12.readFileSync(pidFile, "utf8").trim();
|
|
34079
34371
|
if (!raw) {
|
|
34080
34372
|
return null;
|
|
34081
34373
|
}
|
|
@@ -34091,7 +34383,7 @@ function readRuntimeLogWatcherPidState(pidFile) {
|
|
|
34091
34383
|
}
|
|
34092
34384
|
}
|
|
34093
34385
|
function writeRuntimeLogWatcherPidFile(pidFile, state) {
|
|
34094
|
-
|
|
34386
|
+
fs12.writeFileSync(pidFile, `${JSON.stringify(state, null, 2)}
|
|
34095
34387
|
`, "utf8");
|
|
34096
34388
|
}
|
|
34097
34389
|
function getProcessCommand(pid) {
|
|
@@ -34177,10 +34469,10 @@ function formatRuntimeLogWatchCommand(buildResult) {
|
|
|
34177
34469
|
};
|
|
34178
34470
|
}
|
|
34179
34471
|
function resolveMakerCliEntry() {
|
|
34180
|
-
return process.argv[1] ||
|
|
34472
|
+
return process.argv[1] || path13.resolve(process.cwd(), "dist", "maker.js");
|
|
34181
34473
|
}
|
|
34182
34474
|
function getRuntimeLogFilePath(projectRoot) {
|
|
34183
|
-
return
|
|
34475
|
+
return path13.join(projectRoot, ".maker", "logs", "runtime", "runtime.log");
|
|
34184
34476
|
}
|
|
34185
34477
|
async function refreshMakerPreview(buildResult) {
|
|
34186
34478
|
const makerEnv = buildResult.env === "rnd" || buildResult.env === "production" ? buildResult.env : void 0;
|
|
@@ -34231,12 +34523,14 @@ async function refreshMakerPreview(buildResult) {
|
|
|
34231
34523
|
}
|
|
34232
34524
|
function createRemoteRuntimeLogClient(proxy, timeoutMs = 60 * 1e3, options = {}) {
|
|
34233
34525
|
let client;
|
|
34234
|
-
const createTransport = options.createTransport || (() =>
|
|
34235
|
-
|
|
34236
|
-
|
|
34237
|
-
|
|
34238
|
-
|
|
34239
|
-
|
|
34526
|
+
const createTransport = options.createTransport || (() => trackMakerChildTransport(
|
|
34527
|
+
new HiddenStdioClientTransport({
|
|
34528
|
+
command: proxy.command,
|
|
34529
|
+
args: proxy.args,
|
|
34530
|
+
env: mergeStringEnv(process.env, proxy.envVars),
|
|
34531
|
+
stderr: "pipe"
|
|
34532
|
+
})
|
|
34533
|
+
));
|
|
34240
34534
|
const createClient = options.createClient || (() => new Client(
|
|
34241
34535
|
{
|
|
34242
34536
|
name: "taptap-maker-runtime-log-forwarder",
|
|
@@ -34311,7 +34605,7 @@ function createBuildArgs(projectRoot, options) {
|
|
|
34311
34605
|
if (options.scriptsPath) {
|
|
34312
34606
|
buildArgs.scriptsPath = options.scriptsPath;
|
|
34313
34607
|
}
|
|
34314
|
-
if (!options.entry && !options.scriptsPath && !options.entryClient && !options.entryServer && !options.multiplayer &&
|
|
34608
|
+
if (!options.entry && !options.scriptsPath && !options.entryClient && !options.entryServer && !options.multiplayer && fs12.existsSync(path13.join(projectRoot, "scripts", "main.lua"))) {
|
|
34315
34609
|
buildArgs.entry = "main.lua";
|
|
34316
34610
|
buildArgs.scriptsPath = "scripts";
|
|
34317
34611
|
}
|
|
@@ -34323,7 +34617,7 @@ function createBuildArgs(projectRoot, options) {
|
|
|
34323
34617
|
}
|
|
34324
34618
|
if (options.multiplayer) {
|
|
34325
34619
|
buildArgs.multiplayer = options.multiplayer;
|
|
34326
|
-
} else if (!
|
|
34620
|
+
} else if (!fs12.existsSync(path13.join(projectRoot, ".project", "settings.json"))) {
|
|
34327
34621
|
buildArgs.multiplayer = { enabled: false };
|
|
34328
34622
|
}
|
|
34329
34623
|
return buildArgs;
|
|
@@ -34498,11 +34792,11 @@ function formatRuntimeLogWatchNextActionLines(result) {
|
|
|
34498
34792
|
((_a3 = result.runtimeLogWatch) == null ? void 0 : _a3.pid) ? `- watch_pid: ${result.runtimeLogWatch.pid}` : "",
|
|
34499
34793
|
`- watch_command: ${command}`,
|
|
34500
34794
|
((_b = result.runtimeLogWatch) == null ? void 0 : _b.command) ? `- actual_watch_command: ${result.runtimeLogWatch.command}` : "",
|
|
34501
|
-
`- local_file: ${
|
|
34795
|
+
`- local_file: ${path13.join(result.projectRoot, ".maker", "logs", "runtime", "runtime.log")}`,
|
|
34502
34796
|
((_c = result.runtimeLogWatch) == null ? void 0 : _c.stdoutLog) ? `- watcher_stdout: ${result.runtimeLogWatch.stdoutLog}` : "",
|
|
34503
34797
|
((_d = result.runtimeLogWatch) == null ? void 0 : _d.stderrLog) ? `- watcher_stderr: ${result.runtimeLogWatch.stderrLog}` : "",
|
|
34504
34798
|
((_e = result.runtimeLogWatch) == null ? void 0 : _e.pidFile) ? `- watcher_pid_file: ${result.runtimeLogWatch.pidFile}` : "",
|
|
34505
|
-
`- state_file: ${
|
|
34799
|
+
`- state_file: ${path13.join(result.projectRoot, ".maker", "logs", "runtime", "state.json")}`,
|
|
34506
34800
|
((_f = result.runtimeLogWatch) == null ? void 0 : _f.previousPid) ? `- previous_watch_pid: ${result.runtimeLogWatch.previousPid}` : "",
|
|
34507
34801
|
((_g = result.runtimeLogWatch) == null ? void 0 : _g.previousStopped) !== void 0 ? `- previous_watch_stopped: ${result.runtimeLogWatch.previousStopped ? "yes" : "no"}` : "",
|
|
34508
34802
|
((_h = result.runtimeLogWatch) == null ? void 0 : _h.previousStopError) ? `- previous_watch_stop_error: ${result.runtimeLogWatch.previousStopError}` : "",
|
|
@@ -34619,9 +34913,9 @@ function indent(value) {
|
|
|
34619
34913
|
// src/maker/cli/commands.ts
|
|
34620
34914
|
import { spawnSync as spawnSync8 } from "node:child_process";
|
|
34621
34915
|
import crypto2 from "node:crypto";
|
|
34622
|
-
import
|
|
34916
|
+
import fs13 from "node:fs";
|
|
34623
34917
|
import os4 from "node:os";
|
|
34624
|
-
import
|
|
34918
|
+
import path14 from "node:path";
|
|
34625
34919
|
import readline from "node:readline/promises";
|
|
34626
34920
|
import { stdin as input, stdout as output } from "node:process";
|
|
34627
34921
|
|
|
@@ -34888,7 +35182,7 @@ function toOptionKey(value) {
|
|
|
34888
35182
|
}
|
|
34889
35183
|
async function runInit(parsed, ctx) {
|
|
34890
35184
|
rejectPackageOption(parsed);
|
|
34891
|
-
const targetDir =
|
|
35185
|
+
const targetDir = path14.resolve(stringOption(parsed, "target_dir") || process.cwd());
|
|
34892
35186
|
const env = makerEnvOption(parsed);
|
|
34893
35187
|
const skipConfirm = booleanOption(parsed, "skip_confirm");
|
|
34894
35188
|
const skipMcpInstall = booleanOption(parsed, "skip_mcp_install");
|
|
@@ -34981,7 +35275,7 @@ async function runInit(parsed, ctx) {
|
|
|
34981
35275
|
}
|
|
34982
35276
|
async function runDoctor(parsed, ctx) {
|
|
34983
35277
|
var _a3, _b;
|
|
34984
|
-
const targetDir =
|
|
35278
|
+
const targetDir = path14.resolve(stringOption(parsed, "target_dir") || process.cwd());
|
|
34985
35279
|
const env = makerEnvOption(parsed);
|
|
34986
35280
|
const git = checkGitEnvironment();
|
|
34987
35281
|
const python = checkMakerPythonEnvironment();
|
|
@@ -34993,6 +35287,10 @@ async function runDoctor(parsed, ctx) {
|
|
|
34993
35287
|
const projectRoot = identify.projectRoot || targetDir;
|
|
34994
35288
|
const devKit = inspectAiDevKit(projectRoot);
|
|
34995
35289
|
const devKitUpdate = await checkAiDevKitUpdate(projectRoot, { environment: env });
|
|
35290
|
+
const orphanProcessCheck = inspectMakerOrphanProcesses();
|
|
35291
|
+
const mcpToolsAvailability = inspectMakerMcpToolsAvailability({
|
|
35292
|
+
makerProjectDir: identify.projectRoot
|
|
35293
|
+
});
|
|
34996
35294
|
if (ctx.json) {
|
|
34997
35295
|
writeJson({
|
|
34998
35296
|
env,
|
|
@@ -35005,7 +35303,9 @@ async function runDoctor(parsed, ctx) {
|
|
|
35005
35303
|
lua_lsp: luaLsp,
|
|
35006
35304
|
project: identify,
|
|
35007
35305
|
dev_kit: devKit,
|
|
35008
|
-
dev_kit_update: devKitUpdate
|
|
35306
|
+
dev_kit_update: devKitUpdate,
|
|
35307
|
+
mcp_tools_availability: mcpToolsAvailability,
|
|
35308
|
+
orphan_process_check: orphanProcessCheck
|
|
35009
35309
|
});
|
|
35010
35310
|
return;
|
|
35011
35311
|
}
|
|
@@ -35039,11 +35339,118 @@ async function runDoctor(parsed, ctx) {
|
|
|
35039
35339
|
`- update_available: ${devKitUpdate.updateAvailable ? "yes" : "no"}`,
|
|
35040
35340
|
devKitUpdate.versionCheckError ? `- version_check: ${devKitUpdate.versionCheckError}` : "",
|
|
35041
35341
|
"",
|
|
35342
|
+
formatMakerMcpToolsAvailability(mcpToolsAvailability),
|
|
35343
|
+
"",
|
|
35344
|
+
formatMakerOrphanProcessStatus(orphanProcessCheck),
|
|
35345
|
+
"",
|
|
35042
35346
|
formatMakerSkillStatus({ projectRoot }),
|
|
35043
35347
|
""
|
|
35044
35348
|
].filter(Boolean).join("\n")
|
|
35045
35349
|
);
|
|
35046
35350
|
}
|
|
35351
|
+
function inspectMakerMcpToolsAvailability(options) {
|
|
35352
|
+
const aiPwd = path14.resolve(process.cwd());
|
|
35353
|
+
const aiPwdIdentify = identifyMakerProject({ cwd: aiPwd });
|
|
35354
|
+
const makerProjectDir = options.makerProjectDir ? path14.resolve(options.makerProjectDir) : void 0;
|
|
35355
|
+
if (!makerProjectDir) {
|
|
35356
|
+
return {
|
|
35357
|
+
tools_visibility: "refresh_ai_client_if_missing",
|
|
35358
|
+
pwd_alignment: "not_bound",
|
|
35359
|
+
ai_pwd: aiPwd,
|
|
35360
|
+
ai_pwd_project_dir: aiPwdIdentify.projectRoot
|
|
35361
|
+
};
|
|
35362
|
+
}
|
|
35363
|
+
return {
|
|
35364
|
+
tools_visibility: "refresh_ai_client_if_missing",
|
|
35365
|
+
pwd_alignment: aiPwdIdentify.projectRoot && samePath2(aiPwdIdentify.projectRoot, makerProjectDir) ? "same_project" : "cwd_mismatch",
|
|
35366
|
+
maker_project_dir: makerProjectDir,
|
|
35367
|
+
ai_pwd: aiPwd,
|
|
35368
|
+
ai_pwd_project_dir: aiPwdIdentify.projectRoot
|
|
35369
|
+
};
|
|
35370
|
+
}
|
|
35371
|
+
function formatMakerMcpToolsAvailability(availability) {
|
|
35372
|
+
const lines = [
|
|
35373
|
+
"Maker MCP tools availability",
|
|
35374
|
+
`- tools_visibility: ${availability.tools_visibility}`,
|
|
35375
|
+
"- hint: If Maker proxy tools are missing in this AI chat, this is common after install.",
|
|
35376
|
+
"- next_action: Restart the AI client or open a new AI conversation; /mcp clients can Reconnect taptap-maker.",
|
|
35377
|
+
`- pwd_alignment: ${availability.pwd_alignment}`
|
|
35378
|
+
];
|
|
35379
|
+
if (availability.pwd_alignment === "cwd_mismatch") {
|
|
35380
|
+
lines.push(`- maker_project_dir: ${availability.maker_project_dir}`);
|
|
35381
|
+
lines.push(`- ai_pwd: ${availability.ai_pwd}`);
|
|
35382
|
+
lines.push(`- ai_pwd_project_dir: ${availability.ai_pwd_project_dir || "(none)"}`);
|
|
35383
|
+
lines.push(
|
|
35384
|
+
"- impact: Maker proxy tools may not appear because tools/list uses the AI client pwd."
|
|
35385
|
+
);
|
|
35386
|
+
lines.push(
|
|
35387
|
+
"- next_action: Run the AI client from the Maker project directory, or reinstall MCP with --target-dir."
|
|
35388
|
+
);
|
|
35389
|
+
}
|
|
35390
|
+
return lines.join("\n");
|
|
35391
|
+
}
|
|
35392
|
+
function samePath2(left, right) {
|
|
35393
|
+
return normalizePathForCompare2(left) === normalizePathForCompare2(right);
|
|
35394
|
+
}
|
|
35395
|
+
function normalizePathForCompare2(value) {
|
|
35396
|
+
const resolved = path14.resolve(value);
|
|
35397
|
+
try {
|
|
35398
|
+
return fs13.realpathSync.native(resolved);
|
|
35399
|
+
} catch {
|
|
35400
|
+
return resolved;
|
|
35401
|
+
}
|
|
35402
|
+
}
|
|
35403
|
+
function inspectMakerOrphanProcesses() {
|
|
35404
|
+
if (process.platform === "win32") {
|
|
35405
|
+
return { status: "not_supported_on_windows", processes: [] };
|
|
35406
|
+
}
|
|
35407
|
+
const result = spawnSync8("ps", ["-axo", "pid,ppid,pcpu,etime,command"], {
|
|
35408
|
+
encoding: "utf8"
|
|
35409
|
+
});
|
|
35410
|
+
if (result.status !== 0 || typeof result.stdout !== "string") {
|
|
35411
|
+
return { status: "check_failed", processes: [] };
|
|
35412
|
+
}
|
|
35413
|
+
const processes = result.stdout.split(/\r?\n/).slice(1).map((line) => parseMakerProcessLine(line)).filter((processInfo) => Boolean(processInfo));
|
|
35414
|
+
return { status: "ok", processes };
|
|
35415
|
+
}
|
|
35416
|
+
function parseMakerProcessLine(line) {
|
|
35417
|
+
const match = line.trim().match(/^(\d+)\s+(\d+)\s+([0-9.]+)\s+(\S+)\s+(.+)$/);
|
|
35418
|
+
if (!match) {
|
|
35419
|
+
return null;
|
|
35420
|
+
}
|
|
35421
|
+
const [, pid, ppid, cpu, elapsed, command] = match;
|
|
35422
|
+
if (ppid !== "1") {
|
|
35423
|
+
return null;
|
|
35424
|
+
}
|
|
35425
|
+
if (/\blogs\b.*\bwatch\b/.test(command)) {
|
|
35426
|
+
return null;
|
|
35427
|
+
}
|
|
35428
|
+
if (!/\bmaker\.js\b/.test(command) && !/\btaptap-maker\b/.test(command)) {
|
|
35429
|
+
return null;
|
|
35430
|
+
}
|
|
35431
|
+
return { pid, ppid, cpu, elapsed, command };
|
|
35432
|
+
}
|
|
35433
|
+
function formatMakerOrphanProcessStatus(check2) {
|
|
35434
|
+
const lines = ["Maker orphan process check"];
|
|
35435
|
+
if (check2.status === "not_supported_on_windows") {
|
|
35436
|
+
return [...lines, "- orphan_processes: not_supported_on_windows"].join("\n");
|
|
35437
|
+
}
|
|
35438
|
+
if (check2.status === "check_failed") {
|
|
35439
|
+
return [...lines, "- orphan_processes: check_failed"].join("\n");
|
|
35440
|
+
}
|
|
35441
|
+
if (check2.processes.length === 0) {
|
|
35442
|
+
return [...lines, "- orphan_processes: none"].join("\n");
|
|
35443
|
+
}
|
|
35444
|
+
for (const processInfo of check2.processes) {
|
|
35445
|
+
lines.push(
|
|
35446
|
+
`- pid: ${processInfo.pid} ppid: ${processInfo.ppid} cpu: ${processInfo.cpu} elapsed: ${processInfo.elapsed}`
|
|
35447
|
+
);
|
|
35448
|
+
lines.push(` command: ${processInfo.command}`);
|
|
35449
|
+
}
|
|
35450
|
+
lines.push("- action: safe_to_kill_orphan_maker_processes");
|
|
35451
|
+
lines.push("- note: these PPID=1 Maker processes are detached from the AI client.");
|
|
35452
|
+
return lines.join("\n");
|
|
35453
|
+
}
|
|
35047
35454
|
function ensureInitPythonReady(ctx, targetDir, env) {
|
|
35048
35455
|
const initial = checkMakerPythonEnvironment();
|
|
35049
35456
|
if (initial.ready) {
|
|
@@ -35306,7 +35713,7 @@ async function runPatSet(parsed, ctx) {
|
|
|
35306
35713
|
}
|
|
35307
35714
|
async function resolvePatSet(parsed, ctx) {
|
|
35308
35715
|
if (booleanOption(parsed, "pat_stdin") || booleanOption(parsed, "pat_from_stdin")) {
|
|
35309
|
-
const pat =
|
|
35716
|
+
const pat = fs13.readFileSync(0, "utf8").trim();
|
|
35310
35717
|
if (!pat) {
|
|
35311
35718
|
throw new Error("No PAT found on stdin.");
|
|
35312
35719
|
}
|
|
@@ -35336,7 +35743,7 @@ async function runMcpInstall(parsed, ctx) {
|
|
|
35336
35743
|
env: makerEnvOption(parsed),
|
|
35337
35744
|
pkg: MAKER_NPM_PACKAGE,
|
|
35338
35745
|
mcpName: stringOption(parsed, "name") || DEFAULT_MCP_NAME,
|
|
35339
|
-
cwd: explicitTargetDir ?
|
|
35746
|
+
cwd: explicitTargetDir ? path14.resolve(explicitTargetDir) : void 0
|
|
35340
35747
|
});
|
|
35341
35748
|
if (ctx.json) {
|
|
35342
35749
|
writeJson(results);
|
|
@@ -35439,7 +35846,7 @@ function getMcpVerifyNextSteps(mode, commandText) {
|
|
|
35439
35846
|
];
|
|
35440
35847
|
}
|
|
35441
35848
|
async function runDevKitUpdate(parsed, ctx) {
|
|
35442
|
-
const targetDir =
|
|
35849
|
+
const targetDir = path14.resolve(stringOption(parsed, "target_dir") || process.cwd());
|
|
35443
35850
|
const result = await installAiDevKit({
|
|
35444
35851
|
targetDir,
|
|
35445
35852
|
preserveExisting: false,
|
|
@@ -35451,7 +35858,7 @@ async function runDevKitUpdate(parsed, ctx) {
|
|
|
35451
35858
|
emitDevKitSkillInstallerFailure(ctx, result.skillInstaller, "AI skills install failed");
|
|
35452
35859
|
}
|
|
35453
35860
|
async function runLogsWatch(parsed, ctx) {
|
|
35454
|
-
const targetDir =
|
|
35861
|
+
const targetDir = path14.resolve(stringOption(parsed, "target_dir") || process.cwd());
|
|
35455
35862
|
const intervalMs = parseDurationMs(stringOption(parsed, "interval") || "5s");
|
|
35456
35863
|
const timeoutMs = numberOption(parsed, "timeout_ms") ?? 60 * 1e3;
|
|
35457
35864
|
const maxPolls = numberOption(parsed, "max_polls");
|
|
@@ -35461,9 +35868,9 @@ async function runLogsWatch(parsed, ctx) {
|
|
|
35461
35868
|
serverUrl: stringOption(parsed, "server_url"),
|
|
35462
35869
|
env: makerEnvOption(parsed)
|
|
35463
35870
|
});
|
|
35464
|
-
const runtimeDir =
|
|
35465
|
-
const runtimeLog =
|
|
35466
|
-
const pidFile =
|
|
35871
|
+
const runtimeDir = path14.join(proxy.projectRoot, ".maker", "logs", "runtime");
|
|
35872
|
+
const runtimeLog = path14.join(runtimeDir, "runtime.log");
|
|
35873
|
+
const pidFile = path14.join(runtimeDir, "watcher.pid");
|
|
35467
35874
|
const replacedWatcher = registerRuntimeLogWatcherProcess(pidFile);
|
|
35468
35875
|
const runtimeLogClient = createRemoteRuntimeLogClient(proxy, timeoutMs);
|
|
35469
35876
|
emit(ctx, "logs_watch_start", "Maker runtime log watcher started", {
|
|
@@ -35508,10 +35915,10 @@ async function runLogsWatch(parsed, ctx) {
|
|
|
35508
35915
|
}
|
|
35509
35916
|
}
|
|
35510
35917
|
function registerRuntimeLogWatcherProcess(pidFile) {
|
|
35511
|
-
|
|
35918
|
+
fs13.mkdirSync(path14.dirname(pidFile), { recursive: true });
|
|
35512
35919
|
const existingPid = readPidFile(pidFile);
|
|
35513
35920
|
const previous = existingPid && existingPid !== process.pid ? stopExistingRuntimeLogWatcher(pidFile) : {};
|
|
35514
|
-
|
|
35921
|
+
fs13.writeFileSync(
|
|
35515
35922
|
pidFile,
|
|
35516
35923
|
`${JSON.stringify(
|
|
35517
35924
|
{
|
|
@@ -35529,10 +35936,10 @@ function registerRuntimeLogWatcherProcess(pidFile) {
|
|
|
35529
35936
|
return previous;
|
|
35530
35937
|
}
|
|
35531
35938
|
function readPidFile(pidFile) {
|
|
35532
|
-
if (!
|
|
35939
|
+
if (!fs13.existsSync(pidFile)) {
|
|
35533
35940
|
return void 0;
|
|
35534
35941
|
}
|
|
35535
|
-
const raw =
|
|
35942
|
+
const raw = fs13.readFileSync(pidFile, "utf8").trim();
|
|
35536
35943
|
let pid = Number(raw);
|
|
35537
35944
|
if (!Number.isInteger(pid) || pid <= 0) {
|
|
35538
35945
|
try {
|
|
@@ -35552,7 +35959,7 @@ function installRuntimeLogWatcherPidCleanup(pidFile) {
|
|
|
35552
35959
|
}
|
|
35553
35960
|
cleaned = true;
|
|
35554
35961
|
if (readPidFile(pidFile) === process.pid) {
|
|
35555
|
-
|
|
35962
|
+
fs13.rmSync(pidFile, { force: true });
|
|
35556
35963
|
}
|
|
35557
35964
|
};
|
|
35558
35965
|
process.once("exit", cleanup);
|
|
@@ -35661,7 +36068,7 @@ async function prepareDevKit(targetDir, ctx, options = {}) {
|
|
|
35661
36068
|
onStart: (event) => emitSkillInstallerStart(ctx, event)
|
|
35662
36069
|
});
|
|
35663
36070
|
writeDevKitStagedGitignore(
|
|
35664
|
-
|
|
36071
|
+
path14.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE),
|
|
35665
36072
|
listPresentDevKitManagedEntries(targetDir)
|
|
35666
36073
|
);
|
|
35667
36074
|
if (options.finalizeGitignore) {
|
|
@@ -35678,7 +36085,7 @@ async function prepareDevKit(targetDir, ctx, options = {}) {
|
|
|
35678
36085
|
);
|
|
35679
36086
|
} catch (error2) {
|
|
35680
36087
|
writeDevKitStagedGitignore(
|
|
35681
|
-
|
|
36088
|
+
path14.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE),
|
|
35682
36089
|
listPresentDevKitManagedEntries(targetDir)
|
|
35683
36090
|
);
|
|
35684
36091
|
if (options.finalizeGitignore) {
|
|
@@ -35766,7 +36173,7 @@ function installMcpConfig(ide, options) {
|
|
|
35766
36173
|
}
|
|
35767
36174
|
function installMcpConfigUnsafe(ide, options) {
|
|
35768
36175
|
if (ide === "codex") {
|
|
35769
|
-
const configPath =
|
|
36176
|
+
const configPath = path14.join(os4.homedir(), ".codex", "config.toml");
|
|
35770
36177
|
mergeCodexMcpConfig(configPath, options);
|
|
35771
36178
|
return {
|
|
35772
36179
|
ide,
|
|
@@ -35776,7 +36183,7 @@ function installMcpConfigUnsafe(ide, options) {
|
|
|
35776
36183
|
};
|
|
35777
36184
|
}
|
|
35778
36185
|
if (ide === "cursor") {
|
|
35779
|
-
const configPath =
|
|
36186
|
+
const configPath = path14.join(os4.homedir(), ".cursor", "mcp.json");
|
|
35780
36187
|
mergeJsonMcpConfig(configPath, options);
|
|
35781
36188
|
return {
|
|
35782
36189
|
ide,
|
|
@@ -35792,7 +36199,7 @@ function installMcpConfigUnsafe(ide, options) {
|
|
|
35792
36199
|
return { ide, ok: true, message: "✓ Claude Code MCP config updated with claude mcp add" };
|
|
35793
36200
|
}
|
|
35794
36201
|
}
|
|
35795
|
-
const configPath =
|
|
36202
|
+
const configPath = path14.join(os4.homedir(), ".claude.json");
|
|
35796
36203
|
mergeJsonMcpConfig(configPath, options);
|
|
35797
36204
|
return {
|
|
35798
36205
|
ide,
|
|
@@ -35809,13 +36216,13 @@ function mergeJsonMcpConfig(configPath, options) {
|
|
|
35809
36216
|
const mcpServers = asObject(existing.mcpServers);
|
|
35810
36217
|
mcpServers[options.mcpName] = createJsonMcpServerConfig(options);
|
|
35811
36218
|
existing.mcpServers = mcpServers;
|
|
35812
|
-
|
|
35813
|
-
|
|
36219
|
+
fs13.mkdirSync(path14.dirname(configPath), { recursive: true });
|
|
36220
|
+
fs13.writeFileSync(configPath, `${JSON.stringify(existing, null, 2)}
|
|
35814
36221
|
`, "utf8");
|
|
35815
36222
|
}
|
|
35816
36223
|
function mergeCodexMcpConfig(configPath, options) {
|
|
35817
36224
|
const backupPath = backupIfExists(configPath);
|
|
35818
|
-
const existing =
|
|
36225
|
+
const existing = fs13.existsSync(configPath) ? fs13.readFileSync(configPath, "utf8") : "";
|
|
35819
36226
|
const sectionPattern = createCodexMcpSectionPattern(options.mcpName);
|
|
35820
36227
|
const withoutOld = existing.replace(sectionPattern, "").trimEnd();
|
|
35821
36228
|
const launch = getNpxCliCommand(options.pkg);
|
|
@@ -35829,9 +36236,9 @@ function mergeCodexMcpConfig(configPath, options) {
|
|
|
35829
36236
|
`TAPTAP_MCP_ENV = "${options.env}"`,
|
|
35830
36237
|
""
|
|
35831
36238
|
].join("\n");
|
|
35832
|
-
|
|
35833
|
-
|
|
35834
|
-
const updated =
|
|
36239
|
+
fs13.mkdirSync(path14.dirname(configPath), { recursive: true });
|
|
36240
|
+
fs13.writeFileSync(configPath, [withoutOld, section].filter(Boolean).join("\n\n"), "utf8");
|
|
36241
|
+
const updated = fs13.readFileSync(configPath, "utf8");
|
|
35835
36242
|
const duplicates = findCodexMcpTableDuplicates(updated, options.mcpName);
|
|
35836
36243
|
if (duplicates.length > 0) {
|
|
35837
36244
|
restoreBackup(configPath, backupPath);
|
|
@@ -35948,10 +36355,10 @@ function rejectPackageOption(parsed) {
|
|
|
35948
36355
|
}
|
|
35949
36356
|
}
|
|
35950
36357
|
function readJsonObject(filePath) {
|
|
35951
|
-
if (!
|
|
36358
|
+
if (!fs13.existsSync(filePath)) {
|
|
35952
36359
|
return {};
|
|
35953
36360
|
}
|
|
35954
|
-
return JSON.parse(
|
|
36361
|
+
return JSON.parse(fs13.readFileSync(filePath, "utf8"));
|
|
35955
36362
|
}
|
|
35956
36363
|
function asObject(value) {
|
|
35957
36364
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
@@ -35960,26 +36367,26 @@ function asObject(value) {
|
|
|
35960
36367
|
return {};
|
|
35961
36368
|
}
|
|
35962
36369
|
function backupIfExists(filePath) {
|
|
35963
|
-
if (!
|
|
36370
|
+
if (!fs13.existsSync(filePath)) {
|
|
35964
36371
|
return void 0;
|
|
35965
36372
|
}
|
|
35966
36373
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:]/g, "").replace(/\..+$/, "");
|
|
35967
36374
|
const backupPath = `${filePath}.bak.${stamp}`;
|
|
35968
|
-
|
|
36375
|
+
fs13.copyFileSync(filePath, backupPath);
|
|
35969
36376
|
return backupPath;
|
|
35970
36377
|
}
|
|
35971
36378
|
function restoreBackup(filePath, backupPath) {
|
|
35972
36379
|
if (backupPath) {
|
|
35973
|
-
|
|
36380
|
+
fs13.copyFileSync(backupPath, filePath);
|
|
35974
36381
|
return;
|
|
35975
36382
|
}
|
|
35976
|
-
|
|
36383
|
+
fs13.rmSync(filePath, { force: true });
|
|
35977
36384
|
}
|
|
35978
36385
|
function saveInitState(targetDir, state) {
|
|
35979
|
-
|
|
35980
|
-
const key = crypto2.createHash("sha256").update(
|
|
35981
|
-
|
|
35982
|
-
|
|
36386
|
+
fs13.mkdirSync(getMakerHome(), { recursive: true });
|
|
36387
|
+
const key = crypto2.createHash("sha256").update(path14.resolve(targetDir)).digest("hex").slice(0, 16);
|
|
36388
|
+
fs13.writeFileSync(
|
|
36389
|
+
path14.join(getMakerHome(), `init-state-${key}.json`),
|
|
35983
36390
|
`${JSON.stringify({ ...state, updated_at: (/* @__PURE__ */ new Date()).toISOString() }, null, 2)}
|
|
35984
36391
|
`,
|
|
35985
36392
|
"utf8"
|
|
@@ -36115,7 +36522,7 @@ function makerEnvOption(parsed) {
|
|
|
36115
36522
|
return env;
|
|
36116
36523
|
}
|
|
36117
36524
|
const targetDir = stringOption(parsed, "target_dir");
|
|
36118
|
-
return getMakerEnvironment(void 0, targetDir ?
|
|
36525
|
+
return getMakerEnvironment(void 0, targetDir ? path14.resolve(targetDir) : process.cwd());
|
|
36119
36526
|
}
|
|
36120
36527
|
function mcpVerifyModeOption(parsed) {
|
|
36121
36528
|
const mode = stringOption(parsed, "mode") || "npx";
|
|
@@ -36192,69 +36599,6 @@ function formatCliError(error2) {
|
|
|
36192
36599
|
return error2 instanceof Error ? error2.message : String(error2);
|
|
36193
36600
|
}
|
|
36194
36601
|
|
|
36195
|
-
// src/maker/crashLog.ts
|
|
36196
|
-
import fs13 from "node:fs";
|
|
36197
|
-
import path14 from "node:path";
|
|
36198
|
-
var DEFAULT_MAX_BYTES = 1024 * 1024;
|
|
36199
|
-
var DEFAULT_MAX_ENTRY_BYTES = 16 * 1024;
|
|
36200
|
-
function appendMakerCrashLog(source, error2, options = {}) {
|
|
36201
|
-
const makerHome = getMakerHome();
|
|
36202
|
-
fs13.mkdirSync(makerHome, { recursive: true });
|
|
36203
|
-
const logPath = path14.join(makerHome, "mcp-crash.log");
|
|
36204
|
-
const maxBytes = positiveInteger(options.maxBytes) || resolveEnvBytes("TAPTAP_MAKER_CRASH_LOG_MAX_BYTES", DEFAULT_MAX_BYTES);
|
|
36205
|
-
const maxEntryBytes = positiveInteger(options.maxEntryBytes) || resolveEnvBytes("TAPTAP_MAKER_CRASH_LOG_MAX_ENTRY_BYTES", DEFAULT_MAX_ENTRY_BYTES);
|
|
36206
|
-
const message = error2 instanceof Error ? error2.stack || error2.message : String(error2);
|
|
36207
|
-
const entry = truncateUtf8(
|
|
36208
|
-
[`[${(/* @__PURE__ */ new Date()).toISOString()}] ${source}`, message, ""].join("\n"),
|
|
36209
|
-
Math.min(maxEntryBytes, maxBytes)
|
|
36210
|
-
);
|
|
36211
|
-
const entryBytes = Buffer.byteLength(entry, "utf8");
|
|
36212
|
-
rotateIfNeeded(logPath, maxBytes, entryBytes);
|
|
36213
|
-
fs13.appendFileSync(logPath, entry, "utf8");
|
|
36214
|
-
}
|
|
36215
|
-
function rotateIfNeeded(logPath, maxBytes, incomingBytes) {
|
|
36216
|
-
if (!fs13.existsSync(logPath)) {
|
|
36217
|
-
return;
|
|
36218
|
-
}
|
|
36219
|
-
const currentBytes = fs13.statSync(logPath).size;
|
|
36220
|
-
if (currentBytes + incomingBytes <= maxBytes) {
|
|
36221
|
-
return;
|
|
36222
|
-
}
|
|
36223
|
-
const rotatedPath = `${logPath}.1`;
|
|
36224
|
-
writeFileTail(logPath, rotatedPath, maxBytes);
|
|
36225
|
-
fs13.writeFileSync(logPath, "", "utf8");
|
|
36226
|
-
}
|
|
36227
|
-
function writeFileTail(sourcePath, targetPath, maxBytes) {
|
|
36228
|
-
const size = fs13.statSync(sourcePath).size;
|
|
36229
|
-
const bytesToRead = Math.min(size, maxBytes);
|
|
36230
|
-
const start = Math.max(0, size - bytesToRead);
|
|
36231
|
-
const fd = fs13.openSync(sourcePath, "r");
|
|
36232
|
-
try {
|
|
36233
|
-
const buffer = Buffer.alloc(bytesToRead);
|
|
36234
|
-
fs13.readSync(fd, buffer, 0, bytesToRead, start);
|
|
36235
|
-
fs13.writeFileSync(targetPath, buffer);
|
|
36236
|
-
} finally {
|
|
36237
|
-
fs13.closeSync(fd);
|
|
36238
|
-
}
|
|
36239
|
-
}
|
|
36240
|
-
function truncateUtf8(value, maxBytes) {
|
|
36241
|
-
if (Buffer.byteLength(value, "utf8") <= maxBytes) {
|
|
36242
|
-
return value;
|
|
36243
|
-
}
|
|
36244
|
-
const suffix = `
|
|
36245
|
-
[truncated to ${maxBytes} bytes]
|
|
36246
|
-
`;
|
|
36247
|
-
const suffixBytes = Buffer.byteLength(suffix, "utf8");
|
|
36248
|
-
const prefixBytes = Math.max(0, maxBytes - suffixBytes);
|
|
36249
|
-
return `${Buffer.from(value, "utf8").subarray(0, prefixBytes).toString("utf8")}${suffix}`;
|
|
36250
|
-
}
|
|
36251
|
-
function resolveEnvBytes(key, fallback) {
|
|
36252
|
-
return positiveInteger(Number(process.env[key])) || fallback;
|
|
36253
|
-
}
|
|
36254
|
-
function positiveInteger(value) {
|
|
36255
|
-
return typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.floor(value) : void 0;
|
|
36256
|
-
}
|
|
36257
|
-
|
|
36258
36602
|
// src/mcp-proxy/config.ts
|
|
36259
36603
|
function readStdin() {
|
|
36260
36604
|
return new Promise((resolve, reject) => {
|
|
@@ -38184,6 +38528,8 @@ var LogWriter = class {
|
|
|
38184
38528
|
// src/mcp-proxy/proxy.ts
|
|
38185
38529
|
var VERSION2 = typeof __PROXY_VERSION__ !== "undefined" ? __PROXY_VERSION__ : "dev";
|
|
38186
38530
|
var LOCAL_PROXY_TAG = "local";
|
|
38531
|
+
var DEFAULT_RECONNECT_INTERVAL_MS = 5e3;
|
|
38532
|
+
var MAX_RECONNECT_INTERVAL_MS = 60 * 1e3;
|
|
38187
38533
|
var TapTapMCPProxy = class {
|
|
38188
38534
|
constructor(config2) {
|
|
38189
38535
|
this.connected = false;
|
|
@@ -38191,6 +38537,7 @@ var TapTapMCPProxy = class {
|
|
|
38191
38537
|
this.reconnectTimer = null;
|
|
38192
38538
|
this.healthCheckTimer = null;
|
|
38193
38539
|
this.pendingRequests = [];
|
|
38540
|
+
this.reconnectDelayMs = DEFAULT_RECONNECT_INTERVAL_MS;
|
|
38194
38541
|
// 会话验证相关
|
|
38195
38542
|
this.sessionValidated = false;
|
|
38196
38543
|
this.lastValidationTime = 0;
|
|
@@ -38199,15 +38546,15 @@ var TapTapMCPProxy = class {
|
|
|
38199
38546
|
this.config = config2;
|
|
38200
38547
|
this.cookieJar = new CookieJar(((_a3 = config2.options) == null ? void 0 : _a3.verbose) ?? false);
|
|
38201
38548
|
this.logWriter = this.createLogWriter();
|
|
38202
|
-
this.client =
|
|
38203
|
-
{ name: "taptap-proxy-client", version: "1.0.0" },
|
|
38204
|
-
{ capabilities: {} }
|
|
38205
|
-
);
|
|
38549
|
+
this.client = this.createClient();
|
|
38206
38550
|
this.server = new Server(
|
|
38207
38551
|
{ name: "taptap-proxy", version: "1.0.0" },
|
|
38208
38552
|
{ capabilities: { tools: {}, resources: {} } }
|
|
38209
38553
|
);
|
|
38210
38554
|
}
|
|
38555
|
+
createClient() {
|
|
38556
|
+
return new Client({ name: "taptap-proxy-client", version: "1.0.0" }, { capabilities: {} });
|
|
38557
|
+
}
|
|
38211
38558
|
/**
|
|
38212
38559
|
* 创建文件日志写入器
|
|
38213
38560
|
*/
|
|
@@ -38376,7 +38723,7 @@ var TapTapMCPProxy = class {
|
|
|
38376
38723
|
* 连接到 TapTap MCP Server
|
|
38377
38724
|
*/
|
|
38378
38725
|
async connectToServer() {
|
|
38379
|
-
var _a3, _b;
|
|
38726
|
+
var _a3, _b, _c;
|
|
38380
38727
|
this.log("info", `Connecting to ${this.config.server.url}...`);
|
|
38381
38728
|
try {
|
|
38382
38729
|
const cookieEnabled = ((_a3 = this.config.options) == null ? void 0 : _a3.enable_cookie_sticky) ?? true;
|
|
@@ -38397,6 +38744,7 @@ var TapTapMCPProxy = class {
|
|
|
38397
38744
|
this.connected = true;
|
|
38398
38745
|
this.sessionValidated = true;
|
|
38399
38746
|
this.lastValidationTime = Date.now();
|
|
38747
|
+
this.reconnectDelayMs = ((_c = this.config.options) == null ? void 0 : _c.reconnect_interval) ?? DEFAULT_RECONNECT_INTERVAL_MS;
|
|
38400
38748
|
this.log("info", "✅ Connected and session validated");
|
|
38401
38749
|
this.startHealthCheck();
|
|
38402
38750
|
if (this.reconnecting) {
|
|
@@ -38447,7 +38795,7 @@ var TapTapMCPProxy = class {
|
|
|
38447
38795
|
* 启动定期健康检查
|
|
38448
38796
|
*/
|
|
38449
38797
|
startHealthCheck() {
|
|
38450
|
-
var _a3;
|
|
38798
|
+
var _a3, _b, _c;
|
|
38451
38799
|
this.stopHealthCheck();
|
|
38452
38800
|
const interval = ((_a3 = this.config.options) == null ? void 0 : _a3.health_check_interval) ?? this.SESSION_VALIDATION_INTERVAL;
|
|
38453
38801
|
this.healthCheckTimer = setInterval(async () => {
|
|
@@ -38464,6 +38812,7 @@ var TapTapMCPProxy = class {
|
|
|
38464
38812
|
}
|
|
38465
38813
|
}
|
|
38466
38814
|
}, interval);
|
|
38815
|
+
(_c = (_b = this.healthCheckTimer).unref) == null ? void 0 : _c.call(_b);
|
|
38467
38816
|
this.log("debug", `Health check started (interval: ${interval}ms)`);
|
|
38468
38817
|
}
|
|
38469
38818
|
/**
|
|
@@ -38523,10 +38872,11 @@ var TapTapMCPProxy = class {
|
|
|
38523
38872
|
* 重连到 TapTap Server
|
|
38524
38873
|
*/
|
|
38525
38874
|
async reconnectToServer() {
|
|
38526
|
-
var _a3, _b
|
|
38875
|
+
var _a3, _b;
|
|
38527
38876
|
if (this.reconnecting) return;
|
|
38528
38877
|
this.reconnecting = true;
|
|
38529
38878
|
this.clearReconnectTimer();
|
|
38879
|
+
this.stopHealthCheck();
|
|
38530
38880
|
const cookieEnabled = ((_a3 = this.config.options) == null ? void 0 : _a3.enable_cookie_sticky) ?? true;
|
|
38531
38881
|
if (cookieEnabled && this.cookieJar.hasCookies) {
|
|
38532
38882
|
this.cookieJar.clear();
|
|
@@ -38535,14 +38885,12 @@ var TapTapMCPProxy = class {
|
|
|
38535
38885
|
}
|
|
38536
38886
|
}
|
|
38537
38887
|
try {
|
|
38538
|
-
this.client
|
|
38539
|
-
|
|
38540
|
-
{ capabilities: {} }
|
|
38541
|
-
);
|
|
38888
|
+
await this.closeClientSafely("reconnect-old-client");
|
|
38889
|
+
this.client = this.createClient();
|
|
38542
38890
|
await this.connectToServer();
|
|
38543
38891
|
this.log("info", "✅ Reconnected successfully");
|
|
38544
38892
|
} catch (error2) {
|
|
38545
|
-
const interval =
|
|
38893
|
+
const interval = this.reconnectDelayMs;
|
|
38546
38894
|
this.log("error", `❌ Reconnect failed: ${this.formatError(error2)}`);
|
|
38547
38895
|
this.log("info", `Will retry in ${interval / 1e3}s...`);
|
|
38548
38896
|
this.reconnecting = false;
|
|
@@ -38553,12 +38901,18 @@ var TapTapMCPProxy = class {
|
|
|
38553
38901
|
* 调度重连
|
|
38554
38902
|
*/
|
|
38555
38903
|
scheduleReconnect() {
|
|
38556
|
-
var _a3;
|
|
38904
|
+
var _a3, _b, _c;
|
|
38557
38905
|
this.clearReconnectTimer();
|
|
38558
|
-
const
|
|
38906
|
+
const configuredInterval = ((_a3 = this.config.options) == null ? void 0 : _a3.reconnect_interval) ?? DEFAULT_RECONNECT_INTERVAL_MS;
|
|
38907
|
+
const interval = this.reconnectDelayMs || configuredInterval;
|
|
38559
38908
|
this.reconnectTimer = setTimeout(() => {
|
|
38560
38909
|
this.reconnectToServer();
|
|
38561
38910
|
}, interval);
|
|
38911
|
+
(_c = (_b = this.reconnectTimer).unref) == null ? void 0 : _c.call(_b);
|
|
38912
|
+
this.reconnectDelayMs = Math.min(
|
|
38913
|
+
Math.max(interval * 2, configuredInterval),
|
|
38914
|
+
MAX_RECONNECT_INTERVAL_MS
|
|
38915
|
+
);
|
|
38562
38916
|
}
|
|
38563
38917
|
/**
|
|
38564
38918
|
* 清除重连定时器
|
|
@@ -38583,6 +38937,17 @@ var TapTapMCPProxy = class {
|
|
|
38583
38937
|
const req = this.pendingRequests.shift();
|
|
38584
38938
|
req.reject(timeout);
|
|
38585
38939
|
}
|
|
38940
|
+
void this.closeClientSafely("cleanup");
|
|
38941
|
+
}
|
|
38942
|
+
async closeClientSafely(source) {
|
|
38943
|
+
try {
|
|
38944
|
+
await this.client.close();
|
|
38945
|
+
} catch (error2) {
|
|
38946
|
+
this.log(
|
|
38947
|
+
"warning",
|
|
38948
|
+
`Failed to close proxy client during ${source}: ${this.formatError(error2)}`
|
|
38949
|
+
);
|
|
38950
|
+
}
|
|
38586
38951
|
}
|
|
38587
38952
|
/**
|
|
38588
38953
|
* 检测是否是需要重连的错误(网络错误或会话无效)
|
|
@@ -38838,12 +39203,15 @@ async function startEmbeddedProxy() {
|
|
|
38838
39203
|
const config2 = await loadConfig();
|
|
38839
39204
|
const proxy = new TapTapMCPProxy(config2);
|
|
38840
39205
|
await proxy.start();
|
|
38841
|
-
const cleanup = () => {
|
|
39206
|
+
const cleanup = (source = "proxy-signal") => {
|
|
39207
|
+
logLifecycleEvent(source, "Embedded Maker proxy received shutdown signal; exiting.");
|
|
38842
39208
|
proxy.cleanup();
|
|
38843
39209
|
process.exit(0);
|
|
38844
39210
|
};
|
|
38845
|
-
|
|
38846
|
-
|
|
39211
|
+
installProxyStdinExitHandler(proxy);
|
|
39212
|
+
installParentDeathWatchdog(proxy);
|
|
39213
|
+
process.on("SIGINT", () => cleanup("proxy-sigint"));
|
|
39214
|
+
process.on("SIGTERM", () => cleanup("proxy-sigterm"));
|
|
38847
39215
|
}
|
|
38848
39216
|
function printHelp2() {
|
|
38849
39217
|
process.stdout.write(
|
|
@@ -38883,24 +39251,65 @@ function printHelp2() {
|
|
|
38883
39251
|
}
|
|
38884
39252
|
main().catch((error2) => {
|
|
38885
39253
|
logCrash("main.catch", error2);
|
|
38886
|
-
|
|
39254
|
+
safeWriteStderr(`❌ ${formatCliError(error2)}
|
|
38887
39255
|
`);
|
|
38888
39256
|
process.exit(1);
|
|
38889
39257
|
});
|
|
38890
39258
|
function installCrashLogging() {
|
|
39259
|
+
installStdioErrorHandler(process.stdout, "stdout-error");
|
|
39260
|
+
installStdioErrorHandler(process.stderr, "stderr-error");
|
|
39261
|
+
let handlingFatalError = false;
|
|
38891
39262
|
process.on("uncaughtException", (error2) => {
|
|
38892
39263
|
logCrash("uncaughtException", error2);
|
|
38893
|
-
|
|
39264
|
+
if (isDisconnectedStdioError(error2)) {
|
|
39265
|
+
logLifecycleEvent("uncaughtException-stdio-closed", "Maker stdio disconnected; exiting.");
|
|
39266
|
+
process.exit(0);
|
|
39267
|
+
}
|
|
39268
|
+
if (handlingFatalError) {
|
|
39269
|
+
logCrash("uncaughtException-recursive", error2);
|
|
39270
|
+
process.exit(1);
|
|
39271
|
+
}
|
|
39272
|
+
handlingFatalError = true;
|
|
39273
|
+
safeWriteStderr(`❌ Uncaught Maker MCP error: ${error2.message}
|
|
38894
39274
|
`);
|
|
39275
|
+
handlingFatalError = false;
|
|
38895
39276
|
});
|
|
38896
39277
|
process.on("unhandledRejection", (reason) => {
|
|
38897
39278
|
logCrash("unhandledRejection", reason);
|
|
38898
|
-
|
|
39279
|
+
if (isDisconnectedStdioError(reason)) {
|
|
39280
|
+
logLifecycleEvent("unhandledRejection-stdio-closed", "Maker stdio disconnected; exiting.");
|
|
39281
|
+
process.exit(0);
|
|
39282
|
+
}
|
|
39283
|
+
if (handlingFatalError) {
|
|
39284
|
+
logCrash("unhandledRejection-recursive", reason);
|
|
39285
|
+
process.exit(1);
|
|
39286
|
+
}
|
|
39287
|
+
handlingFatalError = true;
|
|
39288
|
+
safeWriteStderr(
|
|
38899
39289
|
`❌ Unhandled Maker MCP rejection: ${reason instanceof Error ? reason.message : String(reason)}
|
|
38900
39290
|
`
|
|
38901
39291
|
);
|
|
39292
|
+
handlingFatalError = false;
|
|
38902
39293
|
});
|
|
38903
39294
|
}
|
|
39295
|
+
function installStdioErrorHandler(stream, source) {
|
|
39296
|
+
stream.on("error", (error2) => {
|
|
39297
|
+
logCrash(source, error2);
|
|
39298
|
+
if (isDisconnectedStdioError(error2)) {
|
|
39299
|
+
process.exit(0);
|
|
39300
|
+
}
|
|
39301
|
+
});
|
|
39302
|
+
}
|
|
39303
|
+
function safeWriteStderr(message) {
|
|
39304
|
+
try {
|
|
39305
|
+
process.stderr.write(message);
|
|
39306
|
+
} catch (error2) {
|
|
39307
|
+
logCrash("stderr-write-failed", error2);
|
|
39308
|
+
if (isDisconnectedStdioError(error2)) {
|
|
39309
|
+
process.exit(0);
|
|
39310
|
+
}
|
|
39311
|
+
}
|
|
39312
|
+
}
|
|
38904
39313
|
function logCrash(source, error2) {
|
|
38905
39314
|
try {
|
|
38906
39315
|
appendMakerCrashLog(source, error2);
|