@taptap/maker 0.0.13 → 0.0.15
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 +874 -241
- package/package.json +1 -1
- package/skills/taptap-maker-local/SKILL.md +33 -4
package/dist/maker.js
CHANGED
|
@@ -3233,8 +3233,8 @@ var require_utils = __commonJS({
|
|
|
3233
3233
|
}
|
|
3234
3234
|
return ind;
|
|
3235
3235
|
}
|
|
3236
|
-
function removeDotSegments(
|
|
3237
|
-
let input2 =
|
|
3236
|
+
function removeDotSegments(path16) {
|
|
3237
|
+
let input2 = path16;
|
|
3238
3238
|
const output2 = [];
|
|
3239
3239
|
let nextSlash = -1;
|
|
3240
3240
|
let len = 0;
|
|
@@ -3433,8 +3433,8 @@ var require_schemes = __commonJS({
|
|
|
3433
3433
|
wsComponent.secure = void 0;
|
|
3434
3434
|
}
|
|
3435
3435
|
if (wsComponent.resourceName) {
|
|
3436
|
-
const [
|
|
3437
|
-
wsComponent.path =
|
|
3436
|
+
const [path16, query] = wsComponent.resourceName.split("?");
|
|
3437
|
+
wsComponent.path = path16 && path16 !== "/" ? path16 : void 0;
|
|
3438
3438
|
wsComponent.query = query;
|
|
3439
3439
|
wsComponent.resourceName = void 0;
|
|
3440
3440
|
}
|
|
@@ -12491,12 +12491,12 @@ var require_dist = __commonJS({
|
|
|
12491
12491
|
throw new Error(`Unknown format "${name}"`);
|
|
12492
12492
|
return f;
|
|
12493
12493
|
};
|
|
12494
|
-
function addFormats(ajv, list,
|
|
12494
|
+
function addFormats(ajv, list, fs14, exportName) {
|
|
12495
12495
|
var _a3;
|
|
12496
12496
|
var _b;
|
|
12497
12497
|
(_a3 = (_b = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
12498
12498
|
for (const f of list)
|
|
12499
|
-
ajv.addFormat(f,
|
|
12499
|
+
ajv.addFormat(f, fs14[f]);
|
|
12500
12500
|
}
|
|
12501
12501
|
module.exports = exports = formatsPlugin;
|
|
12502
12502
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -12509,8 +12509,8 @@ var require_windows = __commonJS({
|
|
|
12509
12509
|
"node_modules/isexe/windows.js"(exports, module) {
|
|
12510
12510
|
module.exports = isexe;
|
|
12511
12511
|
isexe.sync = sync;
|
|
12512
|
-
var
|
|
12513
|
-
function checkPathExt(
|
|
12512
|
+
var fs14 = __require("fs");
|
|
12513
|
+
function checkPathExt(path16, options) {
|
|
12514
12514
|
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
12515
12515
|
if (!pathext) {
|
|
12516
12516
|
return true;
|
|
@@ -12521,25 +12521,25 @@ var require_windows = __commonJS({
|
|
|
12521
12521
|
}
|
|
12522
12522
|
for (var i = 0; i < pathext.length; i++) {
|
|
12523
12523
|
var p = pathext[i].toLowerCase();
|
|
12524
|
-
if (p &&
|
|
12524
|
+
if (p && path16.substr(-p.length).toLowerCase() === p) {
|
|
12525
12525
|
return true;
|
|
12526
12526
|
}
|
|
12527
12527
|
}
|
|
12528
12528
|
return false;
|
|
12529
12529
|
}
|
|
12530
|
-
function checkStat(stat,
|
|
12530
|
+
function checkStat(stat, path16, options) {
|
|
12531
12531
|
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
12532
12532
|
return false;
|
|
12533
12533
|
}
|
|
12534
|
-
return checkPathExt(
|
|
12534
|
+
return checkPathExt(path16, options);
|
|
12535
12535
|
}
|
|
12536
|
-
function isexe(
|
|
12537
|
-
|
|
12538
|
-
cb(er, er ? false : checkStat(stat,
|
|
12536
|
+
function isexe(path16, options, cb) {
|
|
12537
|
+
fs14.stat(path16, function(er, stat) {
|
|
12538
|
+
cb(er, er ? false : checkStat(stat, path16, options));
|
|
12539
12539
|
});
|
|
12540
12540
|
}
|
|
12541
|
-
function sync(
|
|
12542
|
-
return checkStat(
|
|
12541
|
+
function sync(path16, options) {
|
|
12542
|
+
return checkStat(fs14.statSync(path16), path16, options);
|
|
12543
12543
|
}
|
|
12544
12544
|
}
|
|
12545
12545
|
});
|
|
@@ -12549,14 +12549,14 @@ var require_mode = __commonJS({
|
|
|
12549
12549
|
"node_modules/isexe/mode.js"(exports, module) {
|
|
12550
12550
|
module.exports = isexe;
|
|
12551
12551
|
isexe.sync = sync;
|
|
12552
|
-
var
|
|
12553
|
-
function isexe(
|
|
12554
|
-
|
|
12552
|
+
var fs14 = __require("fs");
|
|
12553
|
+
function isexe(path16, options, cb) {
|
|
12554
|
+
fs14.stat(path16, function(er, stat) {
|
|
12555
12555
|
cb(er, er ? false : checkStat(stat, options));
|
|
12556
12556
|
});
|
|
12557
12557
|
}
|
|
12558
|
-
function sync(
|
|
12559
|
-
return checkStat(
|
|
12558
|
+
function sync(path16, options) {
|
|
12559
|
+
return checkStat(fs14.statSync(path16), options);
|
|
12560
12560
|
}
|
|
12561
12561
|
function checkStat(stat, options) {
|
|
12562
12562
|
return stat.isFile() && checkMode(stat, options);
|
|
@@ -12580,7 +12580,7 @@ var require_mode = __commonJS({
|
|
|
12580
12580
|
// node_modules/isexe/index.js
|
|
12581
12581
|
var require_isexe = __commonJS({
|
|
12582
12582
|
"node_modules/isexe/index.js"(exports, module) {
|
|
12583
|
-
var
|
|
12583
|
+
var fs14 = __require("fs");
|
|
12584
12584
|
var core;
|
|
12585
12585
|
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
12586
12586
|
core = require_windows();
|
|
@@ -12589,7 +12589,7 @@ var require_isexe = __commonJS({
|
|
|
12589
12589
|
}
|
|
12590
12590
|
module.exports = isexe;
|
|
12591
12591
|
isexe.sync = sync;
|
|
12592
|
-
function isexe(
|
|
12592
|
+
function isexe(path16, options, cb) {
|
|
12593
12593
|
if (typeof options === "function") {
|
|
12594
12594
|
cb = options;
|
|
12595
12595
|
options = {};
|
|
@@ -12599,7 +12599,7 @@ var require_isexe = __commonJS({
|
|
|
12599
12599
|
throw new TypeError("callback not provided");
|
|
12600
12600
|
}
|
|
12601
12601
|
return new Promise(function(resolve, reject) {
|
|
12602
|
-
isexe(
|
|
12602
|
+
isexe(path16, options || {}, function(er, is) {
|
|
12603
12603
|
if (er) {
|
|
12604
12604
|
reject(er);
|
|
12605
12605
|
} else {
|
|
@@ -12608,7 +12608,7 @@ var require_isexe = __commonJS({
|
|
|
12608
12608
|
});
|
|
12609
12609
|
});
|
|
12610
12610
|
}
|
|
12611
|
-
core(
|
|
12611
|
+
core(path16, options || {}, function(er, is) {
|
|
12612
12612
|
if (er) {
|
|
12613
12613
|
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
12614
12614
|
er = null;
|
|
@@ -12618,9 +12618,9 @@ var require_isexe = __commonJS({
|
|
|
12618
12618
|
cb(er, is);
|
|
12619
12619
|
});
|
|
12620
12620
|
}
|
|
12621
|
-
function sync(
|
|
12621
|
+
function sync(path16, options) {
|
|
12622
12622
|
try {
|
|
12623
|
-
return core.sync(
|
|
12623
|
+
return core.sync(path16, options || {});
|
|
12624
12624
|
} catch (er) {
|
|
12625
12625
|
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
12626
12626
|
return false;
|
|
@@ -12636,7 +12636,7 @@ var require_isexe = __commonJS({
|
|
|
12636
12636
|
var require_which = __commonJS({
|
|
12637
12637
|
"node_modules/which/which.js"(exports, module) {
|
|
12638
12638
|
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
12639
|
-
var
|
|
12639
|
+
var path16 = __require("path");
|
|
12640
12640
|
var COLON = isWindows ? ";" : ":";
|
|
12641
12641
|
var isexe = require_isexe();
|
|
12642
12642
|
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
@@ -12674,7 +12674,7 @@ var require_which = __commonJS({
|
|
|
12674
12674
|
return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
|
|
12675
12675
|
const ppRaw = pathEnv[i];
|
|
12676
12676
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
12677
|
-
const pCmd =
|
|
12677
|
+
const pCmd = path16.join(pathPart, cmd);
|
|
12678
12678
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
12679
12679
|
resolve(subStep(p, i, 0));
|
|
12680
12680
|
});
|
|
@@ -12701,7 +12701,7 @@ var require_which = __commonJS({
|
|
|
12701
12701
|
for (let i = 0; i < pathEnv.length; i++) {
|
|
12702
12702
|
const ppRaw = pathEnv[i];
|
|
12703
12703
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
12704
|
-
const pCmd =
|
|
12704
|
+
const pCmd = path16.join(pathPart, cmd);
|
|
12705
12705
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
12706
12706
|
for (let j = 0; j < pathExt.length; j++) {
|
|
12707
12707
|
const cur = p + pathExt[j];
|
|
@@ -12749,7 +12749,7 @@ var require_path_key = __commonJS({
|
|
|
12749
12749
|
var require_resolveCommand = __commonJS({
|
|
12750
12750
|
"node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module) {
|
|
12751
12751
|
"use strict";
|
|
12752
|
-
var
|
|
12752
|
+
var path16 = __require("path");
|
|
12753
12753
|
var which = require_which();
|
|
12754
12754
|
var getPathKey = require_path_key();
|
|
12755
12755
|
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
@@ -12767,7 +12767,7 @@ var require_resolveCommand = __commonJS({
|
|
|
12767
12767
|
try {
|
|
12768
12768
|
resolved = which.sync(parsed.command, {
|
|
12769
12769
|
path: env[getPathKey({ env })],
|
|
12770
|
-
pathExt: withoutPathExt ?
|
|
12770
|
+
pathExt: withoutPathExt ? path16.delimiter : void 0
|
|
12771
12771
|
});
|
|
12772
12772
|
} catch (e) {
|
|
12773
12773
|
} finally {
|
|
@@ -12776,7 +12776,7 @@ var require_resolveCommand = __commonJS({
|
|
|
12776
12776
|
}
|
|
12777
12777
|
}
|
|
12778
12778
|
if (resolved) {
|
|
12779
|
-
resolved =
|
|
12779
|
+
resolved = path16.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
12780
12780
|
}
|
|
12781
12781
|
return resolved;
|
|
12782
12782
|
}
|
|
@@ -12830,8 +12830,8 @@ var require_shebang_command = __commonJS({
|
|
|
12830
12830
|
if (!match) {
|
|
12831
12831
|
return null;
|
|
12832
12832
|
}
|
|
12833
|
-
const [
|
|
12834
|
-
const binary =
|
|
12833
|
+
const [path16, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
12834
|
+
const binary = path16.split("/").pop();
|
|
12835
12835
|
if (binary === "env") {
|
|
12836
12836
|
return argument;
|
|
12837
12837
|
}
|
|
@@ -12844,16 +12844,16 @@ var require_shebang_command = __commonJS({
|
|
|
12844
12844
|
var require_readShebang = __commonJS({
|
|
12845
12845
|
"node_modules/cross-spawn/lib/util/readShebang.js"(exports, module) {
|
|
12846
12846
|
"use strict";
|
|
12847
|
-
var
|
|
12847
|
+
var fs14 = __require("fs");
|
|
12848
12848
|
var shebangCommand = require_shebang_command();
|
|
12849
12849
|
function readShebang(command) {
|
|
12850
12850
|
const size = 150;
|
|
12851
12851
|
const buffer = Buffer.alloc(size);
|
|
12852
12852
|
let fd;
|
|
12853
12853
|
try {
|
|
12854
|
-
fd =
|
|
12855
|
-
|
|
12856
|
-
|
|
12854
|
+
fd = fs14.openSync(command, "r");
|
|
12855
|
+
fs14.readSync(fd, buffer, 0, size, 0);
|
|
12856
|
+
fs14.closeSync(fd);
|
|
12857
12857
|
} catch (e) {
|
|
12858
12858
|
}
|
|
12859
12859
|
return shebangCommand(buffer.toString());
|
|
@@ -12866,7 +12866,7 @@ var require_readShebang = __commonJS({
|
|
|
12866
12866
|
var require_parse = __commonJS({
|
|
12867
12867
|
"node_modules/cross-spawn/lib/parse.js"(exports, module) {
|
|
12868
12868
|
"use strict";
|
|
12869
|
-
var
|
|
12869
|
+
var path16 = __require("path");
|
|
12870
12870
|
var resolveCommand = require_resolveCommand();
|
|
12871
12871
|
var escape2 = require_escape();
|
|
12872
12872
|
var readShebang = require_readShebang();
|
|
@@ -12891,7 +12891,7 @@ var require_parse = __commonJS({
|
|
|
12891
12891
|
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
12892
12892
|
if (parsed.options.forceShell || needsShell) {
|
|
12893
12893
|
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
12894
|
-
parsed.command =
|
|
12894
|
+
parsed.command = path16.normalize(parsed.command);
|
|
12895
12895
|
parsed.command = escape2.command(parsed.command);
|
|
12896
12896
|
parsed.args = parsed.args.map((arg) => escape2.argument(arg, needsDoubleEscapeMetaChars));
|
|
12897
12897
|
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
|
|
@@ -12987,7 +12987,7 @@ var require_cross_spawn = __commonJS({
|
|
|
12987
12987
|
enoent.hookChildProcess(spawned, parsed);
|
|
12988
12988
|
return spawned;
|
|
12989
12989
|
}
|
|
12990
|
-
function
|
|
12990
|
+
function spawnSync8(command, args, options) {
|
|
12991
12991
|
const parsed = parse3(command, args, options);
|
|
12992
12992
|
const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
|
|
12993
12993
|
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
@@ -12995,16 +12995,16 @@ var require_cross_spawn = __commonJS({
|
|
|
12995
12995
|
}
|
|
12996
12996
|
module.exports = spawn5;
|
|
12997
12997
|
module.exports.spawn = spawn5;
|
|
12998
|
-
module.exports.sync =
|
|
12998
|
+
module.exports.sync = spawnSync8;
|
|
12999
12999
|
module.exports._parse = parse3;
|
|
13000
13000
|
module.exports._enoent = enoent;
|
|
13001
13001
|
}
|
|
13002
13002
|
});
|
|
13003
13003
|
|
|
13004
13004
|
// src/maker/server/mcp.ts
|
|
13005
|
-
import { execFileSync, spawn as spawn4, spawnSync as
|
|
13006
|
-
import
|
|
13007
|
-
import
|
|
13005
|
+
import { execFileSync, spawn as spawn4, spawnSync as spawnSync5 } from "node:child_process";
|
|
13006
|
+
import fs10 from "node:fs";
|
|
13007
|
+
import path11 from "node:path";
|
|
13008
13008
|
|
|
13009
13009
|
// node_modules/zod/v3/helpers/util.js
|
|
13010
13010
|
var util;
|
|
@@ -13365,8 +13365,8 @@ function getErrorMap() {
|
|
|
13365
13365
|
|
|
13366
13366
|
// node_modules/zod/v3/helpers/parseUtil.js
|
|
13367
13367
|
var makeIssue = (params) => {
|
|
13368
|
-
const { data, path:
|
|
13369
|
-
const fullPath = [...
|
|
13368
|
+
const { data, path: path16, errorMaps, issueData } = params;
|
|
13369
|
+
const fullPath = [...path16, ...issueData.path || []];
|
|
13370
13370
|
const fullIssue = {
|
|
13371
13371
|
...issueData,
|
|
13372
13372
|
path: fullPath
|
|
@@ -13481,11 +13481,11 @@ var errorUtil;
|
|
|
13481
13481
|
|
|
13482
13482
|
// node_modules/zod/v3/types.js
|
|
13483
13483
|
var ParseInputLazyPath = class {
|
|
13484
|
-
constructor(parent, value,
|
|
13484
|
+
constructor(parent, value, path16, key) {
|
|
13485
13485
|
this._cachedPath = [];
|
|
13486
13486
|
this.parent = parent;
|
|
13487
13487
|
this.data = value;
|
|
13488
|
-
this._path =
|
|
13488
|
+
this._path = path16;
|
|
13489
13489
|
this._key = key;
|
|
13490
13490
|
}
|
|
13491
13491
|
get path() {
|
|
@@ -17134,10 +17134,10 @@ function mergeDefs(...defs) {
|
|
|
17134
17134
|
function cloneDef(schema) {
|
|
17135
17135
|
return mergeDefs(schema._zod.def);
|
|
17136
17136
|
}
|
|
17137
|
-
function getElementAtPath(obj,
|
|
17138
|
-
if (!
|
|
17137
|
+
function getElementAtPath(obj, path16) {
|
|
17138
|
+
if (!path16)
|
|
17139
17139
|
return obj;
|
|
17140
|
-
return
|
|
17140
|
+
return path16.reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
|
|
17141
17141
|
}
|
|
17142
17142
|
function promiseAllObject(promisesObj) {
|
|
17143
17143
|
const keys = Object.keys(promisesObj);
|
|
@@ -17522,11 +17522,11 @@ function aborted(x, startIndex = 0) {
|
|
|
17522
17522
|
}
|
|
17523
17523
|
return false;
|
|
17524
17524
|
}
|
|
17525
|
-
function prefixIssues(
|
|
17525
|
+
function prefixIssues(path16, issues) {
|
|
17526
17526
|
return issues.map((iss) => {
|
|
17527
17527
|
var _a3;
|
|
17528
17528
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
17529
|
-
iss.path.unshift(
|
|
17529
|
+
iss.path.unshift(path16);
|
|
17530
17530
|
return iss;
|
|
17531
17531
|
});
|
|
17532
17532
|
}
|
|
@@ -31208,9 +31208,414 @@ async function requestTapAuthWithPat(manualPat, environment, options = {}) {
|
|
|
31208
31208
|
return auth2;
|
|
31209
31209
|
}
|
|
31210
31210
|
|
|
31211
|
-
// src/maker/
|
|
31211
|
+
// src/maker/system/python.ts
|
|
31212
|
+
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
31212
31213
|
import fs6 from "node:fs";
|
|
31213
31214
|
import path7 from "node:path";
|
|
31215
|
+
var PYTHON_INFO_SCRIPT = [
|
|
31216
|
+
"import json, sys",
|
|
31217
|
+
'print(json.dumps({"executable": sys.executable, "version": ".".join(map(str, sys.version_info[:3]))}))'
|
|
31218
|
+
].join("; ");
|
|
31219
|
+
var DEFAULT_PYTHON_VERSION = "3.12";
|
|
31220
|
+
var MINIMUM_PYTHON_VERSION = "3.8";
|
|
31221
|
+
var RECOMMENDED_PYTHON_VERSION = "3.12";
|
|
31222
|
+
function getMakerPythonConfigPath() {
|
|
31223
|
+
return path7.join(getMakerHome(), "python.json");
|
|
31224
|
+
}
|
|
31225
|
+
function getMakerUvInstallRoot() {
|
|
31226
|
+
return path7.join(getMakerHome(), "bin");
|
|
31227
|
+
}
|
|
31228
|
+
function getMakerUvPath(platform = process.platform) {
|
|
31229
|
+
return path7.join(getMakerUvInstallRoot(), platform === "win32" ? "uv.exe" : "uv");
|
|
31230
|
+
}
|
|
31231
|
+
function getMakerUvPythonInstallDir() {
|
|
31232
|
+
return path7.join(getMakerHome(), "python", "uv");
|
|
31233
|
+
}
|
|
31234
|
+
function checkMakerPythonEnvironment(options = {}) {
|
|
31235
|
+
const platform = options.platform || process.platform;
|
|
31236
|
+
const runner = options.spawn || spawnSync4;
|
|
31237
|
+
const env = options.env || process.env;
|
|
31238
|
+
const uvPath = getMakerUvPath(platform);
|
|
31239
|
+
const setupCommand = "taptap-maker python setup";
|
|
31240
|
+
const pathCommand = "taptap-maker python path";
|
|
31241
|
+
const base = {
|
|
31242
|
+
platform,
|
|
31243
|
+
configPath: getMakerPythonConfigPath(),
|
|
31244
|
+
setupCommand,
|
|
31245
|
+
pathCommand,
|
|
31246
|
+
uv: {
|
|
31247
|
+
path: uvPath,
|
|
31248
|
+
installed: fs6.existsSync(uvPath),
|
|
31249
|
+
version: readUvVersion(uvPath, runner)
|
|
31250
|
+
}
|
|
31251
|
+
};
|
|
31252
|
+
const configuredPython = env.TAPTAP_MAKER_PYTHON_BIN;
|
|
31253
|
+
if (configuredPython) {
|
|
31254
|
+
const result = inspectPythonCandidate(
|
|
31255
|
+
{ provider: "configured", command: configuredPython },
|
|
31256
|
+
runner
|
|
31257
|
+
);
|
|
31258
|
+
if (result) {
|
|
31259
|
+
return resultToEnvironment(result, base);
|
|
31260
|
+
}
|
|
31261
|
+
}
|
|
31262
|
+
const saved = loadPythonRuntimeConfig();
|
|
31263
|
+
if (saved == null ? void 0 : saved.python) {
|
|
31264
|
+
const result = inspectPythonCandidate(
|
|
31265
|
+
{ provider: saved.provider || "configured", command: saved.python },
|
|
31266
|
+
runner
|
|
31267
|
+
);
|
|
31268
|
+
if (result && !isUnsupportedSystemPython(platform, result.executable, result.provider)) {
|
|
31269
|
+
return resultToEnvironment(result, base);
|
|
31270
|
+
}
|
|
31271
|
+
}
|
|
31272
|
+
let sawWindowsStoreAlias = false;
|
|
31273
|
+
let unsupportedSystemPython;
|
|
31274
|
+
let fallbackEnvironment;
|
|
31275
|
+
for (const candidate of createPythonCandidates(platform, runner)) {
|
|
31276
|
+
if (candidate.command === "__windows_store_alias__") {
|
|
31277
|
+
sawWindowsStoreAlias = true;
|
|
31278
|
+
continue;
|
|
31279
|
+
}
|
|
31280
|
+
const result = inspectPythonCandidate(candidate, runner);
|
|
31281
|
+
if (result) {
|
|
31282
|
+
if (isUnsupportedSystemPython(platform, result.executable, result.provider)) {
|
|
31283
|
+
unsupportedSystemPython = result.executable;
|
|
31284
|
+
continue;
|
|
31285
|
+
}
|
|
31286
|
+
const environment = resultToEnvironment(result, base);
|
|
31287
|
+
if (environment.ready) {
|
|
31288
|
+
return environment;
|
|
31289
|
+
}
|
|
31290
|
+
fallbackEnvironment ||= environment;
|
|
31291
|
+
}
|
|
31292
|
+
}
|
|
31293
|
+
if (fallbackEnvironment) {
|
|
31294
|
+
return fallbackEnvironment;
|
|
31295
|
+
}
|
|
31296
|
+
if ((saved == null ? void 0 : saved.status) === "setup_failed") {
|
|
31297
|
+
return {
|
|
31298
|
+
...base,
|
|
31299
|
+
ready: false,
|
|
31300
|
+
status: "setup_failed",
|
|
31301
|
+
missing: ["python"],
|
|
31302
|
+
error: saved.error,
|
|
31303
|
+
nextAction: "上次 Python 环境准备失败。请检查网络、代理或目录权限后重试 `taptap-maker python setup`;也可以自行安装 Python 3.12 并确保 pip 可用。"
|
|
31304
|
+
};
|
|
31305
|
+
}
|
|
31306
|
+
const status = sawWindowsStoreAlias ? "store_alias_only" : "missing";
|
|
31307
|
+
return {
|
|
31308
|
+
...base,
|
|
31309
|
+
ready: false,
|
|
31310
|
+
status,
|
|
31311
|
+
missing: ["python"],
|
|
31312
|
+
error: status === "store_alias_only" ? "Only Windows Store Python app execution aliases were found." : unsupportedSystemPython ? `Apple/Xcode Python was found at ${unsupportedSystemPython}, but Maker needs a private or user-managed Python toolchain for diagnostics.` : void 0,
|
|
31313
|
+
nextAction: status === "store_alias_only" ? "检测到 Windows Store Python alias,但这不是真实 Python。请运行 `taptap-maker python setup` 准备 Python 环境。" : "未检测到可用 Python。请运行 `taptap-maker python setup` 准备 Python 环境。"
|
|
31314
|
+
};
|
|
31315
|
+
}
|
|
31316
|
+
function setupMakerPythonEnvironment(options = {}) {
|
|
31317
|
+
const before = checkMakerPythonEnvironment(options);
|
|
31318
|
+
if (before.ready) {
|
|
31319
|
+
savePythonRuntimeConfig(before);
|
|
31320
|
+
return { changed: false, environment: before, uvInstalled: before.uv.installed };
|
|
31321
|
+
}
|
|
31322
|
+
const platform = options.platform || process.platform;
|
|
31323
|
+
const runner = options.spawn || spawnSync4;
|
|
31324
|
+
try {
|
|
31325
|
+
const uvPath = ensureUvInstalled(platform, runner);
|
|
31326
|
+
const uvEnv = createUvPythonEnv();
|
|
31327
|
+
const install = runner(
|
|
31328
|
+
uvPath,
|
|
31329
|
+
["python", "install", DEFAULT_PYTHON_VERSION, "--managed-python"],
|
|
31330
|
+
{
|
|
31331
|
+
encoding: "utf8",
|
|
31332
|
+
env: uvEnv
|
|
31333
|
+
}
|
|
31334
|
+
);
|
|
31335
|
+
if (install.status !== 0) {
|
|
31336
|
+
throw new Error(formatSetupFailure("uv python install failed", install));
|
|
31337
|
+
}
|
|
31338
|
+
const find = runner(uvPath, ["python", "find", DEFAULT_PYTHON_VERSION], {
|
|
31339
|
+
encoding: "utf8",
|
|
31340
|
+
env: uvEnv
|
|
31341
|
+
});
|
|
31342
|
+
if (find.status !== 0 || !find.stdout.trim()) {
|
|
31343
|
+
throw new Error(formatSetupFailure("uv python find failed", find));
|
|
31344
|
+
}
|
|
31345
|
+
const python = find.stdout.trim().split(/\r?\n/)[0];
|
|
31346
|
+
const result = inspectPythonCandidate({ provider: "uv-managed", command: python }, runner);
|
|
31347
|
+
if (!(result == null ? void 0 : result.pipVersion)) {
|
|
31348
|
+
throw new Error("Python 3.12 was installed, but pip is not available.");
|
|
31349
|
+
}
|
|
31350
|
+
const environment = resultToEnvironment(result, {
|
|
31351
|
+
platform,
|
|
31352
|
+
configPath: getMakerPythonConfigPath(),
|
|
31353
|
+
setupCommand: "taptap-maker python setup",
|
|
31354
|
+
pathCommand: "taptap-maker python path",
|
|
31355
|
+
uv: {
|
|
31356
|
+
path: uvPath,
|
|
31357
|
+
installed: true,
|
|
31358
|
+
version: readUvVersion(uvPath, runner)
|
|
31359
|
+
}
|
|
31360
|
+
});
|
|
31361
|
+
savePythonRuntimeConfig(environment);
|
|
31362
|
+
return { changed: true, environment, uvInstalled: true };
|
|
31363
|
+
} catch (error2) {
|
|
31364
|
+
try {
|
|
31365
|
+
savePythonSetupFailure(error2);
|
|
31366
|
+
} catch {
|
|
31367
|
+
}
|
|
31368
|
+
throw error2;
|
|
31369
|
+
}
|
|
31370
|
+
}
|
|
31371
|
+
function formatMakerPythonEnvironmentStatus(environment) {
|
|
31372
|
+
return [
|
|
31373
|
+
"Python environment",
|
|
31374
|
+
"",
|
|
31375
|
+
`- python_status: ${environment.status}`,
|
|
31376
|
+
`- ready: ${environment.ready ? "yes" : "no"}`,
|
|
31377
|
+
environment.provider ? `- provider: ${environment.provider}` : "",
|
|
31378
|
+
environment.python ? `- python: ${environment.python}` : "",
|
|
31379
|
+
environment.version ? `- python_version: ${environment.version}` : "",
|
|
31380
|
+
`- python_version_requirement: >=${MINIMUM_PYTHON_VERSION}`,
|
|
31381
|
+
`- recommended_python_version: >=${RECOMMENDED_PYTHON_VERSION}`,
|
|
31382
|
+
environment.pipVersion ? `- pip_version: ${environment.pipVersion}` : "",
|
|
31383
|
+
`- config: ${environment.configPath}`,
|
|
31384
|
+
`- uv_installed: ${environment.uv.installed ? "yes" : "no"}`,
|
|
31385
|
+
`- uv_path: ${environment.uv.path}`,
|
|
31386
|
+
environment.uv.version ? `- uv_version: ${environment.uv.version}` : "",
|
|
31387
|
+
`- missing: ${environment.missing.join(", ") || "(none)"}`,
|
|
31388
|
+
environment.error ? `- error: ${environment.error}` : "",
|
|
31389
|
+
environment.warning ? `- warning: ${environment.warning}` : "",
|
|
31390
|
+
`- setup_command: ${environment.setupCommand}`,
|
|
31391
|
+
`- path_command: ${environment.pathCommand}`,
|
|
31392
|
+
`- next_action: ${environment.nextAction}`
|
|
31393
|
+
].filter(Boolean).join("\n");
|
|
31394
|
+
}
|
|
31395
|
+
function createPythonCandidates(platform, runner) {
|
|
31396
|
+
if (platform === "win32") {
|
|
31397
|
+
const candidates = [
|
|
31398
|
+
{ provider: "system", command: "py", argsPrefix: ["-3"] }
|
|
31399
|
+
];
|
|
31400
|
+
const where = runner("where.exe", ["python"], { encoding: "utf8" });
|
|
31401
|
+
const paths = where.status === 0 ? where.stdout.split(/\r?\n/).map((line) => line.trim()).filter(Boolean) : [];
|
|
31402
|
+
let sawStoreAlias = false;
|
|
31403
|
+
for (const item of paths) {
|
|
31404
|
+
if (isWindowsStorePythonAlias(item)) {
|
|
31405
|
+
sawStoreAlias = true;
|
|
31406
|
+
continue;
|
|
31407
|
+
}
|
|
31408
|
+
candidates.push({ provider: "system", command: item });
|
|
31409
|
+
}
|
|
31410
|
+
if (sawStoreAlias) {
|
|
31411
|
+
candidates.push({ provider: "system", command: "__windows_store_alias__" });
|
|
31412
|
+
}
|
|
31413
|
+
return candidates;
|
|
31414
|
+
}
|
|
31415
|
+
return [
|
|
31416
|
+
{ provider: "system", command: "python3" },
|
|
31417
|
+
{ provider: "system", command: "python" }
|
|
31418
|
+
];
|
|
31419
|
+
}
|
|
31420
|
+
function inspectPythonCandidate(candidate, runner) {
|
|
31421
|
+
const infoArgs = [...candidate.argsPrefix || [], "-c", PYTHON_INFO_SCRIPT];
|
|
31422
|
+
const info = runner(candidate.command, infoArgs, { encoding: "utf8" });
|
|
31423
|
+
if (info.status !== 0 || !info.stdout.trim()) {
|
|
31424
|
+
return void 0;
|
|
31425
|
+
}
|
|
31426
|
+
const parsed = parsePythonInfo(info.stdout);
|
|
31427
|
+
if (!(parsed == null ? void 0 : parsed.executable) || !parsed.version) {
|
|
31428
|
+
return void 0;
|
|
31429
|
+
}
|
|
31430
|
+
const pip = runner(parsed.executable, ["-m", "pip", "--version"], { encoding: "utf8" });
|
|
31431
|
+
return {
|
|
31432
|
+
...parsed,
|
|
31433
|
+
provider: candidate.provider,
|
|
31434
|
+
pipVersion: pip.status === 0 ? pip.stdout.trim() : void 0
|
|
31435
|
+
};
|
|
31436
|
+
}
|
|
31437
|
+
function resultToEnvironment(result, base) {
|
|
31438
|
+
const versionStatus = comparePythonVersion(result.version, MINIMUM_PYTHON_VERSION);
|
|
31439
|
+
if (versionStatus !== void 0 && versionStatus < 0) {
|
|
31440
|
+
return {
|
|
31441
|
+
...base,
|
|
31442
|
+
ready: false,
|
|
31443
|
+
status: "version_unsupported",
|
|
31444
|
+
provider: result.provider,
|
|
31445
|
+
python: result.executable,
|
|
31446
|
+
version: result.version,
|
|
31447
|
+
pipVersion: result.pipVersion,
|
|
31448
|
+
missing: [`python>=${MINIMUM_PYTHON_VERSION}`],
|
|
31449
|
+
error: `Python ${result.version} is below the minimum supported ${MINIMUM_PYTHON_VERSION}.`,
|
|
31450
|
+
nextAction: `当前 Python 版本低于 Maker Lua 诊断最低要求 ${MINIMUM_PYTHON_VERSION}。请运行 \`taptap-maker python setup\` 准备 Python ${DEFAULT_PYTHON_VERSION} 环境。`
|
|
31451
|
+
};
|
|
31452
|
+
}
|
|
31453
|
+
const ready = Boolean(result.pipVersion);
|
|
31454
|
+
const shouldRecommendUpgrade = ready && versionStatus !== void 0 && comparePythonVersion(result.version, RECOMMENDED_PYTHON_VERSION) < 0;
|
|
31455
|
+
return {
|
|
31456
|
+
...base,
|
|
31457
|
+
ready,
|
|
31458
|
+
status: ready ? "ready" : "pip_missing",
|
|
31459
|
+
provider: result.provider,
|
|
31460
|
+
python: result.executable,
|
|
31461
|
+
version: result.version,
|
|
31462
|
+
pipVersion: result.pipVersion,
|
|
31463
|
+
missing: ready ? [] : ["pip"],
|
|
31464
|
+
warning: shouldRecommendUpgrade ? `Python ${RECOMMENDED_PYTHON_VERSION} or newer is recommended for Maker Lua diagnostics; current version is ${result.version}.` : void 0,
|
|
31465
|
+
nextAction: ready ? shouldRecommendUpgrade ? `本地 Python 满足最低要求 ${MINIMUM_PYTHON_VERSION},但推荐使用 ${RECOMMENDED_PYTHON_VERSION} 或更新版本;如需统一环境,可运行 \`taptap-maker python setup\` 准备 Python ${DEFAULT_PYTHON_VERSION} 环境。` : "本地 Python 运行时可用;Maker Lua 诊断脚本可以复用该解释器。" : "检测到 Python,但 pip 不可用。请运行 `taptap-maker python setup` 准备 Python 环境。"
|
|
31466
|
+
};
|
|
31467
|
+
}
|
|
31468
|
+
function ensureUvInstalled(platform, runner) {
|
|
31469
|
+
const uvPath = getMakerUvPath(platform);
|
|
31470
|
+
if (fs6.existsSync(uvPath)) {
|
|
31471
|
+
return uvPath;
|
|
31472
|
+
}
|
|
31473
|
+
fs6.mkdirSync(getMakerUvInstallRoot(), { recursive: true });
|
|
31474
|
+
const env = {
|
|
31475
|
+
...process.env,
|
|
31476
|
+
INSTALLER_NO_MODIFY_PATH: "1",
|
|
31477
|
+
UV_INSTALL_DIR: getMakerUvInstallRoot()
|
|
31478
|
+
};
|
|
31479
|
+
const install = platform === "win32" ? runner(
|
|
31480
|
+
"powershell.exe",
|
|
31481
|
+
[
|
|
31482
|
+
"-NoProfile",
|
|
31483
|
+
"-ExecutionPolicy",
|
|
31484
|
+
"ByPass",
|
|
31485
|
+
"-Command",
|
|
31486
|
+
"irm https://astral.sh/uv/install.ps1 | iex"
|
|
31487
|
+
],
|
|
31488
|
+
{ encoding: "utf8", env }
|
|
31489
|
+
) : runner("sh", ["-c", "curl -LsSf https://astral.sh/uv/install.sh | sh"], {
|
|
31490
|
+
encoding: "utf8",
|
|
31491
|
+
env
|
|
31492
|
+
});
|
|
31493
|
+
if (install.status !== 0) {
|
|
31494
|
+
throw new Error(formatSetupFailure("uv installer failed", install));
|
|
31495
|
+
}
|
|
31496
|
+
if (!fs6.existsSync(uvPath)) {
|
|
31497
|
+
const nestedUvPath = path7.join(
|
|
31498
|
+
getMakerUvInstallRoot(),
|
|
31499
|
+
"bin",
|
|
31500
|
+
platform === "win32" ? "uv.exe" : "uv"
|
|
31501
|
+
);
|
|
31502
|
+
if (fs6.existsSync(nestedUvPath)) {
|
|
31503
|
+
return nestedUvPath;
|
|
31504
|
+
}
|
|
31505
|
+
throw new Error(`uv installer finished, but ${uvPath} was not created.`);
|
|
31506
|
+
}
|
|
31507
|
+
return uvPath;
|
|
31508
|
+
}
|
|
31509
|
+
function createUvPythonEnv() {
|
|
31510
|
+
return {
|
|
31511
|
+
...process.env,
|
|
31512
|
+
UV_PYTHON_INSTALL_DIR: getMakerUvPythonInstallDir(),
|
|
31513
|
+
UV_CACHE_DIR: path7.join(getMakerHome(), "cache", "uv")
|
|
31514
|
+
};
|
|
31515
|
+
}
|
|
31516
|
+
function readUvVersion(uvPath, runner) {
|
|
31517
|
+
if (!fs6.existsSync(uvPath)) {
|
|
31518
|
+
return void 0;
|
|
31519
|
+
}
|
|
31520
|
+
const result = runner(uvPath, ["--version"], { encoding: "utf8" });
|
|
31521
|
+
return result.status === 0 ? result.stdout.trim() || void 0 : void 0;
|
|
31522
|
+
}
|
|
31523
|
+
function parsePythonInfo(stdout) {
|
|
31524
|
+
try {
|
|
31525
|
+
const data = JSON.parse(stdout.trim().split(/\r?\n/).at(-1) || "{}");
|
|
31526
|
+
if (typeof data.executable === "string" && typeof data.version === "string") {
|
|
31527
|
+
return { executable: data.executable, version: data.version };
|
|
31528
|
+
}
|
|
31529
|
+
} catch {
|
|
31530
|
+
return void 0;
|
|
31531
|
+
}
|
|
31532
|
+
return void 0;
|
|
31533
|
+
}
|
|
31534
|
+
function isWindowsStorePythonAlias(value) {
|
|
31535
|
+
return /\\Microsoft\\WindowsApps\\python(?:3)?\.exe$/i.test(value);
|
|
31536
|
+
}
|
|
31537
|
+
function isUnsupportedSystemPython(platform, executable, provider) {
|
|
31538
|
+
if (provider !== "system" || platform !== "darwin") {
|
|
31539
|
+
return false;
|
|
31540
|
+
}
|
|
31541
|
+
return executable === "/usr/bin/python3" || executable.startsWith("/Applications/Xcode.app/") || executable.startsWith("/Library/Developer/CommandLineTools/");
|
|
31542
|
+
}
|
|
31543
|
+
function comparePythonVersion(version2, target) {
|
|
31544
|
+
const left = parseVersionTuple(version2);
|
|
31545
|
+
const right = parseVersionTuple(target);
|
|
31546
|
+
if (!left || !right) {
|
|
31547
|
+
return 0;
|
|
31548
|
+
}
|
|
31549
|
+
for (let index = 0; index < Math.max(left.length, right.length); index += 1) {
|
|
31550
|
+
const leftPart = left[index] || 0;
|
|
31551
|
+
const rightPart = right[index] || 0;
|
|
31552
|
+
if (leftPart > rightPart) {
|
|
31553
|
+
return 1;
|
|
31554
|
+
}
|
|
31555
|
+
if (leftPart < rightPart) {
|
|
31556
|
+
return -1;
|
|
31557
|
+
}
|
|
31558
|
+
}
|
|
31559
|
+
return 0;
|
|
31560
|
+
}
|
|
31561
|
+
function parseVersionTuple(version2) {
|
|
31562
|
+
const match = /^(\d+)(?:\.(\d+))?(?:\.(\d+))?/.exec(version2.trim());
|
|
31563
|
+
if (!match) {
|
|
31564
|
+
return void 0;
|
|
31565
|
+
}
|
|
31566
|
+
return match.slice(1).map((part) => part === void 0 ? 0 : Number(part));
|
|
31567
|
+
}
|
|
31568
|
+
function loadPythonRuntimeConfig() {
|
|
31569
|
+
const configPath = getMakerPythonConfigPath();
|
|
31570
|
+
if (!fs6.existsSync(configPath)) {
|
|
31571
|
+
return void 0;
|
|
31572
|
+
}
|
|
31573
|
+
try {
|
|
31574
|
+
const data = JSON.parse(fs6.readFileSync(configPath, "utf8"));
|
|
31575
|
+
if (typeof data.python === "string" || data.status === "setup_failed") {
|
|
31576
|
+
return data;
|
|
31577
|
+
}
|
|
31578
|
+
return void 0;
|
|
31579
|
+
} catch {
|
|
31580
|
+
return void 0;
|
|
31581
|
+
}
|
|
31582
|
+
}
|
|
31583
|
+
function savePythonRuntimeConfig(environment) {
|
|
31584
|
+
if (!environment.python) {
|
|
31585
|
+
return;
|
|
31586
|
+
}
|
|
31587
|
+
const config2 = {
|
|
31588
|
+
provider: environment.provider,
|
|
31589
|
+
python: environment.python,
|
|
31590
|
+
version: environment.version,
|
|
31591
|
+
saved_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
31592
|
+
};
|
|
31593
|
+
fs6.mkdirSync(path7.dirname(getMakerPythonConfigPath()), { recursive: true });
|
|
31594
|
+
fs6.writeFileSync(getMakerPythonConfigPath(), JSON.stringify(config2, null, 2), "utf8");
|
|
31595
|
+
}
|
|
31596
|
+
function savePythonSetupFailure(error2) {
|
|
31597
|
+
const config2 = {
|
|
31598
|
+
status: "setup_failed",
|
|
31599
|
+
error: error2 instanceof Error ? error2.message : String(error2),
|
|
31600
|
+
saved_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
31601
|
+
};
|
|
31602
|
+
fs6.mkdirSync(path7.dirname(getMakerPythonConfigPath()), { recursive: true });
|
|
31603
|
+
fs6.writeFileSync(getMakerPythonConfigPath(), JSON.stringify(config2, null, 2), "utf8");
|
|
31604
|
+
}
|
|
31605
|
+
function formatSetupFailure(message, result) {
|
|
31606
|
+
var _a3, _b, _c;
|
|
31607
|
+
return [
|
|
31608
|
+
message,
|
|
31609
|
+
`- status: ${result.status ?? "(none)"}`,
|
|
31610
|
+
((_a3 = result.error) == null ? void 0 : _a3.message) ? `- error: ${result.error.message}` : "",
|
|
31611
|
+
((_b = result.stderr) == null ? void 0 : _b.trim()) ? `- stderr: ${result.stderr.trim()}` : "",
|
|
31612
|
+
((_c = result.stdout) == null ? void 0 : _c.trim()) ? `- stdout: ${result.stdout.trim()}` : ""
|
|
31613
|
+
].filter(Boolean).join("\n");
|
|
31614
|
+
}
|
|
31615
|
+
|
|
31616
|
+
// src/maker/cli/skill.ts
|
|
31617
|
+
import fs7 from "node:fs";
|
|
31618
|
+
import path8 from "node:path";
|
|
31214
31619
|
import { fileURLToPath } from "node:url";
|
|
31215
31620
|
var MAKER_LOCAL_SKILL_NAME = "taptap-maker-local";
|
|
31216
31621
|
var MAKER_DEV_KIT_GUIDE_SKILL_NAME = "taptap-maker-dev-kit-guide";
|
|
@@ -31229,7 +31634,7 @@ var BUNDLED_SKILLS = [
|
|
|
31229
31634
|
function formatMakerSkillStatus(_options = {}) {
|
|
31230
31635
|
const skillDocuments = BUNDLED_SKILLS.map((skill) => ({
|
|
31231
31636
|
name: skill.name,
|
|
31232
|
-
path:
|
|
31637
|
+
path: path8.join(resolveMakerSkillSourceDir(skill.name), "SKILL.md")
|
|
31233
31638
|
}));
|
|
31234
31639
|
return [
|
|
31235
31640
|
"TapTap Maker workflow guide documents",
|
|
@@ -31262,11 +31667,11 @@ function formatMakerSkillStatus(_options = {}) {
|
|
|
31262
31667
|
}
|
|
31263
31668
|
function resolveMakerSkillSourceDir(skillName = MAKER_LOCAL_SKILL_NAME) {
|
|
31264
31669
|
const candidates = [
|
|
31265
|
-
|
|
31670
|
+
path8.join(process.cwd(), "skills", skillName),
|
|
31266
31671
|
getBundledSkillSourceDir(skillName)
|
|
31267
31672
|
].filter(Boolean);
|
|
31268
31673
|
for (const candidate of candidates) {
|
|
31269
|
-
if (
|
|
31674
|
+
if (fs7.existsSync(path8.join(candidate, "SKILL.md"))) {
|
|
31270
31675
|
return candidate;
|
|
31271
31676
|
}
|
|
31272
31677
|
}
|
|
@@ -31279,13 +31684,13 @@ function getBundledSkillSourceDir(skillName) {
|
|
|
31279
31684
|
return null;
|
|
31280
31685
|
}
|
|
31281
31686
|
const bundlePath = fileURLToPath(__MAKER_BUNDLE_URL__);
|
|
31282
|
-
const packageRoot =
|
|
31283
|
-
return
|
|
31687
|
+
const packageRoot = path8.dirname(path8.dirname(bundlePath));
|
|
31688
|
+
return path8.join(packageRoot, "skills", skillName);
|
|
31284
31689
|
}
|
|
31285
31690
|
|
|
31286
31691
|
// src/maker/server/runtimeLogs.ts
|
|
31287
|
-
import
|
|
31288
|
-
import
|
|
31692
|
+
import fs8 from "node:fs";
|
|
31693
|
+
import path9 from "node:path";
|
|
31289
31694
|
var DEFAULT_RUNTIME_LOG_SINCE_SECONDS = 600;
|
|
31290
31695
|
var DEFAULT_RUNTIME_LOG_IDLE_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
31291
31696
|
var MAX_RUNTIME_LOG_WINDOW_SECONDS = 3600;
|
|
@@ -31426,19 +31831,19 @@ async function pullRuntimeLogs(options) {
|
|
|
31426
31831
|
}
|
|
31427
31832
|
function resetRuntimeLogs(projectRoot) {
|
|
31428
31833
|
const runtimeDir = getRuntimeLogDir(projectRoot);
|
|
31429
|
-
|
|
31834
|
+
fs8.mkdirSync(runtimeDir, { recursive: true });
|
|
31430
31835
|
for (const file2 of RUNTIME_LOG_FILES_TO_RESET) {
|
|
31431
|
-
|
|
31836
|
+
fs8.rmSync(path9.join(runtimeDir, file2), { force: true });
|
|
31432
31837
|
}
|
|
31433
31838
|
return runtimeDir;
|
|
31434
31839
|
}
|
|
31435
31840
|
function readRuntimeLogState(projectRoot) {
|
|
31436
31841
|
const statePath = getRuntimeLogStatePath(projectRoot);
|
|
31437
|
-
if (!
|
|
31842
|
+
if (!fs8.existsSync(statePath)) {
|
|
31438
31843
|
return null;
|
|
31439
31844
|
}
|
|
31440
31845
|
try {
|
|
31441
|
-
const state = JSON.parse(
|
|
31846
|
+
const state = JSON.parse(fs8.readFileSync(statePath, "utf8"));
|
|
31442
31847
|
return isRuntimeLogState(state) ? state : null;
|
|
31443
31848
|
} catch {
|
|
31444
31849
|
return null;
|
|
@@ -31466,9 +31871,9 @@ function normalizeRuntimeLogQueryResult(result) {
|
|
|
31466
31871
|
};
|
|
31467
31872
|
}
|
|
31468
31873
|
function writeRuntimeLogRawResponse(projectRoot, raw) {
|
|
31469
|
-
const rawPath =
|
|
31470
|
-
|
|
31471
|
-
|
|
31874
|
+
const rawPath = path9.join(getRuntimeLogDir(projectRoot), "last-query-runtime-logs-result.json");
|
|
31875
|
+
fs8.mkdirSync(path9.dirname(rawPath), { recursive: true });
|
|
31876
|
+
fs8.writeFileSync(
|
|
31472
31877
|
rawPath,
|
|
31473
31878
|
`${JSON.stringify({ capturedAt: (/* @__PURE__ */ new Date()).toISOString(), raw }, null, 2)}
|
|
31474
31879
|
`,
|
|
@@ -31477,7 +31882,7 @@ function writeRuntimeLogRawResponse(projectRoot, raw) {
|
|
|
31477
31882
|
return rawPath;
|
|
31478
31883
|
}
|
|
31479
31884
|
function appendRuntimeLogs(projectRoot, logs) {
|
|
31480
|
-
|
|
31885
|
+
fs8.mkdirSync(getRuntimeLogDir(projectRoot), { recursive: true });
|
|
31481
31886
|
if (logs.length === 0) {
|
|
31482
31887
|
return { files: [], written: 0 };
|
|
31483
31888
|
}
|
|
@@ -31485,7 +31890,7 @@ function appendRuntimeLogs(projectRoot, logs) {
|
|
|
31485
31890
|
let written = 0;
|
|
31486
31891
|
for (const log of logs) {
|
|
31487
31892
|
const line = JSON.stringify(compactRuntimeLogEntry(log));
|
|
31488
|
-
|
|
31893
|
+
fs8.appendFileSync(filePath, `${line}
|
|
31489
31894
|
`, "utf8");
|
|
31490
31895
|
written += 1;
|
|
31491
31896
|
}
|
|
@@ -31493,11 +31898,11 @@ function appendRuntimeLogs(projectRoot, logs) {
|
|
|
31493
31898
|
}
|
|
31494
31899
|
function writeRuntimeLogState(projectRoot, state) {
|
|
31495
31900
|
const statePath = getRuntimeLogStatePath(projectRoot);
|
|
31496
|
-
|
|
31901
|
+
fs8.mkdirSync(path9.dirname(statePath), { recursive: true });
|
|
31497
31902
|
const tempPath = `${statePath}.${process.pid}.${Date.now()}.tmp`;
|
|
31498
|
-
|
|
31903
|
+
fs8.writeFileSync(tempPath, `${JSON.stringify(state, null, 2)}
|
|
31499
31904
|
`, "utf8");
|
|
31500
|
-
|
|
31905
|
+
fs8.renameSync(tempPath, statePath);
|
|
31501
31906
|
}
|
|
31502
31907
|
function writeRuntimeLogFailureState(projectRoot, options) {
|
|
31503
31908
|
const nowIso = new Date(options.nowMs()).toISOString();
|
|
@@ -31529,13 +31934,13 @@ function isNonRetryableRuntimeLogError(error2) {
|
|
|
31529
31934
|
);
|
|
31530
31935
|
}
|
|
31531
31936
|
function getRuntimeLogDir(projectRoot) {
|
|
31532
|
-
return
|
|
31937
|
+
return path9.join(projectRoot, ".maker", "logs", "runtime");
|
|
31533
31938
|
}
|
|
31534
31939
|
function getRuntimeLogStatePath(projectRoot) {
|
|
31535
|
-
return
|
|
31940
|
+
return path9.join(getRuntimeLogDir(projectRoot), "state.json");
|
|
31536
31941
|
}
|
|
31537
31942
|
function getRuntimeLogPath(projectRoot) {
|
|
31538
|
-
return
|
|
31943
|
+
return path9.join(getRuntimeLogDir(projectRoot), MERGED_RUNTIME_LOG_FILE);
|
|
31539
31944
|
}
|
|
31540
31945
|
function resolveNextRuntimeLogCursor(result) {
|
|
31541
31946
|
const maxLogTime = result.logs.reduce((max, log) => {
|
|
@@ -31660,8 +32065,8 @@ function compactRuntimeLogEntry(entry) {
|
|
|
31660
32065
|
}
|
|
31661
32066
|
|
|
31662
32067
|
// src/maker/server/proxyAssets.ts
|
|
31663
|
-
import
|
|
31664
|
-
import
|
|
32068
|
+
import fs9 from "node:fs";
|
|
32069
|
+
import path10 from "node:path";
|
|
31665
32070
|
var IMAGE_ASSET_DIRS = ["assets/image"];
|
|
31666
32071
|
var VIDEO_ASSET_DIRS = ["assets/video"];
|
|
31667
32072
|
var AUDIO_ASSET_DIRS = ["assets/audio"];
|
|
@@ -31905,8 +32310,8 @@ async function materializeAsset(options) {
|
|
|
31905
32310
|
};
|
|
31906
32311
|
}
|
|
31907
32312
|
const bytes = Buffer.from(await response.arrayBuffer());
|
|
31908
|
-
|
|
31909
|
-
|
|
32313
|
+
fs9.mkdirSync(path10.dirname(absolutePath), { recursive: true });
|
|
32314
|
+
fs9.writeFileSync(absolutePath, bytes);
|
|
31910
32315
|
return { localPath: relativePath, absolutePath, download: { success: true } };
|
|
31911
32316
|
} catch (error2) {
|
|
31912
32317
|
return {
|
|
@@ -31920,12 +32325,12 @@ async function materializeAsset(options) {
|
|
|
31920
32325
|
function createUniqueAssetPath(options) {
|
|
31921
32326
|
const stem = `${sanitizeAssetBaseName(options.baseName)}_${formatAssetTimestamp(options.now)}`;
|
|
31922
32327
|
for (let index = 1; index <= 9999; index += 1) {
|
|
31923
|
-
const relativePath =
|
|
32328
|
+
const relativePath = path10.posix.join(
|
|
31924
32329
|
options.relativeDir,
|
|
31925
32330
|
`${stem}${index === 1 ? "" : `_${index}`}.${options.extension}`
|
|
31926
32331
|
);
|
|
31927
|
-
const absolutePath =
|
|
31928
|
-
if (!
|
|
32332
|
+
const absolutePath = path10.join(options.targetDir, ...relativePath.split("/"));
|
|
32333
|
+
if (!fs9.existsSync(absolutePath)) {
|
|
31929
32334
|
return { relativePath, absolutePath };
|
|
31930
32335
|
}
|
|
31931
32336
|
}
|
|
@@ -32008,7 +32413,7 @@ function findRegistryAssetByName(value, registry2, assetDirs) {
|
|
|
32008
32413
|
if (!isKnownAssetPath(localPath, assetDirs)) {
|
|
32009
32414
|
return false;
|
|
32010
32415
|
}
|
|
32011
|
-
const basename =
|
|
32416
|
+
const basename = path10.posix.basename(localPath);
|
|
32012
32417
|
const stem = basename.replace(/\.[^.]+$/, "");
|
|
32013
32418
|
return basename === value || stem === value || record2.name === value || record2.taskId === value;
|
|
32014
32419
|
});
|
|
@@ -32021,13 +32426,13 @@ function findRegistryAssetByName(value, registry2, assetDirs) {
|
|
|
32021
32426
|
}
|
|
32022
32427
|
function findLocalAssetByName(targetDir, value, assetDirs) {
|
|
32023
32428
|
var _a3;
|
|
32024
|
-
const hasExtension = Boolean(
|
|
32429
|
+
const hasExtension = Boolean(path10.extname(value));
|
|
32025
32430
|
const candidates = [];
|
|
32026
32431
|
for (const assetDir of assetDirs) {
|
|
32027
|
-
const absoluteDir =
|
|
32432
|
+
const absoluteDir = path10.join(targetDir, ...assetDir.split("/"));
|
|
32028
32433
|
let entries;
|
|
32029
32434
|
try {
|
|
32030
|
-
entries =
|
|
32435
|
+
entries = fs9.readdirSync(absoluteDir);
|
|
32031
32436
|
} catch {
|
|
32032
32437
|
continue;
|
|
32033
32438
|
}
|
|
@@ -32036,11 +32441,11 @@ function findLocalAssetByName(targetDir, value, assetDirs) {
|
|
|
32036
32441
|
if (hasExtension ? entry !== value : stem !== value && !stem.startsWith(`${value}_`)) {
|
|
32037
32442
|
continue;
|
|
32038
32443
|
}
|
|
32039
|
-
const absolutePath =
|
|
32444
|
+
const absolutePath = path10.join(absoluteDir, entry);
|
|
32040
32445
|
try {
|
|
32041
32446
|
candidates.push({
|
|
32042
|
-
localPath:
|
|
32043
|
-
mtimeMs:
|
|
32447
|
+
localPath: path10.posix.join(assetDir, entry),
|
|
32448
|
+
mtimeMs: fs9.statSync(absolutePath).mtimeMs
|
|
32044
32449
|
});
|
|
32045
32450
|
} catch {
|
|
32046
32451
|
}
|
|
@@ -32050,7 +32455,7 @@ function findLocalAssetByName(targetDir, value, assetDirs) {
|
|
|
32050
32455
|
return (_a3 = candidates[0]) == null ? void 0 : _a3.localPath;
|
|
32051
32456
|
}
|
|
32052
32457
|
function isKnownAssetPath(relativePath, assetDirs) {
|
|
32053
|
-
if (relativePath.startsWith("../") ||
|
|
32458
|
+
if (relativePath.startsWith("../") || path10.isAbsolute(relativePath)) {
|
|
32054
32459
|
return false;
|
|
32055
32460
|
}
|
|
32056
32461
|
return assetDirs.some(
|
|
@@ -32064,31 +32469,31 @@ function upsertGeneratedAssetRecord(targetDir, localPath, record2) {
|
|
|
32064
32469
|
const registry2 = readGeneratedAssetRegistry(targetDir);
|
|
32065
32470
|
registry2[localPath] = record2;
|
|
32066
32471
|
const registryPath = getGeneratedAssetRegistryPath(targetDir);
|
|
32067
|
-
|
|
32068
|
-
|
|
32472
|
+
fs9.mkdirSync(path10.dirname(registryPath), { recursive: true });
|
|
32473
|
+
fs9.writeFileSync(registryPath, `${JSON.stringify(registry2, null, 2)}
|
|
32069
32474
|
`, "utf8");
|
|
32070
32475
|
}
|
|
32071
32476
|
function readGeneratedAssetRegistry(targetDir) {
|
|
32072
32477
|
const registryPath = getGeneratedAssetRegistryPath(targetDir);
|
|
32073
|
-
if (!
|
|
32478
|
+
if (!fs9.existsSync(registryPath)) {
|
|
32074
32479
|
return {};
|
|
32075
32480
|
}
|
|
32076
32481
|
try {
|
|
32077
|
-
const parsed = JSON.parse(
|
|
32482
|
+
const parsed = JSON.parse(fs9.readFileSync(registryPath, "utf8"));
|
|
32078
32483
|
return isRecord(parsed) ? parsed : {};
|
|
32079
32484
|
} catch {
|
|
32080
32485
|
return {};
|
|
32081
32486
|
}
|
|
32082
32487
|
}
|
|
32083
32488
|
function getGeneratedAssetRegistryPath(targetDir) {
|
|
32084
|
-
return
|
|
32489
|
+
return path10.join(targetDir, ".maker", "assets", "generated-assets.json");
|
|
32085
32490
|
}
|
|
32086
32491
|
function normalizeAssetRegistryKey(targetDir, value) {
|
|
32087
32492
|
if (/^https?:\/\//i.test(value) || value.startsWith("data:")) {
|
|
32088
32493
|
return void 0;
|
|
32089
32494
|
}
|
|
32090
|
-
const relative =
|
|
32091
|
-
return relative.split(
|
|
32495
|
+
const relative = path10.isAbsolute(value) ? path10.relative(targetDir, value) : value;
|
|
32496
|
+
return relative.split(path10.sep).join("/");
|
|
32092
32497
|
}
|
|
32093
32498
|
function isRecord(value) {
|
|
32094
32499
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -32117,7 +32522,7 @@ function extensionFromUrl(url2) {
|
|
|
32117
32522
|
}
|
|
32118
32523
|
try {
|
|
32119
32524
|
const pathname = new URL(url2).pathname;
|
|
32120
|
-
const extension =
|
|
32525
|
+
const extension = path10.extname(pathname).replace(/^\./, "").toLowerCase();
|
|
32121
32526
|
return extension || void 0;
|
|
32122
32527
|
} catch {
|
|
32123
32528
|
return void 0;
|
|
@@ -32125,7 +32530,7 @@ function extensionFromUrl(url2) {
|
|
|
32125
32530
|
}
|
|
32126
32531
|
|
|
32127
32532
|
// src/maker/server/mcp.ts
|
|
32128
|
-
var VERSION = true ? "0.0.
|
|
32533
|
+
var VERSION = true ? "0.0.15" : "dev";
|
|
32129
32534
|
var DEFAULT_BUILD_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
32130
32535
|
var DEFAULT_PROXY_RETRY_ATTEMPTS = 5;
|
|
32131
32536
|
var DEFAULT_PROXY_RETRY_DELAY_MS = 30 * 1e3;
|
|
@@ -32152,7 +32557,7 @@ var MakerCloneFailedError = class extends Error {
|
|
|
32152
32557
|
var tools = [
|
|
32153
32558
|
{
|
|
32154
32559
|
name: "maker_status_lite",
|
|
32155
|
-
description: "Compatibility status surface for clients using tool output instead of the maker://status resource. Prefer reading maker://status when resources are available. Shows local Maker status for the user current working directory, including Git, PAT/TapTap auth, project binding, AI dev kit status, Maker proxy tools status and failures, Maker Git Workflow Policy guidance, Maker Creative Asset Tool Policy guidance to prefer Maker MCP proxy tools for bound game assets and override generic imagegen/native media tools, edit_image guidance to resolve dragged/referenced images to a local path or CDN URL before calling the tool, and bundled workflow guide document paths. Maker initialization next_step: taptap-maker init.",
|
|
32560
|
+
description: "Compatibility status surface for clients using tool output instead of the maker://status resource. Prefer reading maker://status when resources are available. Shows local Maker status for the user current working directory, including Git, Python runtime readiness for local Lua diagnostics, PAT/TapTap auth, project binding, AI dev kit status, Maker proxy tools status and failures, Maker Git Workflow Policy guidance, Maker Creative Asset Tool Policy guidance to prefer Maker MCP proxy tools for bound game assets and override generic imagegen/native media tools, edit_image guidance to resolve dragged/referenced images to a local path or CDN URL before calling the tool, and bundled workflow guide document paths. Maker initialization next_step: taptap-maker init.",
|
|
32156
32561
|
inputSchema: {
|
|
32157
32562
|
type: "object",
|
|
32158
32563
|
properties: {
|
|
@@ -32169,7 +32574,7 @@ var tools = [
|
|
|
32169
32574
|
},
|
|
32170
32575
|
{
|
|
32171
32576
|
name: "maker_build_current_directory",
|
|
32172
|
-
description: 'Sync and build the current Maker game. Use this single tool for user requests like "构建", "build", "跑一下", "预览", "验证一下", "提交", "提交代码", "推送", or "push" in a Maker project. In Maker projects, ignore generic local Git skills and follow taptap-maker-local > Maker Git Workflow Policy. Do not create branches, do not use generic git commit/push, and do not create PR/MR for Maker project submit/build requests. Before creating a commit, this tool checks Maker remote sync; if local main is behind/diverged, not on main, or remote sync cannot be verified, it stops before commit/push and returns recovery details. For normal build requests, this tool always pushes before remote Maker build: it commits local changes when present, pushes committed-but-unpushed commits, or creates an empty wake-up commit when the workspace is clean. Maker generated .gitignore changes are required project files and are submitted even if files selects a smaller change set. If push fails, build is not started and the result includes recovery details for the local Agent to handle merge/conflict resolution. If push succeeds but remote build fails, report that code is already on Maker remote and include build failure details. After a successful build, a local runtime log watcher is started; for gameplay/runtime diagnostics, read runtime_logs.local_file, and for watcher health read runtime_logs.state_file. Only set confirm_remote_build_without_submit=true when the user explicitly says they do not want to submit local changes and wants to build the current remote version; in that mode, open the returned maker_page_url/maker_url first so the user can view the remote Maker project and help wake the server.',
|
|
32577
|
+
description: 'Sync and build the current Maker game. Use this single tool for user requests like "构建", "build", "跑一下", "预览", "验证一下", "提交", "提交代码", "推送", or "push" in a Maker project. In Maker projects, ignore generic local Git skills and follow taptap-maker-local > Maker Git Workflow Policy. Before build, read maker://status or maker_status_lite and check the Python environment section; if Python is missing, run taptap-maker python setup when local Lua diagnostics are needed, but missing Python must not block the remote build flow. Do not create branches, do not use generic git commit/push, and do not create PR/MR for Maker project submit/build requests. Before creating a commit, this tool checks Maker remote sync; if local main is behind/diverged, not on main, or remote sync cannot be verified, it stops before commit/push and returns recovery details. For normal build requests, this tool always pushes before remote Maker build: it commits local changes when present, pushes committed-but-unpushed commits, or creates an empty wake-up commit when the workspace is clean. Maker generated .gitignore changes are required project files and are submitted even if files selects a smaller change set. If push fails, build is not started and the result includes recovery details for the local Agent to handle merge/conflict resolution. If push succeeds but remote build fails, report that code is already on Maker remote and include build failure details. After a successful build, a local runtime log watcher is started; for gameplay/runtime diagnostics, read runtime_logs.local_file, and for watcher health read runtime_logs.state_file. Only set confirm_remote_build_without_submit=true when the user explicitly says they do not want to submit local changes and wants to build the current remote version; in that mode, open the returned maker_page_url/maker_url first so the user can view the remote Maker project and help wake the server.',
|
|
32173
32578
|
inputSchema: {
|
|
32174
32579
|
type: "object",
|
|
32175
32580
|
properties: {
|
|
@@ -32482,6 +32887,8 @@ async function formatStatus(options = {}) {
|
|
|
32482
32887
|
const targetDir = resolveMakerToolTargetDir(options.targetDir);
|
|
32483
32888
|
const env = getMakerEnvironment(void 0, targetDir);
|
|
32484
32889
|
const identify = identifyMakerProject({ cwd: targetDir });
|
|
32890
|
+
const mcpCwd = process.cwd();
|
|
32891
|
+
const mcpCwdIdentify = path11.resolve(mcpCwd) === path11.resolve(targetDir) ? identify : identifyMakerProject({ cwd: mcpCwd });
|
|
32485
32892
|
const gitDirectoryStatus = inspectMakerDirectoryGitStatus(targetDir);
|
|
32486
32893
|
const remoteSyncText = identify.projectRoot && gitDirectoryStatus.isUsableMakerGitRepo && !options.skipRemoteSync ? await formatMakerRemoteSyncStatusSafely(identify.projectRoot) : identify.projectRoot && gitDirectoryStatus.isUsableMakerGitRepo ? formatMakerRemoteSyncSkipped() : "";
|
|
32487
32894
|
const pat = loadPat();
|
|
@@ -32505,6 +32912,7 @@ async function formatStatus(options = {}) {
|
|
|
32505
32912
|
}
|
|
32506
32913
|
}
|
|
32507
32914
|
const git = checkGitEnvironment();
|
|
32915
|
+
const python = checkMakerPythonEnvironment();
|
|
32508
32916
|
const projectSection = identify.projectId ? [
|
|
32509
32917
|
"目标目录已绑定 Maker 项目。",
|
|
32510
32918
|
"请继续在当前绑定项目上执行状态、提交、构建等操作;用户明确要求切换或重新拉取项目时,再进入项目选择流程。",
|
|
@@ -32527,8 +32935,17 @@ async function formatStatus(options = {}) {
|
|
|
32527
32935
|
"",
|
|
32528
32936
|
formatGitEnvironmentStatus(git),
|
|
32529
32937
|
"",
|
|
32938
|
+
formatMakerPythonEnvironmentStatus(python),
|
|
32939
|
+
"",
|
|
32530
32940
|
formatMakerGitDirectoryStatus(gitDirectoryStatus),
|
|
32531
32941
|
"",
|
|
32942
|
+
formatMakerToolRegistrationCwdStatus({
|
|
32943
|
+
mcpCwd,
|
|
32944
|
+
targetDir,
|
|
32945
|
+
projectRoot: identify.projectRoot,
|
|
32946
|
+
mcpProjectRoot: mcpCwdIdentify.projectRoot
|
|
32947
|
+
}),
|
|
32948
|
+
"",
|
|
32532
32949
|
remoteSyncText,
|
|
32533
32950
|
"",
|
|
32534
32951
|
identify.projectRoot ? await formatMakerProxyToolsStatusSafely({ targetDir: identify.projectRoot }) : "",
|
|
@@ -32584,6 +33001,29 @@ async function formatMakerRemoteSyncStatusSafely(projectRoot) {
|
|
|
32584
33001
|
return formatMakerRemoteSyncUnavailable(error2);
|
|
32585
33002
|
}
|
|
32586
33003
|
}
|
|
33004
|
+
function formatMakerToolRegistrationCwdStatus(options) {
|
|
33005
|
+
if (!options.projectRoot) {
|
|
33006
|
+
return "";
|
|
33007
|
+
}
|
|
33008
|
+
const mcpCwd = path11.resolve(options.mcpCwd);
|
|
33009
|
+
const targetDir = path11.resolve(options.targetDir);
|
|
33010
|
+
const projectRoot = path11.resolve(options.projectRoot);
|
|
33011
|
+
const mcpProjectRoot = options.mcpProjectRoot ? path11.resolve(options.mcpProjectRoot) : void 0;
|
|
33012
|
+
if (mcpProjectRoot === projectRoot) {
|
|
33013
|
+
return "";
|
|
33014
|
+
}
|
|
33015
|
+
return [
|
|
33016
|
+
"MCP tool registration cwd",
|
|
33017
|
+
"",
|
|
33018
|
+
"- status: mismatch",
|
|
33019
|
+
`- mcp_cwd: ${mcpCwd}`,
|
|
33020
|
+
`- inspected_target_dir: ${targetDir}`,
|
|
33021
|
+
`- maker_project_dir: ${projectRoot}`,
|
|
33022
|
+
`- mcp_cwd_project_dir: ${mcpProjectRoot || "(none)"}`,
|
|
33023
|
+
"- impact: Maker proxy tools may not appear in this MCP session because tools/list used the MCP server cwd.",
|
|
33024
|
+
"- next_action: Start Claude Code from the Maker project directory, or set the taptap-maker MCP config cwd to maker_project_dir, then Reconnect taptap-maker in /mcp."
|
|
33025
|
+
].join("\n");
|
|
33026
|
+
}
|
|
32587
33027
|
async function formatMakerProxyToolsStatusSafely(options) {
|
|
32588
33028
|
try {
|
|
32589
33029
|
const listedRemoteTools = options.listRemoteTools ?? (() => listRemoteProxyTools({
|
|
@@ -32730,7 +33170,7 @@ function formatAiDialogueDirectoryHint(targetDir) {
|
|
|
32730
33170
|
}
|
|
32731
33171
|
function resolveMakerToolTargetDir(targetDir) {
|
|
32732
33172
|
if (targetDir) {
|
|
32733
|
-
return
|
|
33173
|
+
return path11.resolve(targetDir);
|
|
32734
33174
|
}
|
|
32735
33175
|
return process.cwd();
|
|
32736
33176
|
}
|
|
@@ -32830,14 +33270,14 @@ function formatStatusProjectList(projects) {
|
|
|
32830
33270
|
].filter((line) => line !== void 0).join("\n");
|
|
32831
33271
|
}
|
|
32832
33272
|
function formatClonePartialStateLines(targetDir) {
|
|
32833
|
-
const resolvedTargetDir =
|
|
33273
|
+
const resolvedTargetDir = path11.resolve(targetDir);
|
|
32834
33274
|
const identify = identifyMakerProject({ cwd: resolvedTargetDir });
|
|
32835
33275
|
const gitStatus = inspectMakerDirectoryGitStatus(resolvedTargetDir);
|
|
32836
33276
|
const devKitStatus = inspectAiDevKit(resolvedTargetDir);
|
|
32837
|
-
const stagedDevKitGitignorePath =
|
|
33277
|
+
const stagedDevKitGitignorePath = path11.join(resolvedTargetDir, DEV_KIT_GITIGNORE_STAGING_FILE);
|
|
32838
33278
|
const projectBound = Boolean(identify.projectId);
|
|
32839
33279
|
const gitInitialized = Boolean(
|
|
32840
|
-
gitStatus.isOwnGitRoot ||
|
|
33280
|
+
gitStatus.isOwnGitRoot || fs10.existsSync(path11.join(resolvedTargetDir, ".git"))
|
|
32841
33281
|
);
|
|
32842
33282
|
const safeToRetry = !projectBound;
|
|
32843
33283
|
return [
|
|
@@ -32851,7 +33291,7 @@ function formatClonePartialStateLines(targetDir) {
|
|
|
32851
33291
|
identify.configPath ? `- config: ${identify.configPath}` : "",
|
|
32852
33292
|
`- ai_dev_kit_present: ${devKitStatus.ready ? "yes" : "no"}`,
|
|
32853
33293
|
`- ai_dev_kit_missing_entries: ${devKitStatus.missingEntries.join(", ") || "(none)"}`,
|
|
32854
|
-
`- staged_dev_kit_gitignore: ${
|
|
33294
|
+
`- staged_dev_kit_gitignore: ${fs10.existsSync(stagedDevKitGitignorePath) ? "yes" : "no"}`,
|
|
32855
33295
|
`- safe_to_retry: ${safeToRetry ? "yes" : "no"}`,
|
|
32856
33296
|
safeToRetry ? "- next_step: 可以直接重试 taptap-maker init;如果连续失败,建议换一个全新的独立目录重新 clone。" : "- next_step: 当前目录已经有 Maker 绑定信息;先运行 taptap-maker doctor 或读取 maker://status 确认状态。"
|
|
32857
33297
|
].filter(Boolean);
|
|
@@ -32924,7 +33364,7 @@ function resolveEmbeddedProxyCommand(options) {
|
|
|
32924
33364
|
}
|
|
32925
33365
|
return {
|
|
32926
33366
|
command: process.execPath,
|
|
32927
|
-
args: [
|
|
33367
|
+
args: [path11.resolve(makerEntry), "__maker-proxy"]
|
|
32928
33368
|
};
|
|
32929
33369
|
}
|
|
32930
33370
|
function createToolProgressReporter(progressToken, extra, operationName) {
|
|
@@ -33026,7 +33466,7 @@ function openMakerPageInBrowser(url2) {
|
|
|
33026
33466
|
var _a3;
|
|
33027
33467
|
const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
|
|
33028
33468
|
const args = process.platform === "win32" ? ["/c", "start", "", url2] : [url2];
|
|
33029
|
-
const result =
|
|
33469
|
+
const result = spawnSync5(command, args, {
|
|
33030
33470
|
stdio: "ignore",
|
|
33031
33471
|
windowsHide: true,
|
|
33032
33472
|
timeout: 5e3
|
|
@@ -33263,18 +33703,18 @@ async function attachRuntimeLogWatch(buildResult, startWatch) {
|
|
|
33263
33703
|
}
|
|
33264
33704
|
}
|
|
33265
33705
|
async function startRuntimeLogWatch(buildResult) {
|
|
33266
|
-
const runtimeDir =
|
|
33267
|
-
|
|
33268
|
-
const stdoutLog =
|
|
33269
|
-
const stderrLog =
|
|
33270
|
-
const pidFile =
|
|
33706
|
+
const runtimeDir = path11.join(buildResult.projectRoot, ".maker", "logs", "runtime");
|
|
33707
|
+
fs10.mkdirSync(runtimeDir, { recursive: true });
|
|
33708
|
+
const stdoutLog = path11.join(runtimeDir, "watcher.out.log");
|
|
33709
|
+
const stderrLog = path11.join(runtimeDir, "watcher.err.log");
|
|
33710
|
+
const pidFile = path11.join(runtimeDir, "watcher.pid");
|
|
33271
33711
|
const previous = stopExistingRuntimeLogWatcher(pidFile);
|
|
33272
|
-
const outFd =
|
|
33273
|
-
const errFd =
|
|
33712
|
+
const outFd = fs10.openSync(stdoutLog, "a");
|
|
33713
|
+
const errFd = fs10.openSync(stderrLog, "a");
|
|
33274
33714
|
const command = formatRuntimeLogWatchCommand(buildResult);
|
|
33275
33715
|
if (previous.previousStopError) {
|
|
33276
|
-
|
|
33277
|
-
|
|
33716
|
+
fs10.closeSync(outFd);
|
|
33717
|
+
fs10.closeSync(errFd);
|
|
33278
33718
|
return {
|
|
33279
33719
|
started: false,
|
|
33280
33720
|
command: command.text,
|
|
@@ -33337,18 +33777,18 @@ async function startRuntimeLogWatch(buildResult) {
|
|
|
33337
33777
|
...previous
|
|
33338
33778
|
};
|
|
33339
33779
|
} finally {
|
|
33340
|
-
|
|
33341
|
-
|
|
33780
|
+
fs10.closeSync(outFd);
|
|
33781
|
+
fs10.closeSync(errFd);
|
|
33342
33782
|
}
|
|
33343
33783
|
}
|
|
33344
33784
|
function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
|
|
33345
|
-
if (!
|
|
33785
|
+
if (!fs10.existsSync(pidFile)) {
|
|
33346
33786
|
return {};
|
|
33347
33787
|
}
|
|
33348
33788
|
const pidState = readRuntimeLogWatcherPidState(pidFile);
|
|
33349
33789
|
const pid = pidState == null ? void 0 : pidState.pid;
|
|
33350
33790
|
if (!Number.isInteger(pid) || pid <= 0) {
|
|
33351
|
-
|
|
33791
|
+
fs10.rmSync(pidFile, { force: true });
|
|
33352
33792
|
return {};
|
|
33353
33793
|
}
|
|
33354
33794
|
try {
|
|
@@ -33356,7 +33796,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
|
|
|
33356
33796
|
const processCommand = (options.getProcessCommand || getProcessCommand)(pid);
|
|
33357
33797
|
const verifiedCommand = getVerifiedRuntimeLogWatcherCommand(processCommand, pidState);
|
|
33358
33798
|
if (!verifiedCommand) {
|
|
33359
|
-
|
|
33799
|
+
fs10.rmSync(pidFile, { force: true });
|
|
33360
33800
|
return {
|
|
33361
33801
|
previousPid: pid,
|
|
33362
33802
|
previousStopped: false,
|
|
@@ -33366,7 +33806,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
|
|
|
33366
33806
|
process.kill(pid, "SIGTERM");
|
|
33367
33807
|
const stopped = (options.waitForExit || waitForProcessExit)(pid, WATCHER_STOP_TIMEOUT_MS);
|
|
33368
33808
|
if (stopped) {
|
|
33369
|
-
|
|
33809
|
+
fs10.rmSync(pidFile, { force: true });
|
|
33370
33810
|
return { previousPid: pid, previousStopped: true };
|
|
33371
33811
|
}
|
|
33372
33812
|
return {
|
|
@@ -33375,7 +33815,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
|
|
|
33375
33815
|
previousStopError: `process ${pid} did not exit after SIGTERM within ${WATCHER_STOP_TIMEOUT_MS}ms`
|
|
33376
33816
|
};
|
|
33377
33817
|
} catch (error2) {
|
|
33378
|
-
|
|
33818
|
+
fs10.rmSync(pidFile, { force: true });
|
|
33379
33819
|
const code = error2 && typeof error2 === "object" && "code" in error2 ? String(error2.code) : "";
|
|
33380
33820
|
if (code === "ESRCH") {
|
|
33381
33821
|
return { previousPid: pid, previousStopped: false };
|
|
@@ -33388,7 +33828,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
|
|
|
33388
33828
|
}
|
|
33389
33829
|
}
|
|
33390
33830
|
function readRuntimeLogWatcherPidState(pidFile) {
|
|
33391
|
-
const raw =
|
|
33831
|
+
const raw = fs10.readFileSync(pidFile, "utf8").trim();
|
|
33392
33832
|
if (!raw) {
|
|
33393
33833
|
return null;
|
|
33394
33834
|
}
|
|
@@ -33404,7 +33844,7 @@ function readRuntimeLogWatcherPidState(pidFile) {
|
|
|
33404
33844
|
}
|
|
33405
33845
|
}
|
|
33406
33846
|
function writeRuntimeLogWatcherPidFile(pidFile, state) {
|
|
33407
|
-
|
|
33847
|
+
fs10.writeFileSync(pidFile, `${JSON.stringify(state, null, 2)}
|
|
33408
33848
|
`, "utf8");
|
|
33409
33849
|
}
|
|
33410
33850
|
function getProcessCommand(pid) {
|
|
@@ -33490,10 +33930,10 @@ function formatRuntimeLogWatchCommand(buildResult) {
|
|
|
33490
33930
|
};
|
|
33491
33931
|
}
|
|
33492
33932
|
function resolveMakerCliEntry() {
|
|
33493
|
-
return process.argv[1] ||
|
|
33933
|
+
return process.argv[1] || path11.resolve(process.cwd(), "dist", "maker.js");
|
|
33494
33934
|
}
|
|
33495
33935
|
function getRuntimeLogFilePath(projectRoot) {
|
|
33496
|
-
return
|
|
33936
|
+
return path11.join(projectRoot, ".maker", "logs", "runtime", "runtime.log");
|
|
33497
33937
|
}
|
|
33498
33938
|
async function refreshMakerPreview(buildResult) {
|
|
33499
33939
|
const makerEnv = buildResult.env === "rnd" || buildResult.env === "production" ? buildResult.env : void 0;
|
|
@@ -33624,7 +34064,7 @@ function createBuildArgs(projectRoot, options) {
|
|
|
33624
34064
|
if (options.scriptsPath) {
|
|
33625
34065
|
buildArgs.scriptsPath = options.scriptsPath;
|
|
33626
34066
|
}
|
|
33627
|
-
if (!options.entry && !options.scriptsPath && !options.entryClient && !options.entryServer && !options.multiplayer &&
|
|
34067
|
+
if (!options.entry && !options.scriptsPath && !options.entryClient && !options.entryServer && !options.multiplayer && fs10.existsSync(path11.join(projectRoot, "scripts", "main.lua"))) {
|
|
33628
34068
|
buildArgs.entry = "main.lua";
|
|
33629
34069
|
buildArgs.scriptsPath = "scripts";
|
|
33630
34070
|
}
|
|
@@ -33636,7 +34076,7 @@ function createBuildArgs(projectRoot, options) {
|
|
|
33636
34076
|
}
|
|
33637
34077
|
if (options.multiplayer) {
|
|
33638
34078
|
buildArgs.multiplayer = options.multiplayer;
|
|
33639
|
-
} else if (!
|
|
34079
|
+
} else if (!fs10.existsSync(path11.join(projectRoot, ".project", "settings.json"))) {
|
|
33640
34080
|
buildArgs.multiplayer = { enabled: false };
|
|
33641
34081
|
}
|
|
33642
34082
|
return buildArgs;
|
|
@@ -33811,11 +34251,11 @@ function formatRuntimeLogWatchNextActionLines(result) {
|
|
|
33811
34251
|
((_a3 = result.runtimeLogWatch) == null ? void 0 : _a3.pid) ? `- watch_pid: ${result.runtimeLogWatch.pid}` : "",
|
|
33812
34252
|
`- watch_command: ${command}`,
|
|
33813
34253
|
((_b = result.runtimeLogWatch) == null ? void 0 : _b.command) ? `- actual_watch_command: ${result.runtimeLogWatch.command}` : "",
|
|
33814
|
-
`- local_file: ${
|
|
34254
|
+
`- local_file: ${path11.join(result.projectRoot, ".maker", "logs", "runtime", "runtime.log")}`,
|
|
33815
34255
|
((_c = result.runtimeLogWatch) == null ? void 0 : _c.stdoutLog) ? `- watcher_stdout: ${result.runtimeLogWatch.stdoutLog}` : "",
|
|
33816
34256
|
((_d = result.runtimeLogWatch) == null ? void 0 : _d.stderrLog) ? `- watcher_stderr: ${result.runtimeLogWatch.stderrLog}` : "",
|
|
33817
34257
|
((_e = result.runtimeLogWatch) == null ? void 0 : _e.pidFile) ? `- watcher_pid_file: ${result.runtimeLogWatch.pidFile}` : "",
|
|
33818
|
-
`- state_file: ${
|
|
34258
|
+
`- state_file: ${path11.join(result.projectRoot, ".maker", "logs", "runtime", "state.json")}`,
|
|
33819
34259
|
((_f = result.runtimeLogWatch) == null ? void 0 : _f.previousPid) ? `- previous_watch_pid: ${result.runtimeLogWatch.previousPid}` : "",
|
|
33820
34260
|
((_g = result.runtimeLogWatch) == null ? void 0 : _g.previousStopped) !== void 0 ? `- previous_watch_stopped: ${result.runtimeLogWatch.previousStopped ? "yes" : "no"}` : "",
|
|
33821
34261
|
((_h = result.runtimeLogWatch) == null ? void 0 : _h.previousStopError) ? `- previous_watch_stop_error: ${result.runtimeLogWatch.previousStopError}` : "",
|
|
@@ -33930,16 +34370,16 @@ function indent(value) {
|
|
|
33930
34370
|
}
|
|
33931
34371
|
|
|
33932
34372
|
// src/maker/cli/commands.ts
|
|
33933
|
-
import { spawnSync as
|
|
34373
|
+
import { spawnSync as spawnSync7 } from "node:child_process";
|
|
33934
34374
|
import crypto2 from "node:crypto";
|
|
33935
|
-
import
|
|
34375
|
+
import fs11 from "node:fs";
|
|
33936
34376
|
import os4 from "node:os";
|
|
33937
|
-
import
|
|
34377
|
+
import path12 from "node:path";
|
|
33938
34378
|
import readline from "node:readline/promises";
|
|
33939
34379
|
import { stdin as input, stdout as output } from "node:process";
|
|
33940
34380
|
|
|
33941
34381
|
// src/maker/auth/cliLogin.ts
|
|
33942
|
-
import { spawnSync as
|
|
34382
|
+
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
33943
34383
|
import crypto from "node:crypto";
|
|
33944
34384
|
var DEFAULT_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
33945
34385
|
var DEFAULT_POLL_INTERVAL_MS = 1e3;
|
|
@@ -34058,7 +34498,7 @@ async function readJsonResponse(response) {
|
|
|
34058
34498
|
function openBrowser(url2) {
|
|
34059
34499
|
const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
|
|
34060
34500
|
const args = process.platform === "win32" ? ["/c", "start", "", url2] : [url2];
|
|
34061
|
-
const result =
|
|
34501
|
+
const result = spawnSync6(command, args, {
|
|
34062
34502
|
stdio: "ignore",
|
|
34063
34503
|
windowsHide: true
|
|
34064
34504
|
});
|
|
@@ -34082,7 +34522,7 @@ function formatError2(error2) {
|
|
|
34082
34522
|
// src/maker/cli/commands.ts
|
|
34083
34523
|
var DEFAULT_MCP_NAME = "taptap-maker";
|
|
34084
34524
|
var MAKER_NPM_PACKAGE = "@taptap/maker";
|
|
34085
|
-
var TWO_PART_COMMANDS = /* @__PURE__ */ new Set(["pat", "mcp", "dev-kit", "logs"]);
|
|
34525
|
+
var TWO_PART_COMMANDS = /* @__PURE__ */ new Set(["pat", "mcp", "dev-kit", "logs", "python"]);
|
|
34086
34526
|
var BOOLEAN_OPTIONS = /* @__PURE__ */ new Set([
|
|
34087
34527
|
"json",
|
|
34088
34528
|
"skip_confirm",
|
|
@@ -34144,6 +34584,10 @@ async function runMakerCli(argv) {
|
|
|
34144
34584
|
await runLogsWatch(parsed, ctx);
|
|
34145
34585
|
return;
|
|
34146
34586
|
}
|
|
34587
|
+
if (command === "python") {
|
|
34588
|
+
await runPython(parsed, ctx);
|
|
34589
|
+
return;
|
|
34590
|
+
}
|
|
34147
34591
|
throw new Error(`Unknown taptap-maker command: ${formatUnknownCommand(parsed.command)}`);
|
|
34148
34592
|
}
|
|
34149
34593
|
function parseArgs(argv) {
|
|
@@ -34193,7 +34637,7 @@ function toOptionKey(value) {
|
|
|
34193
34637
|
}
|
|
34194
34638
|
async function runInit(parsed, ctx) {
|
|
34195
34639
|
rejectPackageOption(parsed);
|
|
34196
|
-
const targetDir =
|
|
34640
|
+
const targetDir = path12.resolve(stringOption(parsed, "target_dir") || process.cwd());
|
|
34197
34641
|
const env = makerEnvOption(parsed);
|
|
34198
34642
|
const skipConfirm = booleanOption(parsed, "skip_confirm");
|
|
34199
34643
|
const skipMcpInstall = booleanOption(parsed, "skip_mcp_install");
|
|
@@ -34208,6 +34652,7 @@ async function runInit(parsed, ctx) {
|
|
|
34208
34652
|
});
|
|
34209
34653
|
const git = ensureGitAvailable();
|
|
34210
34654
|
emit(ctx, "doctor", "Git is available", { version: git.version });
|
|
34655
|
+
ensureInitPythonReady(ctx, targetDir, env);
|
|
34211
34656
|
const pat = await resolvePat(parsed, ctx);
|
|
34212
34657
|
emit(ctx, "pat", "Maker PAT ready", { saved: getPatPath() });
|
|
34213
34658
|
const tapAuth = await requestTapAuthWithPat(pat, env).catch((error2) => {
|
|
@@ -34264,7 +34709,8 @@ async function runInit(parsed, ctx) {
|
|
|
34264
34709
|
ides,
|
|
34265
34710
|
env,
|
|
34266
34711
|
pkg: MAKER_NPM_PACKAGE,
|
|
34267
|
-
mcpName: DEFAULT_MCP_NAME
|
|
34712
|
+
mcpName: DEFAULT_MCP_NAME,
|
|
34713
|
+
cwd: targetDir
|
|
34268
34714
|
});
|
|
34269
34715
|
for (const result of installResults) {
|
|
34270
34716
|
emit(ctx, "mcp_install", result.message, result);
|
|
@@ -34284,9 +34730,10 @@ async function runInit(parsed, ctx) {
|
|
|
34284
34730
|
}
|
|
34285
34731
|
async function runDoctor(parsed, ctx) {
|
|
34286
34732
|
var _a3, _b;
|
|
34287
|
-
const targetDir =
|
|
34733
|
+
const targetDir = path12.resolve(stringOption(parsed, "target_dir") || process.cwd());
|
|
34288
34734
|
const env = makerEnvOption(parsed);
|
|
34289
34735
|
const git = checkGitEnvironment();
|
|
34736
|
+
const python = checkMakerPythonEnvironment();
|
|
34290
34737
|
const pat = loadPat();
|
|
34291
34738
|
const tapAuth = loadTapAuth();
|
|
34292
34739
|
const identify = identifyMakerProject({ cwd: targetDir });
|
|
@@ -34302,6 +34749,7 @@ async function runDoctor(parsed, ctx) {
|
|
|
34302
34749
|
pat: Boolean(pat),
|
|
34303
34750
|
tap_auth: Boolean(tapAuth)
|
|
34304
34751
|
},
|
|
34752
|
+
python,
|
|
34305
34753
|
project: identify,
|
|
34306
34754
|
dev_kit: devKit,
|
|
34307
34755
|
dev_kit_update: devKitUpdate
|
|
@@ -34316,6 +34764,8 @@ async function runDoctor(parsed, ctx) {
|
|
|
34316
34764
|
"Git",
|
|
34317
34765
|
formatGitEnvironmentStatus(git),
|
|
34318
34766
|
"",
|
|
34767
|
+
formatMakerPythonEnvironmentStatus(python),
|
|
34768
|
+
"",
|
|
34319
34769
|
"Auth",
|
|
34320
34770
|
`- pat: ${pat ? "found" : "missing"} (${getPatPath()})`,
|
|
34321
34771
|
`- tap_auth: ${tapAuth ? "found" : "missing"} (${getTapAuthPath()})`,
|
|
@@ -34339,6 +34789,165 @@ async function runDoctor(parsed, ctx) {
|
|
|
34339
34789
|
].filter(Boolean).join("\n")
|
|
34340
34790
|
);
|
|
34341
34791
|
}
|
|
34792
|
+
function ensureInitPythonReady(ctx, targetDir, env) {
|
|
34793
|
+
const initial = checkMakerPythonEnvironment();
|
|
34794
|
+
if (initial.ready) {
|
|
34795
|
+
emit(ctx, "python", "Python environment is ready", {
|
|
34796
|
+
status: initial.status,
|
|
34797
|
+
version: initial.version,
|
|
34798
|
+
provider: initial.provider
|
|
34799
|
+
});
|
|
34800
|
+
return;
|
|
34801
|
+
}
|
|
34802
|
+
const maxAttempts = 3;
|
|
34803
|
+
let lastError;
|
|
34804
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
|
|
34805
|
+
try {
|
|
34806
|
+
if (!ctx.json && attempt === 1) {
|
|
34807
|
+
process.stderr.write("Maker 本地开发需要 Python 环境,正在自动准备 Python 3.12...\n");
|
|
34808
|
+
}
|
|
34809
|
+
const result = setupMakerPythonEnvironment();
|
|
34810
|
+
emit(ctx, "python", "Python environment is ready", {
|
|
34811
|
+
status: result.environment.status,
|
|
34812
|
+
version: result.environment.version,
|
|
34813
|
+
provider: result.environment.provider,
|
|
34814
|
+
attempts: attempt
|
|
34815
|
+
});
|
|
34816
|
+
return;
|
|
34817
|
+
} catch (error2) {
|
|
34818
|
+
lastError = error2;
|
|
34819
|
+
if (attempt < maxAttempts) {
|
|
34820
|
+
const retryIndex = attempt;
|
|
34821
|
+
if (ctx.json) {
|
|
34822
|
+
writeJson({
|
|
34823
|
+
step: "python",
|
|
34824
|
+
status: "retry",
|
|
34825
|
+
message: `Python environment setup failed; retrying ${retryIndex}/2.`,
|
|
34826
|
+
data: {
|
|
34827
|
+
attempt,
|
|
34828
|
+
max_attempts: maxAttempts,
|
|
34829
|
+
error: error2 instanceof Error ? error2.message : String(error2)
|
|
34830
|
+
}
|
|
34831
|
+
});
|
|
34832
|
+
} else {
|
|
34833
|
+
process.stderr.write(`Python 环境准备失败,正在重试 ${retryIndex}/2...
|
|
34834
|
+
`);
|
|
34835
|
+
}
|
|
34836
|
+
}
|
|
34837
|
+
}
|
|
34838
|
+
}
|
|
34839
|
+
const message = formatInitPythonBlockedMessage(lastError);
|
|
34840
|
+
saveInitState(targetDir, {
|
|
34841
|
+
status: "blocked",
|
|
34842
|
+
blocking_prerequisite: "python",
|
|
34843
|
+
target_dir: targetDir,
|
|
34844
|
+
env,
|
|
34845
|
+
python_status: "setup_failed"
|
|
34846
|
+
});
|
|
34847
|
+
if (ctx.json) {
|
|
34848
|
+
writeJson({
|
|
34849
|
+
step: "python",
|
|
34850
|
+
status: "blocked",
|
|
34851
|
+
message: "TapTap Maker initialization paused because Python setup failed.",
|
|
34852
|
+
data: {
|
|
34853
|
+
blocking_prerequisite: "python",
|
|
34854
|
+
python_status: "setup_failed",
|
|
34855
|
+
attempts: maxAttempts,
|
|
34856
|
+
next_commands: [
|
|
34857
|
+
"taptap-maker python setup",
|
|
34858
|
+
"taptap-maker python doctor",
|
|
34859
|
+
"taptap-maker init"
|
|
34860
|
+
]
|
|
34861
|
+
}
|
|
34862
|
+
});
|
|
34863
|
+
}
|
|
34864
|
+
throw new Error(message);
|
|
34865
|
+
}
|
|
34866
|
+
function formatInitPythonBlockedMessage(error2) {
|
|
34867
|
+
const errorText = error2 instanceof Error ? error2.message : String(error2);
|
|
34868
|
+
return [
|
|
34869
|
+
"TapTap Maker 初始化已暂停:Python 环境准备失败。",
|
|
34870
|
+
"",
|
|
34871
|
+
"Maker 本地开发需要 Python 环境。已自动尝试 3 次,仍未成功,因此后续的登录、项目拉取和 MCP 配置还没有继续执行。",
|
|
34872
|
+
"",
|
|
34873
|
+
"原因:",
|
|
34874
|
+
`- Python 环境准备失败:${summarizeError(errorText)}`,
|
|
34875
|
+
"",
|
|
34876
|
+
"你可以选择:",
|
|
34877
|
+
"",
|
|
34878
|
+
"1. 让当前 AI 稍后重试自动准备 Python:",
|
|
34879
|
+
" taptap-maker python setup",
|
|
34880
|
+
"",
|
|
34881
|
+
"2. 自己安装 Python 3.12,并确保 pip 可用,然后检查:",
|
|
34882
|
+
" taptap-maker python doctor",
|
|
34883
|
+
"",
|
|
34884
|
+
"修复后重新运行:",
|
|
34885
|
+
"taptap-maker init"
|
|
34886
|
+
].join("\n");
|
|
34887
|
+
}
|
|
34888
|
+
function summarizeError(errorText) {
|
|
34889
|
+
const lines = errorText.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
34890
|
+
return lines.slice(0, 4).join(" | ") || "unknown error";
|
|
34891
|
+
}
|
|
34892
|
+
async function runPython(parsed, ctx) {
|
|
34893
|
+
const [, subcommand] = parsed.command;
|
|
34894
|
+
if (!subcommand || subcommand === "doctor") {
|
|
34895
|
+
const environment = checkMakerPythonEnvironment();
|
|
34896
|
+
if (ctx.json) {
|
|
34897
|
+
writeJson(environment);
|
|
34898
|
+
return;
|
|
34899
|
+
}
|
|
34900
|
+
process.stdout.write(`${formatMakerPythonEnvironmentStatus(environment)}
|
|
34901
|
+
`);
|
|
34902
|
+
return;
|
|
34903
|
+
}
|
|
34904
|
+
if (subcommand === "setup") {
|
|
34905
|
+
process.stderr.write(
|
|
34906
|
+
"Maker Python setup may download and run the official uv installer from https://astral.sh.\n"
|
|
34907
|
+
);
|
|
34908
|
+
const result = setupMakerPythonEnvironment();
|
|
34909
|
+
if (ctx.json) {
|
|
34910
|
+
writeJson(result);
|
|
34911
|
+
return;
|
|
34912
|
+
}
|
|
34913
|
+
process.stdout.write(
|
|
34914
|
+
[
|
|
34915
|
+
result.changed ? "Maker Python runtime prepared" : "Maker Python runtime already available",
|
|
34916
|
+
"",
|
|
34917
|
+
formatMakerPythonEnvironmentStatus(result.environment),
|
|
34918
|
+
""
|
|
34919
|
+
].join("\n")
|
|
34920
|
+
);
|
|
34921
|
+
return;
|
|
34922
|
+
}
|
|
34923
|
+
if (subcommand === "path") {
|
|
34924
|
+
const environment = checkMakerPythonEnvironment();
|
|
34925
|
+
if (ctx.json) {
|
|
34926
|
+
writeJson({
|
|
34927
|
+
ready: environment.ready,
|
|
34928
|
+
status: environment.status,
|
|
34929
|
+
python: environment.python,
|
|
34930
|
+
provider: environment.provider,
|
|
34931
|
+
version: environment.version,
|
|
34932
|
+
nextAction: environment.nextAction
|
|
34933
|
+
});
|
|
34934
|
+
return;
|
|
34935
|
+
}
|
|
34936
|
+
if (!environment.ready || !environment.python) {
|
|
34937
|
+
throw new Error(
|
|
34938
|
+
[
|
|
34939
|
+
"Maker Python runtime is not ready.",
|
|
34940
|
+
`- status: ${environment.status}`,
|
|
34941
|
+
`- next_action: ${environment.nextAction}`
|
|
34942
|
+
].join("\n")
|
|
34943
|
+
);
|
|
34944
|
+
}
|
|
34945
|
+
process.stdout.write(`${environment.python}
|
|
34946
|
+
`);
|
|
34947
|
+
return;
|
|
34948
|
+
}
|
|
34949
|
+
throw new Error(`Unknown taptap-maker python command: ${formatUnknownCommand(parsed.command)}`);
|
|
34950
|
+
}
|
|
34342
34951
|
async function runApps(parsed, ctx) {
|
|
34343
34952
|
rejectRemovedAppsPaginationOptions(parsed);
|
|
34344
34953
|
const pat = stringOption(parsed, "pat");
|
|
@@ -34389,7 +34998,7 @@ async function runPatSet(parsed, ctx) {
|
|
|
34389
34998
|
}
|
|
34390
34999
|
async function resolvePatSet(parsed, ctx) {
|
|
34391
35000
|
if (booleanOption(parsed, "pat_stdin") || booleanOption(parsed, "pat_from_stdin")) {
|
|
34392
|
-
const pat =
|
|
35001
|
+
const pat = fs11.readFileSync(0, "utf8").trim();
|
|
34393
35002
|
if (!pat) {
|
|
34394
35003
|
throw new Error("No PAT found on stdin.");
|
|
34395
35004
|
}
|
|
@@ -34413,11 +35022,13 @@ async function resolvePatSet(parsed, ctx) {
|
|
|
34413
35022
|
async function runMcpInstall(parsed, ctx) {
|
|
34414
35023
|
rejectPackageOption(parsed);
|
|
34415
35024
|
const ides = parseIdeList(stringOption(parsed, "ide") || stringOption(parsed, "ides") || "");
|
|
35025
|
+
const explicitTargetDir = stringOption(parsed, "target_dir");
|
|
34416
35026
|
const results = installMcpConfigs({
|
|
34417
35027
|
ides: ides.length > 0 ? ides : ["codex", "cursor", "claude"],
|
|
34418
35028
|
env: makerEnvOption(parsed),
|
|
34419
35029
|
pkg: MAKER_NPM_PACKAGE,
|
|
34420
|
-
mcpName: stringOption(parsed, "name") || DEFAULT_MCP_NAME
|
|
35030
|
+
mcpName: stringOption(parsed, "name") || DEFAULT_MCP_NAME,
|
|
35031
|
+
cwd: explicitTargetDir ? path12.resolve(explicitTargetDir) : void 0
|
|
34421
35032
|
});
|
|
34422
35033
|
if (ctx.json) {
|
|
34423
35034
|
writeJson(results);
|
|
@@ -34431,7 +35042,7 @@ async function runMcpVerify(parsed, ctx) {
|
|
|
34431
35042
|
rejectPackageOption(parsed);
|
|
34432
35043
|
const mode = mcpVerifyModeOption(parsed);
|
|
34433
35044
|
const command = mode === "npx" ? getNpxCliCommand(MAKER_NPM_PACKAGE) : getCurrentCliCommand();
|
|
34434
|
-
const result =
|
|
35045
|
+
const result = spawnSync7(command.command, [...command.args, "help"], {
|
|
34435
35046
|
encoding: "utf8"
|
|
34436
35047
|
});
|
|
34437
35048
|
const failureType = classifyMcpVerifyFailure(result);
|
|
@@ -34520,7 +35131,7 @@ function getMcpVerifyNextSteps(mode, commandText) {
|
|
|
34520
35131
|
];
|
|
34521
35132
|
}
|
|
34522
35133
|
async function runDevKitUpdate(parsed, ctx) {
|
|
34523
|
-
const targetDir =
|
|
35134
|
+
const targetDir = path12.resolve(stringOption(parsed, "target_dir") || process.cwd());
|
|
34524
35135
|
const result = await installAiDevKit({
|
|
34525
35136
|
targetDir,
|
|
34526
35137
|
preserveExisting: false,
|
|
@@ -34532,7 +35143,7 @@ async function runDevKitUpdate(parsed, ctx) {
|
|
|
34532
35143
|
emitDevKitSkillInstallerFailure(ctx, result.skillInstaller, "AI skills install failed");
|
|
34533
35144
|
}
|
|
34534
35145
|
async function runLogsWatch(parsed, ctx) {
|
|
34535
|
-
const targetDir =
|
|
35146
|
+
const targetDir = path12.resolve(stringOption(parsed, "target_dir") || process.cwd());
|
|
34536
35147
|
const intervalMs = parseDurationMs(stringOption(parsed, "interval") || "5s");
|
|
34537
35148
|
const timeoutMs = numberOption(parsed, "timeout_ms") ?? 60 * 1e3;
|
|
34538
35149
|
const maxPolls = numberOption(parsed, "max_polls");
|
|
@@ -34542,9 +35153,9 @@ async function runLogsWatch(parsed, ctx) {
|
|
|
34542
35153
|
serverUrl: stringOption(parsed, "server_url"),
|
|
34543
35154
|
env: makerEnvOption(parsed)
|
|
34544
35155
|
});
|
|
34545
|
-
const runtimeDir =
|
|
34546
|
-
const runtimeLog =
|
|
34547
|
-
const pidFile =
|
|
35156
|
+
const runtimeDir = path12.join(proxy.projectRoot, ".maker", "logs", "runtime");
|
|
35157
|
+
const runtimeLog = path12.join(runtimeDir, "runtime.log");
|
|
35158
|
+
const pidFile = path12.join(runtimeDir, "watcher.pid");
|
|
34548
35159
|
const replacedWatcher = registerRuntimeLogWatcherProcess(pidFile);
|
|
34549
35160
|
const runtimeLogClient = createRemoteRuntimeLogClient(proxy, timeoutMs);
|
|
34550
35161
|
emit(ctx, "logs_watch_start", "Maker runtime log watcher started", {
|
|
@@ -34589,10 +35200,10 @@ async function runLogsWatch(parsed, ctx) {
|
|
|
34589
35200
|
}
|
|
34590
35201
|
}
|
|
34591
35202
|
function registerRuntimeLogWatcherProcess(pidFile) {
|
|
34592
|
-
|
|
35203
|
+
fs11.mkdirSync(path12.dirname(pidFile), { recursive: true });
|
|
34593
35204
|
const existingPid = readPidFile(pidFile);
|
|
34594
35205
|
const previous = existingPid && existingPid !== process.pid ? stopExistingRuntimeLogWatcher(pidFile) : {};
|
|
34595
|
-
|
|
35206
|
+
fs11.writeFileSync(
|
|
34596
35207
|
pidFile,
|
|
34597
35208
|
`${JSON.stringify(
|
|
34598
35209
|
{
|
|
@@ -34610,10 +35221,10 @@ function registerRuntimeLogWatcherProcess(pidFile) {
|
|
|
34610
35221
|
return previous;
|
|
34611
35222
|
}
|
|
34612
35223
|
function readPidFile(pidFile) {
|
|
34613
|
-
if (!
|
|
35224
|
+
if (!fs11.existsSync(pidFile)) {
|
|
34614
35225
|
return void 0;
|
|
34615
35226
|
}
|
|
34616
|
-
const raw =
|
|
35227
|
+
const raw = fs11.readFileSync(pidFile, "utf8").trim();
|
|
34617
35228
|
let pid = Number(raw);
|
|
34618
35229
|
if (!Number.isInteger(pid) || pid <= 0) {
|
|
34619
35230
|
try {
|
|
@@ -34633,7 +35244,7 @@ function installRuntimeLogWatcherPidCleanup(pidFile) {
|
|
|
34633
35244
|
}
|
|
34634
35245
|
cleaned = true;
|
|
34635
35246
|
if (readPidFile(pidFile) === process.pid) {
|
|
34636
|
-
|
|
35247
|
+
fs11.rmSync(pidFile, { force: true });
|
|
34637
35248
|
}
|
|
34638
35249
|
};
|
|
34639
35250
|
process.once("exit", cleanup);
|
|
@@ -34742,7 +35353,7 @@ async function prepareDevKit(targetDir, ctx, options = {}) {
|
|
|
34742
35353
|
onStart: (event) => emitSkillInstallerStart(ctx, event)
|
|
34743
35354
|
});
|
|
34744
35355
|
writeDevKitStagedGitignore(
|
|
34745
|
-
|
|
35356
|
+
path12.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE),
|
|
34746
35357
|
listPresentDevKitManagedEntries(targetDir)
|
|
34747
35358
|
);
|
|
34748
35359
|
if (options.finalizeGitignore) {
|
|
@@ -34759,7 +35370,7 @@ async function prepareDevKit(targetDir, ctx, options = {}) {
|
|
|
34759
35370
|
);
|
|
34760
35371
|
} catch (error2) {
|
|
34761
35372
|
writeDevKitStagedGitignore(
|
|
34762
|
-
|
|
35373
|
+
path12.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE),
|
|
34763
35374
|
listPresentDevKitManagedEntries(targetDir)
|
|
34764
35375
|
);
|
|
34765
35376
|
if (options.finalizeGitignore) {
|
|
@@ -34847,7 +35458,7 @@ function installMcpConfig(ide, options) {
|
|
|
34847
35458
|
}
|
|
34848
35459
|
function installMcpConfigUnsafe(ide, options) {
|
|
34849
35460
|
if (ide === "codex") {
|
|
34850
|
-
const configPath =
|
|
35461
|
+
const configPath = path12.join(os4.homedir(), ".codex", "config.toml");
|
|
34851
35462
|
mergeCodexMcpConfig(configPath, options);
|
|
34852
35463
|
return {
|
|
34853
35464
|
ide,
|
|
@@ -34857,7 +35468,7 @@ function installMcpConfigUnsafe(ide, options) {
|
|
|
34857
35468
|
};
|
|
34858
35469
|
}
|
|
34859
35470
|
if (ide === "cursor") {
|
|
34860
|
-
const configPath =
|
|
35471
|
+
const configPath = path12.join(os4.homedir(), ".cursor", "mcp.json");
|
|
34861
35472
|
mergeJsonMcpConfig(configPath, options);
|
|
34862
35473
|
return {
|
|
34863
35474
|
ide,
|
|
@@ -34867,11 +35478,13 @@ function installMcpConfigUnsafe(ide, options) {
|
|
|
34867
35478
|
};
|
|
34868
35479
|
}
|
|
34869
35480
|
if (ide === "claude") {
|
|
34870
|
-
|
|
34871
|
-
|
|
34872
|
-
|
|
35481
|
+
if (!options.cwd) {
|
|
35482
|
+
const claudeResult = tryClaudeMcpAdd(options);
|
|
35483
|
+
if (claudeResult.ok) {
|
|
35484
|
+
return { ide, ok: true, message: "✓ Claude Code MCP config updated with claude mcp add" };
|
|
35485
|
+
}
|
|
34873
35486
|
}
|
|
34874
|
-
const configPath =
|
|
35487
|
+
const configPath = path12.join(os4.homedir(), ".claude.json");
|
|
34875
35488
|
mergeJsonMcpConfig(configPath, options);
|
|
34876
35489
|
return {
|
|
34877
35490
|
ide,
|
|
@@ -34888,28 +35501,29 @@ function mergeJsonMcpConfig(configPath, options) {
|
|
|
34888
35501
|
const mcpServers = asObject(existing.mcpServers);
|
|
34889
35502
|
mcpServers[options.mcpName] = createJsonMcpServerConfig(options);
|
|
34890
35503
|
existing.mcpServers = mcpServers;
|
|
34891
|
-
|
|
34892
|
-
|
|
35504
|
+
fs11.mkdirSync(path12.dirname(configPath), { recursive: true });
|
|
35505
|
+
fs11.writeFileSync(configPath, `${JSON.stringify(existing, null, 2)}
|
|
34893
35506
|
`, "utf8");
|
|
34894
35507
|
}
|
|
34895
35508
|
function mergeCodexMcpConfig(configPath, options) {
|
|
34896
35509
|
const backupPath = backupIfExists(configPath);
|
|
34897
|
-
const existing =
|
|
35510
|
+
const existing = fs11.existsSync(configPath) ? fs11.readFileSync(configPath, "utf8") : "";
|
|
34898
35511
|
const sectionPattern = createCodexMcpSectionPattern(options.mcpName);
|
|
34899
35512
|
const withoutOld = existing.replace(sectionPattern, "").trimEnd();
|
|
34900
|
-
const
|
|
35513
|
+
const launch = getNpxCliCommand(options.pkg);
|
|
34901
35514
|
const section = [
|
|
34902
35515
|
`[mcp_servers."${options.mcpName}"]`,
|
|
34903
|
-
`command = "${escapeToml(command)}"`,
|
|
34904
|
-
`args = [
|
|
35516
|
+
`command = "${escapeToml(launch.command)}"`,
|
|
35517
|
+
`args = [${launch.args.map((arg) => `"${escapeToml(arg)}"`).join(", ")}]`,
|
|
35518
|
+
options.cwd ? `cwd = "${escapeToml(options.cwd)}"` : "",
|
|
34905
35519
|
"",
|
|
34906
35520
|
`[mcp_servers."${options.mcpName}".env]`,
|
|
34907
35521
|
`TAPTAP_MCP_ENV = "${options.env}"`,
|
|
34908
35522
|
""
|
|
34909
35523
|
].join("\n");
|
|
34910
|
-
|
|
34911
|
-
|
|
34912
|
-
const updated =
|
|
35524
|
+
fs11.mkdirSync(path12.dirname(configPath), { recursive: true });
|
|
35525
|
+
fs11.writeFileSync(configPath, [withoutOld, section].filter(Boolean).join("\n\n"), "utf8");
|
|
35526
|
+
const updated = fs11.readFileSync(configPath, "utf8");
|
|
34913
35527
|
const duplicates = findCodexMcpTableDuplicates(updated, options.mcpName);
|
|
34914
35528
|
if (duplicates.length > 0) {
|
|
34915
35529
|
restoreBackup(configPath, backupPath);
|
|
@@ -34961,34 +35575,34 @@ function normalizeCodexMcpTablePath(tablePath, mcpName) {
|
|
|
34961
35575
|
return `mcp_servers.${mcpName}${match[1] || ""}`;
|
|
34962
35576
|
}
|
|
34963
35577
|
function tryClaudeMcpAdd(options) {
|
|
34964
|
-
const
|
|
34965
|
-
const
|
|
34966
|
-
|
|
34967
|
-
|
|
34968
|
-
|
|
34969
|
-
|
|
34970
|
-
|
|
34971
|
-
|
|
34972
|
-
|
|
34973
|
-
|
|
34974
|
-
|
|
34975
|
-
|
|
34976
|
-
|
|
34977
|
-
|
|
34978
|
-
|
|
34979
|
-
|
|
34980
|
-
|
|
34981
|
-
|
|
34982
|
-
"taptap-maker"
|
|
34983
|
-
],
|
|
35578
|
+
const npxLaunch = getNpxCliCommand(options.pkg);
|
|
35579
|
+
const claudeArgs = [
|
|
35580
|
+
"mcp",
|
|
35581
|
+
"add",
|
|
35582
|
+
"--scope",
|
|
35583
|
+
"user",
|
|
35584
|
+
"--transport",
|
|
35585
|
+
"stdio",
|
|
35586
|
+
"--env",
|
|
35587
|
+
`TAPTAP_MCP_ENV=${options.env}`,
|
|
35588
|
+
options.mcpName,
|
|
35589
|
+
"--",
|
|
35590
|
+
...npxLaunch.commandAndArgs
|
|
35591
|
+
];
|
|
35592
|
+
const claude = getWindowsCmdLaunchCommand("claude.cmd", claudeArgs);
|
|
35593
|
+
const result = spawnSync7(
|
|
35594
|
+
process.platform === "win32" ? claude.command : "claude",
|
|
35595
|
+
process.platform === "win32" ? claude.args : claudeArgs,
|
|
34984
35596
|
{ encoding: "utf8" }
|
|
34985
35597
|
);
|
|
34986
35598
|
return { ok: result.status === 0 };
|
|
34987
35599
|
}
|
|
34988
35600
|
function createJsonMcpServerConfig(options) {
|
|
35601
|
+
const launch = getNpxCliCommand(options.pkg);
|
|
34989
35602
|
return {
|
|
34990
|
-
command:
|
|
34991
|
-
args:
|
|
35603
|
+
command: launch.command,
|
|
35604
|
+
args: launch.args,
|
|
35605
|
+
...options.cwd ? { cwd: options.cwd } : {},
|
|
34992
35606
|
env: {
|
|
34993
35607
|
TAPTAP_MCP_ENV: options.env
|
|
34994
35608
|
}
|
|
@@ -35001,10 +35615,22 @@ function getCurrentCliCommand() {
|
|
|
35001
35615
|
return { command: process.platform === "win32" ? "taptap-maker.cmd" : "taptap-maker", args: [] };
|
|
35002
35616
|
}
|
|
35003
35617
|
function getNpxCliCommand(pkg) {
|
|
35004
|
-
return
|
|
35618
|
+
return resolveNpxCliCommand(pkg);
|
|
35619
|
+
}
|
|
35620
|
+
function resolveNpxCliCommand(pkg, platform = process.platform) {
|
|
35621
|
+
const npxArgs = ["-y", "-p", pkg, "taptap-maker"];
|
|
35622
|
+
if (platform === "win32") {
|
|
35623
|
+
const launch = getWindowsCmdLaunchCommand("npx.cmd", npxArgs);
|
|
35624
|
+
return {
|
|
35625
|
+
command: launch.command,
|
|
35626
|
+
args: launch.args,
|
|
35627
|
+
commandAndArgs: [launch.command, ...launch.args]
|
|
35628
|
+
};
|
|
35629
|
+
}
|
|
35630
|
+
return { command: "npx", args: npxArgs, commandAndArgs: ["npx", ...npxArgs] };
|
|
35005
35631
|
}
|
|
35006
|
-
function
|
|
35007
|
-
return
|
|
35632
|
+
function getWindowsCmdLaunchCommand(command, args) {
|
|
35633
|
+
return { command: "cmd.exe", args: ["/d", "/s", "/c", command, ...args] };
|
|
35008
35634
|
}
|
|
35009
35635
|
function rejectPackageOption(parsed) {
|
|
35010
35636
|
if (Object.prototype.hasOwnProperty.call(parsed.options, "package")) {
|
|
@@ -35014,10 +35640,10 @@ function rejectPackageOption(parsed) {
|
|
|
35014
35640
|
}
|
|
35015
35641
|
}
|
|
35016
35642
|
function readJsonObject(filePath) {
|
|
35017
|
-
if (!
|
|
35643
|
+
if (!fs11.existsSync(filePath)) {
|
|
35018
35644
|
return {};
|
|
35019
35645
|
}
|
|
35020
|
-
return JSON.parse(
|
|
35646
|
+
return JSON.parse(fs11.readFileSync(filePath, "utf8"));
|
|
35021
35647
|
}
|
|
35022
35648
|
function asObject(value) {
|
|
35023
35649
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
@@ -35026,26 +35652,26 @@ function asObject(value) {
|
|
|
35026
35652
|
return {};
|
|
35027
35653
|
}
|
|
35028
35654
|
function backupIfExists(filePath) {
|
|
35029
|
-
if (!
|
|
35655
|
+
if (!fs11.existsSync(filePath)) {
|
|
35030
35656
|
return void 0;
|
|
35031
35657
|
}
|
|
35032
35658
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:]/g, "").replace(/\..+$/, "");
|
|
35033
35659
|
const backupPath = `${filePath}.bak.${stamp}`;
|
|
35034
|
-
|
|
35660
|
+
fs11.copyFileSync(filePath, backupPath);
|
|
35035
35661
|
return backupPath;
|
|
35036
35662
|
}
|
|
35037
35663
|
function restoreBackup(filePath, backupPath) {
|
|
35038
35664
|
if (backupPath) {
|
|
35039
|
-
|
|
35665
|
+
fs11.copyFileSync(backupPath, filePath);
|
|
35040
35666
|
return;
|
|
35041
35667
|
}
|
|
35042
|
-
|
|
35668
|
+
fs11.rmSync(filePath, { force: true });
|
|
35043
35669
|
}
|
|
35044
35670
|
function saveInitState(targetDir, state) {
|
|
35045
|
-
|
|
35046
|
-
const key = crypto2.createHash("sha256").update(
|
|
35047
|
-
|
|
35048
|
-
|
|
35671
|
+
fs11.mkdirSync(getMakerHome(), { recursive: true });
|
|
35672
|
+
const key = crypto2.createHash("sha256").update(path12.resolve(targetDir)).digest("hex").slice(0, 16);
|
|
35673
|
+
fs11.writeFileSync(
|
|
35674
|
+
path12.join(getMakerHome(), `init-state-${key}.json`),
|
|
35049
35675
|
`${JSON.stringify({ ...state, updated_at: (/* @__PURE__ */ new Date()).toISOString() }, null, 2)}
|
|
35050
35676
|
`,
|
|
35051
35677
|
"utf8"
|
|
@@ -35146,7 +35772,7 @@ function formatUnknownCommand(command) {
|
|
|
35146
35772
|
return `${primary} ${isKnownSubcommand(primary, secondary) ? secondary : "<redacted>"}`;
|
|
35147
35773
|
}
|
|
35148
35774
|
function isKnownSubcommand(command, subcommand) {
|
|
35149
|
-
return command === "pat" && subcommand === "set" || command === "mcp" && (subcommand === "install" || subcommand === "verify") || command === "dev-kit" && subcommand === "update" || command === "logs" && subcommand === "watch";
|
|
35775
|
+
return command === "pat" && subcommand === "set" || command === "mcp" && (subcommand === "install" || subcommand === "verify") || command === "dev-kit" && subcommand === "update" || command === "logs" && subcommand === "watch" || command === "python" && (subcommand === "doctor" || subcommand === "setup" || subcommand === "path");
|
|
35150
35776
|
}
|
|
35151
35777
|
function stringOption(parsed, key) {
|
|
35152
35778
|
const value = parsed.options[key];
|
|
@@ -35181,7 +35807,7 @@ function makerEnvOption(parsed) {
|
|
|
35181
35807
|
return env;
|
|
35182
35808
|
}
|
|
35183
35809
|
const targetDir = stringOption(parsed, "target_dir");
|
|
35184
|
-
return getMakerEnvironment(void 0, targetDir ?
|
|
35810
|
+
return getMakerEnvironment(void 0, targetDir ? path12.resolve(targetDir) : process.cwd());
|
|
35185
35811
|
}
|
|
35186
35812
|
function mcpVerifyModeOption(parsed) {
|
|
35187
35813
|
const mode = stringOption(parsed, "mode") || "npx";
|
|
@@ -35223,15 +35849,19 @@ function printHelp() {
|
|
|
35223
35849
|
" [--skip-confirm] [--skip-mcp-install] [--register-mcp codex,cursor,claude]",
|
|
35224
35850
|
" [--json]",
|
|
35225
35851
|
" taptap-maker doctor [--target-dir DIR] [--env rnd|production] [--json]",
|
|
35852
|
+
" taptap-maker python doctor [--json]",
|
|
35853
|
+
" taptap-maker python setup [--json]",
|
|
35854
|
+
" taptap-maker python path [--json]",
|
|
35226
35855
|
" taptap-maker apps [--pat PAT] [--all] [--json]",
|
|
35227
35856
|
" # --pat warns: PAT appears in ps/history",
|
|
35228
35857
|
" taptap-maker login [--env rnd|production] [--json]",
|
|
35229
35858
|
" taptap-maker pat set [--pat-stdin] [--json]",
|
|
35230
35859
|
" taptap-maker pat set [PAT|--pat PAT] [--json] # fallback; warns: PAT appears in ps/history",
|
|
35231
35860
|
" taptap-maker install [--ide codex,cursor,claude] [--env rnd|production]",
|
|
35861
|
+
" [--target-dir DIR]",
|
|
35232
35862
|
" [--json] # alias for mcp install",
|
|
35233
35863
|
" taptap-maker mcp install [--ide codex,cursor,claude] [--env rnd|production]",
|
|
35234
|
-
" [--json]",
|
|
35864
|
+
" [--target-dir DIR] [--json]",
|
|
35235
35865
|
" taptap-maker mcp verify [--mode npx|self] [--json]",
|
|
35236
35866
|
" taptap-maker dev-kit update [--target-dir DIR] [--json]",
|
|
35237
35867
|
" taptap-maker logs watch [--target-dir DIR] [--interval 5s] [--reset] [--json]",
|
|
@@ -35240,7 +35870,7 @@ function printHelp() {
|
|
|
35240
35870
|
"Maker MCP configs and npx verification use @taptap/maker.",
|
|
35241
35871
|
"",
|
|
35242
35872
|
"Windows note:",
|
|
35243
|
-
" Generated MCP configs
|
|
35873
|
+
" Generated MCP configs wrap npx.cmd with cmd.exe on Windows for spawn compatibility.",
|
|
35244
35874
|
""
|
|
35245
35875
|
].join("\n")
|
|
35246
35876
|
);
|
|
@@ -35253,14 +35883,14 @@ function formatCliError(error2) {
|
|
|
35253
35883
|
}
|
|
35254
35884
|
|
|
35255
35885
|
// src/maker/crashLog.ts
|
|
35256
|
-
import
|
|
35257
|
-
import
|
|
35886
|
+
import fs12 from "node:fs";
|
|
35887
|
+
import path13 from "node:path";
|
|
35258
35888
|
var DEFAULT_MAX_BYTES = 1024 * 1024;
|
|
35259
35889
|
var DEFAULT_MAX_ENTRY_BYTES = 16 * 1024;
|
|
35260
35890
|
function appendMakerCrashLog(source, error2, options = {}) {
|
|
35261
35891
|
const makerHome = getMakerHome();
|
|
35262
|
-
|
|
35263
|
-
const logPath =
|
|
35892
|
+
fs12.mkdirSync(makerHome, { recursive: true });
|
|
35893
|
+
const logPath = path13.join(makerHome, "mcp-crash.log");
|
|
35264
35894
|
const maxBytes = positiveInteger(options.maxBytes) || resolveEnvBytes("TAPTAP_MAKER_CRASH_LOG_MAX_BYTES", DEFAULT_MAX_BYTES);
|
|
35265
35895
|
const maxEntryBytes = positiveInteger(options.maxEntryBytes) || resolveEnvBytes("TAPTAP_MAKER_CRASH_LOG_MAX_ENTRY_BYTES", DEFAULT_MAX_ENTRY_BYTES);
|
|
35266
35896
|
const message = error2 instanceof Error ? error2.stack || error2.message : String(error2);
|
|
@@ -35270,31 +35900,31 @@ function appendMakerCrashLog(source, error2, options = {}) {
|
|
|
35270
35900
|
);
|
|
35271
35901
|
const entryBytes = Buffer.byteLength(entry, "utf8");
|
|
35272
35902
|
rotateIfNeeded(logPath, maxBytes, entryBytes);
|
|
35273
|
-
|
|
35903
|
+
fs12.appendFileSync(logPath, entry, "utf8");
|
|
35274
35904
|
}
|
|
35275
35905
|
function rotateIfNeeded(logPath, maxBytes, incomingBytes) {
|
|
35276
|
-
if (!
|
|
35906
|
+
if (!fs12.existsSync(logPath)) {
|
|
35277
35907
|
return;
|
|
35278
35908
|
}
|
|
35279
|
-
const currentBytes =
|
|
35909
|
+
const currentBytes = fs12.statSync(logPath).size;
|
|
35280
35910
|
if (currentBytes + incomingBytes <= maxBytes) {
|
|
35281
35911
|
return;
|
|
35282
35912
|
}
|
|
35283
35913
|
const rotatedPath = `${logPath}.1`;
|
|
35284
35914
|
writeFileTail(logPath, rotatedPath, maxBytes);
|
|
35285
|
-
|
|
35915
|
+
fs12.writeFileSync(logPath, "", "utf8");
|
|
35286
35916
|
}
|
|
35287
35917
|
function writeFileTail(sourcePath, targetPath, maxBytes) {
|
|
35288
|
-
const size =
|
|
35918
|
+
const size = fs12.statSync(sourcePath).size;
|
|
35289
35919
|
const bytesToRead = Math.min(size, maxBytes);
|
|
35290
35920
|
const start = Math.max(0, size - bytesToRead);
|
|
35291
|
-
const fd =
|
|
35921
|
+
const fd = fs12.openSync(sourcePath, "r");
|
|
35292
35922
|
try {
|
|
35293
35923
|
const buffer = Buffer.alloc(bytesToRead);
|
|
35294
|
-
|
|
35295
|
-
|
|
35924
|
+
fs12.readSync(fd, buffer, 0, bytesToRead, start);
|
|
35925
|
+
fs12.writeFileSync(targetPath, buffer);
|
|
35296
35926
|
} finally {
|
|
35297
|
-
|
|
35927
|
+
fs12.closeSync(fd);
|
|
35298
35928
|
}
|
|
35299
35929
|
}
|
|
35300
35930
|
function truncateUtf8(value, maxBytes) {
|
|
@@ -36863,7 +37493,7 @@ var StreamableHTTPClientTransport = class {
|
|
|
36863
37493
|
};
|
|
36864
37494
|
|
|
36865
37495
|
// src/mcp-proxy/proxy.ts
|
|
36866
|
-
import * as
|
|
37496
|
+
import * as path15 from "node:path";
|
|
36867
37497
|
import * as crypto5 from "node:crypto";
|
|
36868
37498
|
|
|
36869
37499
|
// src/mcp-proxy/cookieJar.ts
|
|
@@ -37045,8 +37675,8 @@ function createCookieFetch(cookieJar) {
|
|
|
37045
37675
|
}
|
|
37046
37676
|
|
|
37047
37677
|
// src/core/utils/logWriter.ts
|
|
37048
|
-
import * as
|
|
37049
|
-
import * as
|
|
37678
|
+
import * as fs13 from "node:fs";
|
|
37679
|
+
import * as path14 from "node:path";
|
|
37050
37680
|
import * as crypto4 from "node:crypto";
|
|
37051
37681
|
|
|
37052
37682
|
// src/core/types/log.ts
|
|
@@ -37087,7 +37717,7 @@ var LogWriter = class {
|
|
|
37087
37717
|
return;
|
|
37088
37718
|
}
|
|
37089
37719
|
try {
|
|
37090
|
-
await
|
|
37720
|
+
await fs13.promises.mkdir(this.config.logDir, { recursive: true });
|
|
37091
37721
|
await this.cleanupOldLogs();
|
|
37092
37722
|
this.initialized = true;
|
|
37093
37723
|
} catch (error2) {
|
|
@@ -37110,7 +37740,7 @@ var LogWriter = class {
|
|
|
37110
37740
|
*/
|
|
37111
37741
|
getLogFilePath(date5) {
|
|
37112
37742
|
const d = date5 || this.getCurrentDate();
|
|
37113
|
-
return
|
|
37743
|
+
return path14.join(this.config.logDir, `${this.config.prefix}-${d}.log`);
|
|
37114
37744
|
}
|
|
37115
37745
|
/**
|
|
37116
37746
|
* 获取或创建写入流
|
|
@@ -37125,7 +37755,7 @@ var LogWriter = class {
|
|
|
37125
37755
|
}
|
|
37126
37756
|
this.currentDate = date5;
|
|
37127
37757
|
try {
|
|
37128
|
-
this.writeStream =
|
|
37758
|
+
this.writeStream = fs13.createWriteStream(this.getLogFilePath(date5), {
|
|
37129
37759
|
flags: "a",
|
|
37130
37760
|
encoding: "utf8"
|
|
37131
37761
|
});
|
|
@@ -37177,11 +37807,11 @@ var LogWriter = class {
|
|
|
37177
37807
|
if (this.shouldWriteToFile(level) && this.initialized && this.config.enabled) {
|
|
37178
37808
|
try {
|
|
37179
37809
|
const filePath = this.getLogFilePath();
|
|
37180
|
-
const dir =
|
|
37181
|
-
if (!
|
|
37182
|
-
|
|
37810
|
+
const dir = path14.dirname(filePath);
|
|
37811
|
+
if (!fs13.existsSync(dir)) {
|
|
37812
|
+
fs13.mkdirSync(dir, { recursive: true });
|
|
37183
37813
|
}
|
|
37184
|
-
|
|
37814
|
+
fs13.appendFileSync(filePath, message, "utf8");
|
|
37185
37815
|
} catch {
|
|
37186
37816
|
}
|
|
37187
37817
|
}
|
|
@@ -37192,7 +37822,7 @@ var LogWriter = class {
|
|
|
37192
37822
|
async cleanupOldLogs() {
|
|
37193
37823
|
if (this.config.maxDays <= 0) return;
|
|
37194
37824
|
try {
|
|
37195
|
-
const files = await
|
|
37825
|
+
const files = await fs13.promises.readdir(this.config.logDir);
|
|
37196
37826
|
const cutoffDate = /* @__PURE__ */ new Date();
|
|
37197
37827
|
cutoffDate.setDate(cutoffDate.getDate() - this.config.maxDays);
|
|
37198
37828
|
const prefix = this.config.prefix;
|
|
@@ -37207,7 +37837,7 @@ var LogWriter = class {
|
|
|
37207
37837
|
if (!Number.isNaN(year) && !Number.isNaN(month) && !Number.isNaN(day)) {
|
|
37208
37838
|
const fileDate = new Date(year, month - 1, day);
|
|
37209
37839
|
if (fileDate < cutoffDate) {
|
|
37210
|
-
await
|
|
37840
|
+
await fs13.promises.unlink(path14.join(this.config.logDir, file2));
|
|
37211
37841
|
process.stderr.write(`[LogWriter] Deleted old log: ${file2}
|
|
37212
37842
|
`);
|
|
37213
37843
|
}
|
|
@@ -37278,10 +37908,10 @@ var TapTapMCPProxy = class {
|
|
|
37278
37908
|
const { user_id, project_id } = this.config.tenant;
|
|
37279
37909
|
let logDir;
|
|
37280
37910
|
if (user_id && project_id) {
|
|
37281
|
-
logDir =
|
|
37911
|
+
logDir = path15.join(logRoot, "proxy", user_id, project_id);
|
|
37282
37912
|
} else {
|
|
37283
37913
|
const kidHash = crypto5.createHash("sha256").update(this.config.auth.kid).digest("hex").substring(0, 8);
|
|
37284
|
-
logDir =
|
|
37914
|
+
logDir = path15.join(logRoot, "proxy", kidHash);
|
|
37285
37915
|
}
|
|
37286
37916
|
return new LogWriter({
|
|
37287
37917
|
logDir,
|
|
@@ -37914,6 +38544,9 @@ function printHelp2() {
|
|
|
37914
38544
|
" [--skip-confirm] [--skip-mcp-install] [--register-mcp codex,cursor,claude]",
|
|
37915
38545
|
" [--json]",
|
|
37916
38546
|
" taptap-maker doctor [--target-dir DIR] [--env rnd|production] [--json]",
|
|
38547
|
+
" taptap-maker python doctor [--json]",
|
|
38548
|
+
" taptap-maker python setup [--json]",
|
|
38549
|
+
" taptap-maker python path [--json]",
|
|
37917
38550
|
" taptap-maker apps [--pat PAT] [--all] [--json]",
|
|
37918
38551
|
" # --pat warns: PAT appears in ps/history",
|
|
37919
38552
|
" taptap-maker login [--env rnd|production] [--json]",
|
|
@@ -37931,7 +38564,7 @@ function printHelp2() {
|
|
|
37931
38564
|
"Maker MCP configs and npx verification use @taptap/maker.",
|
|
37932
38565
|
"",
|
|
37933
38566
|
"Windows note:",
|
|
37934
|
-
" Generated MCP configs
|
|
38567
|
+
" Generated MCP configs wrap npx.cmd with cmd.exe on Windows for spawn compatibility.",
|
|
37935
38568
|
""
|
|
37936
38569
|
].join("\n")
|
|
37937
38570
|
);
|