@taptap/maker 0.0.8 → 0.0.9

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/dist/maker.js CHANGED
@@ -3233,8 +3233,8 @@ var require_utils = __commonJS({
3233
3233
  }
3234
3234
  return ind;
3235
3235
  }
3236
- function removeDotSegments(path13) {
3237
- let input2 = path13;
3236
+ function removeDotSegments(path14) {
3237
+ let input2 = path14;
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 [path13, query] = wsComponent.resourceName.split("?");
3437
- wsComponent.path = path13 && path13 !== "/" ? path13 : void 0;
3436
+ const [path14, query] = wsComponent.resourceName.split("?");
3437
+ wsComponent.path = path14 && path14 !== "/" ? path14 : 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, fs11, exportName) {
12494
+ function addFormats(ajv, list, fs12, 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, fs11[f]);
12499
+ ajv.addFormat(f, fs12[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 fs11 = __require("fs");
12513
- function checkPathExt(path13, options) {
12512
+ var fs12 = __require("fs");
12513
+ function checkPathExt(path14, 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 && path13.substr(-p.length).toLowerCase() === p) {
12524
+ if (p && path14.substr(-p.length).toLowerCase() === p) {
12525
12525
  return true;
12526
12526
  }
12527
12527
  }
12528
12528
  return false;
12529
12529
  }
12530
- function checkStat(stat, path13, options) {
12530
+ function checkStat(stat, path14, options) {
12531
12531
  if (!stat.isSymbolicLink() && !stat.isFile()) {
12532
12532
  return false;
12533
12533
  }
12534
- return checkPathExt(path13, options);
12534
+ return checkPathExt(path14, options);
12535
12535
  }
12536
- function isexe(path13, options, cb) {
12537
- fs11.stat(path13, function(er, stat) {
12538
- cb(er, er ? false : checkStat(stat, path13, options));
12536
+ function isexe(path14, options, cb) {
12537
+ fs12.stat(path14, function(er, stat) {
12538
+ cb(er, er ? false : checkStat(stat, path14, options));
12539
12539
  });
12540
12540
  }
12541
- function sync(path13, options) {
12542
- return checkStat(fs11.statSync(path13), path13, options);
12541
+ function sync(path14, options) {
12542
+ return checkStat(fs12.statSync(path14), path14, 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 fs11 = __require("fs");
12553
- function isexe(path13, options, cb) {
12554
- fs11.stat(path13, function(er, stat) {
12552
+ var fs12 = __require("fs");
12553
+ function isexe(path14, options, cb) {
12554
+ fs12.stat(path14, function(er, stat) {
12555
12555
  cb(er, er ? false : checkStat(stat, options));
12556
12556
  });
12557
12557
  }
12558
- function sync(path13, options) {
12559
- return checkStat(fs11.statSync(path13), options);
12558
+ function sync(path14, options) {
12559
+ return checkStat(fs12.statSync(path14), 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 fs11 = __require("fs");
12583
+ var fs12 = __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(path13, options, cb) {
12592
+ function isexe(path14, 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(path13, options || {}, function(er, is) {
12602
+ isexe(path14, 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(path13, options || {}, function(er, is) {
12611
+ core(path14, 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(path13, options) {
12621
+ function sync(path14, options) {
12622
12622
  try {
12623
- return core.sync(path13, options || {});
12623
+ return core.sync(path14, 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 path13 = __require("path");
12639
+ var path14 = __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 = path13.join(pathPart, cmd);
12677
+ const pCmd = path14.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 = path13.join(pathPart, cmd);
12704
+ const pCmd = path14.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 path13 = __require("path");
12752
+ var path14 = __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 ? path13.delimiter : void 0
12770
+ pathExt: withoutPathExt ? path14.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 = path13.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
12779
+ resolved = path14.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 [path13, argument] = match[0].replace(/#! ?/, "").split(" ");
12834
- const binary = path13.split("/").pop();
12833
+ const [path14, argument] = match[0].replace(/#! ?/, "").split(" ");
12834
+ const binary = path14.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 fs11 = __require("fs");
12847
+ var fs12 = __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 = fs11.openSync(command, "r");
12855
- fs11.readSync(fd, buffer, 0, size, 0);
12856
- fs11.closeSync(fd);
12854
+ fd = fs12.openSync(command, "r");
12855
+ fs12.readSync(fd, buffer, 0, size, 0);
12856
+ fs12.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 path13 = __require("path");
12869
+ var path14 = __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 = path13.normalize(parsed.command);
12894
+ parsed.command = path14.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(" ");
@@ -13003,8 +13003,8 @@ var require_cross_spawn = __commonJS({
13003
13003
 
13004
13004
  // src/maker/server/mcp.ts
13005
13005
  import { execFileSync, spawn as spawn4 } from "node:child_process";
13006
- import fs7 from "node:fs";
13007
- import path8 from "node:path";
13006
+ import fs8 from "node:fs";
13007
+ import path9 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: path13, errorMaps, issueData } = params;
13369
- const fullPath = [...path13, ...issueData.path || []];
13368
+ const { data, path: path14, errorMaps, issueData } = params;
13369
+ const fullPath = [...path14, ...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, path13, key) {
13484
+ constructor(parent, value, path14, key) {
13485
13485
  this._cachedPath = [];
13486
13486
  this.parent = parent;
13487
13487
  this.data = value;
13488
- this._path = path13;
13488
+ this._path = path14;
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, path13) {
17138
- if (!path13)
17137
+ function getElementAtPath(obj, path14) {
17138
+ if (!path14)
17139
17139
  return obj;
17140
- return path13.reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
17140
+ return path14.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(path13, issues) {
17525
+ function prefixIssues(path14, issues) {
17526
17526
  return issues.map((iss) => {
17527
17527
  var _a3;
17528
17528
  (_a3 = iss).path ?? (_a3.path = []);
17529
- iss.path.unshift(path13);
17529
+ iss.path.unshift(path14);
17530
17530
  return iss;
17531
17531
  });
17532
17532
  }
@@ -28889,6 +28889,9 @@ function resolveDefaultAiDevKitUrl(environment = EnvConfig.environment) {
28889
28889
  }
28890
28890
  var DEV_KIT_IGNORE_BEGIN = "# >>> TapTap Maker AI dev kit (local only) >>>";
28891
28891
  var DEV_KIT_IGNORE_END = "# <<< TapTap Maker AI dev kit (local only) <<<";
28892
+ var MAKER_ASSET_POLICY_BEGIN = "<!-- >>> TapTap Maker asset tool policy >>> -->";
28893
+ var MAKER_ASSET_POLICY_END = "<!-- <<< TapTap Maker asset tool policy <<< -->";
28894
+ var AGENTS_INSTRUCTION_FILE = "AGENTS.md";
28892
28895
  var DEV_KIT_GITIGNORE_STAGING_FILE = ".gitignore.dev-kit-before-clone";
28893
28896
  var DEV_KIT_REQUIRED_ENTRIES = ["CLAUDE.md", "examples", "templates", "urhox-libs"];
28894
28897
  var ALWAYS_IGNORED_LOCAL_ENTRIES = [".DS_Store", ".maker", ".installer"];
@@ -28955,6 +28958,12 @@ async function installAiDevKit(options = {}) {
28955
28958
  const skillInstaller = runDevKitSkillInstallerForInstall(targetDir, {
28956
28959
  onStart: options.onSkillInstallerStart
28957
28960
  });
28961
+ const instructionFiles = ensureMakerAssetPolicyInstructionFiles(targetDir);
28962
+ for (const entry of instructionFiles) {
28963
+ if (!installedEntries.includes(entry)) {
28964
+ installedEntries.push(entry);
28965
+ }
28966
+ }
28958
28967
  const stagedGitignorePath = path4.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE);
28959
28968
  writeDevKitStagedGitignore(stagedGitignorePath, [
28960
28969
  ...installedEntries,
@@ -29001,6 +29010,65 @@ function writeDevKitStagedGitignore(stagedGitignorePath, entries) {
29001
29010
  fs3.writeFileSync(stagedGitignorePath, `${createDevKitGitignoreBlock(entries)}
29002
29011
  `, "utf8");
29003
29012
  }
29013
+ function ensureMakerAssetPolicyInstructionFiles(targetDir) {
29014
+ const resolvedTargetDir = path4.resolve(targetDir);
29015
+ fs3.mkdirSync(resolvedTargetDir, { recursive: true });
29016
+ const agentsPath = path4.join(resolvedTargetDir, AGENTS_INSTRUCTION_FILE);
29017
+ const existingAgents = fs3.existsSync(agentsPath) ? fs3.readFileSync(agentsPath, "utf8") : "";
29018
+ fs3.writeFileSync(agentsPath, prependMakerAssetPolicyBlock(existingAgents), "utf8");
29019
+ return [AGENTS_INSTRUCTION_FILE];
29020
+ }
29021
+ function prependMakerAssetPolicyBlock(existing) {
29022
+ const withoutOldBlock = removeMakerAssetPolicyBlock(existing).trimStart();
29023
+ const block = createMakerAssetPolicyBlock();
29024
+ return [block, withoutOldBlock].filter((part) => part.length > 0).join("\n\n");
29025
+ }
29026
+ function removeMakerAssetPolicyBlock(content) {
29027
+ return content.replace(
29028
+ new RegExp(
29029
+ `${escapeRegExp(MAKER_ASSET_POLICY_BEGIN)}[\\s\\S]*?${escapeRegExp(
29030
+ MAKER_ASSET_POLICY_END
29031
+ )}\\n?`,
29032
+ "g"
29033
+ ),
29034
+ ""
29035
+ ).replace(/^# TapTap Maker Project Asset Tool Policy\n\n(?=\s*)/, "");
29036
+ }
29037
+ function createMakerAssetPolicyBlock() {
29038
+ return [
29039
+ "# TapTap Maker Project Asset Tool Policy",
29040
+ "",
29041
+ MAKER_ASSET_POLICY_BEGIN,
29042
+ "",
29043
+ "This is a bound TapTap Maker project. For game asset generation or editing in this project,",
29044
+ "the local AI/Agent MUST use Maker MCP proxy tools first:",
29045
+ "",
29046
+ "- `generate_image` for one image asset.",
29047
+ "- `batch_generate_images` for multiple image assets.",
29048
+ "- `edit_image` for modifying existing project images.",
29049
+ "- `create_video_task` for game video assets or referenced image/video generation.",
29050
+ "- `text_to_music` for game music or audio assets.",
29051
+ "",
29052
+ "Before calling `edit_image`, resolve dragged or referenced images to a local project image path",
29053
+ "or CDN URL first. If the user references an attached/local image, inspect the attachment or",
29054
+ "workspace file path before calling the tool.",
29055
+ "If the image is under `assets/image`, pass that path. If only a file name is given, search",
29056
+ "`assets/image` for the matching file. Do not call `edit_image` without an image path or CDN URL.",
29057
+ "",
29058
+ "This policy overrides imagegen, built-in image tools, built-in video tools, built-in audio",
29059
+ "tools, and other client-native media generation for Maker game assets.",
29060
+ "",
29061
+ "DO NOT invoke imagegen or native media tools for Maker game assets when the Maker proxy tool is",
29062
+ "callable. If the required Maker proxy tool is not exposed in the current AI session, stop and",
29063
+ "tell the user to restart/check the Maker MCP session. DO NOT fall back to generic imagegen or",
29064
+ "native media generation unless the user explicitly asks to leave the Maker asset workflow.",
29065
+ "",
29066
+ "Generated assets must stay in the Maker project asset workflow under `assets/image`,",
29067
+ "`assets/video`, or `assets/audio`, with CDN mappings preserved for later edits and builds.",
29068
+ "",
29069
+ MAKER_ASSET_POLICY_END
29070
+ ].join("\n");
29071
+ }
29004
29072
  function mergeDevKitGitignoreBlock(gitignorePath, block) {
29005
29073
  const existing = fs3.existsSync(gitignorePath) ? fs3.readFileSync(gitignorePath, "utf8") : "";
29006
29074
  const withoutOldBlock = existing.replace(
@@ -29552,7 +29620,7 @@ async function cloneMakerProject(options) {
29552
29620
  };
29553
29621
  }
29554
29622
  async function pushMakerProject(options) {
29555
- var _a3, _b, _c, _d, _e, _f, _g, _h, _i;
29623
+ var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j;
29556
29624
  ensureGitAvailable();
29557
29625
  (_a3 = options.onProgress) == null ? void 0 : _a3.call(options, {
29558
29626
  progress: 0,
@@ -29581,6 +29649,19 @@ async function pushMakerProject(options) {
29581
29649
  phase: "auth",
29582
29650
  message: "Authenticated Maker git origin ready"
29583
29651
  });
29652
+ const remoteSyncStatus = await inspectMakerRemoteSyncStatus(cwd);
29653
+ const remoteSyncFailure = getBlockingRemoteSyncFailure(remoteSyncStatus);
29654
+ if (remoteSyncFailure) {
29655
+ return {
29656
+ branch: remoteSyncStatus.branch,
29657
+ committed: false,
29658
+ pushed: false,
29659
+ status: "clean",
29660
+ failure: remoteSyncFailure,
29661
+ ahead: await readAheadState(cwd),
29662
+ transientRetries: 0
29663
+ };
29664
+ }
29584
29665
  const statusBefore = await readGit(["status", "--porcelain"], cwd);
29585
29666
  const branch = await currentBranch(cwd, options.branch);
29586
29667
  const unpushed = await readUnpushedCommitState(cwd, branch);
@@ -29612,9 +29693,34 @@ async function pushMakerProject(options) {
29612
29693
  phase: "stage",
29613
29694
  message: "Staging selected files"
29614
29695
  });
29615
- await runGit(["add", ...options.files], { cwd });
29696
+ await runGit(["add", ...includeMandatoryMakerSubmitFiles(cwd, options.files)], { cwd });
29697
+ const staged = await readGit(["diff", "--cached", "--name-only"], cwd);
29698
+ message = options.message || generateCommitMessage(statusBefore);
29699
+ if (staged.trim() || options.allowEmpty) {
29700
+ (_f = options.onProgress) == null ? void 0 : _f.call(options, {
29701
+ progress: 45,
29702
+ total: 100,
29703
+ phase: "commit",
29704
+ message: "Creating local Maker project commit"
29705
+ });
29706
+ await runGit(
29707
+ [
29708
+ "-c",
29709
+ "user.email=maker-mcp@local",
29710
+ "-c",
29711
+ "user.name=taptap-maker",
29712
+ "commit",
29713
+ ...options.allowEmpty ? ["--allow-empty"] : [],
29714
+ "-m",
29715
+ message
29716
+ ],
29717
+ { cwd }
29718
+ );
29719
+ committed = true;
29720
+ commitHash = (await readGit(["rev-parse", "--short", "HEAD"], cwd)).trim();
29721
+ }
29616
29722
  } else {
29617
- (_f = options.onProgress) == null ? void 0 : _f.call(options, {
29723
+ (_g = options.onProgress) == null ? void 0 : _g.call(options, {
29618
29724
  progress: 20,
29619
29725
  total: 100,
29620
29726
  phase: "stage",
@@ -29624,7 +29730,7 @@ async function pushMakerProject(options) {
29624
29730
  const staged = await readGit(["diff", "--cached", "--name-only"], cwd);
29625
29731
  message = options.message || generateCommitMessage(statusBefore);
29626
29732
  if (staged.trim() || options.allowEmpty) {
29627
- (_g = options.onProgress) == null ? void 0 : _g.call(options, {
29733
+ (_h = options.onProgress) == null ? void 0 : _h.call(options, {
29628
29734
  progress: 45,
29629
29735
  total: 100,
29630
29736
  phase: "commit",
@@ -29648,7 +29754,7 @@ async function pushMakerProject(options) {
29648
29754
  }
29649
29755
  }
29650
29756
  try {
29651
- (_h = options.onProgress) == null ? void 0 : _h.call(options, {
29757
+ (_i = options.onProgress) == null ? void 0 : _i.call(options, {
29652
29758
  progress: 65,
29653
29759
  total: 100,
29654
29760
  phase: "push",
@@ -29673,7 +29779,7 @@ async function pushMakerProject(options) {
29673
29779
  transientRetries
29674
29780
  };
29675
29781
  }
29676
- (_i = options.onProgress) == null ? void 0 : _i.call(options, {
29782
+ (_j = options.onProgress) == null ? void 0 : _j.call(options, {
29677
29783
  progress: 100,
29678
29784
  total: 100,
29679
29785
  phase: "done",
@@ -29689,6 +29795,50 @@ async function pushMakerProject(options) {
29689
29795
  transientRetries
29690
29796
  };
29691
29797
  }
29798
+ function getBlockingRemoteSyncFailure(status) {
29799
+ if (status.status === "up_to_date" || status.status === "ahead") {
29800
+ return void 0;
29801
+ }
29802
+ if (status.status === "branch_not_allowed") {
29803
+ return {
29804
+ stage: "remote_sync",
29805
+ message: status.nextAction,
29806
+ classification: "branch_not_allowed",
29807
+ retryable: false,
29808
+ stderr: status.nextAction,
29809
+ nextAction: status.nextAction
29810
+ };
29811
+ }
29812
+ if (status.status === "remote_unavailable" && status.failure) {
29813
+ return {
29814
+ ...status.failure,
29815
+ stage: "remote_sync",
29816
+ nextAction: status.nextAction
29817
+ };
29818
+ }
29819
+ return {
29820
+ stage: "remote_sync",
29821
+ message: status.nextAction,
29822
+ classification: "remote_rejected",
29823
+ retryable: false,
29824
+ stderr: [
29825
+ `Maker remote sync status: ${status.status}`,
29826
+ `branch: ${status.branch}`,
29827
+ `ahead: ${status.aheadCount}`,
29828
+ `behind: ${status.behindCount}`,
29829
+ status.nextAction
29830
+ ].join("\n"),
29831
+ nextAction: status.nextAction
29832
+ };
29833
+ }
29834
+ function includeMandatoryMakerSubmitFiles(cwd, files) {
29835
+ const unique = new Set(files);
29836
+ const changedFiles = parseGitStatusFiles(readGitSync(["-C", cwd, "status", "--porcelain", "-z"]));
29837
+ if (changedFiles.includes(".gitignore")) {
29838
+ unique.add(".gitignore");
29839
+ }
29840
+ return [...unique];
29841
+ }
29692
29842
  async function readMakerProjectLocalChanges(cwd) {
29693
29843
  ensureGitAvailable();
29694
29844
  const { projectRoot } = resolveUsableMakerGitWorkspace(cwd);
@@ -30812,6 +30962,25 @@ function formatMakerSkillStatus(_options = {}) {
30812
30962
  ...skillDocuments.map((skill) => `- ${skill.name}: ${skill.path}`),
30813
30963
  "",
30814
30964
  "Use these documents as reading references for Maker local workflows.",
30965
+ "",
30966
+ "Maker Git workflow policy",
30967
+ `- entry: ${MAKER_LOCAL_SKILL_NAME} > Maker Git Workflow Policy`,
30968
+ "- Ignore generic local Git skills for Maker submit/build.",
30969
+ "- Do not create branches, task branches, PR/MR, or generic git commit/push flows.",
30970
+ "- Use maker_build_current_directory for submit, push, and build.",
30971
+ "",
30972
+ "Maker creative asset tool policy",
30973
+ `- entry: ${MAKER_LOCAL_SKILL_NAME} > Maker Creative Asset Tool Policy`,
30974
+ "- Prefer Maker MCP proxy tools over native AI image/video/audio tools for bound Maker projects.",
30975
+ "- This policy overrides generic imagegen or native media skills for Maker game assets.",
30976
+ "- Do not invoke imagegen, built-in image/video/audio tools, or other native media generation.",
30977
+ "- Do not fall back to generic imagegen when Maker proxy tools are unavailable in the session.",
30978
+ "- Use generate_image, batch_generate_images, edit_image for game image assets.",
30979
+ "- Use create_video_task and text_to_music for game video/audio assets.",
30980
+ "- Generated assets are saved under assets/image, assets/video, or assets/audio with CDN mappings.",
30981
+ "- Before edit_image, resolve dragged or referenced images to a local project image path or CDN URL.",
30982
+ "- If only a file name is given, search assets/image for the matching file before calling edit_image.",
30983
+ "- Do not call edit_image without an image path or CDN URL.",
30815
30984
  "Maker initialization next_step: execute `taptap-maker init`.",
30816
30985
  "Load these documents when the current AI client supports reading local guide files."
30817
30986
  ].join("\n");
@@ -31215,13 +31384,487 @@ function compactRuntimeLogEntry(entry) {
31215
31384
  return compact;
31216
31385
  }
31217
31386
 
31387
+ // src/maker/server/proxyAssets.ts
31388
+ import fs7 from "node:fs";
31389
+ import path8 from "node:path";
31390
+ var IMAGE_ASSET_DIRS = ["assets/image"];
31391
+ var VIDEO_ASSET_DIRS = ["assets/video"];
31392
+ var AUDIO_ASSET_DIRS = ["assets/audio"];
31393
+ function prepareRemoteProxyToolArgs(options) {
31394
+ if (options.toolName === "edit_image") {
31395
+ return rewriteEditImageAssetArgs(options.targetDir, options.args);
31396
+ }
31397
+ if (options.toolName === "generate_image") {
31398
+ return normalizeImageReferenceAssetArgs(options.targetDir, options.args);
31399
+ }
31400
+ if (options.toolName === "create_video_task") {
31401
+ return rewriteVideoReferenceAssetArgs(options.targetDir, options.args);
31402
+ }
31403
+ return options.args;
31404
+ }
31405
+ async function materializeRemoteProxyToolAssets(options) {
31406
+ if (!shouldMaterializeRemoteProxyTool(options.toolName)) {
31407
+ return options.result;
31408
+ }
31409
+ const content = options.result.content;
31410
+ if (!Array.isArray(content)) {
31411
+ return options.result;
31412
+ }
31413
+ let changed = false;
31414
+ const nextContent = [];
31415
+ for (const item of content) {
31416
+ if (!isTextContent(item)) {
31417
+ nextContent.push(item);
31418
+ continue;
31419
+ }
31420
+ const parsed = parseJsonObject(item.text);
31421
+ if (!parsed) {
31422
+ nextContent.push(item);
31423
+ continue;
31424
+ }
31425
+ const nextParsed = await materializeParsedProxyResult({
31426
+ toolName: options.toolName,
31427
+ targetDir: options.targetDir,
31428
+ payload: parsed,
31429
+ now: options.now ?? /* @__PURE__ */ new Date(),
31430
+ fetchImpl: options.fetchImpl ?? fetch
31431
+ });
31432
+ if (nextParsed === parsed) {
31433
+ nextContent.push(item);
31434
+ continue;
31435
+ }
31436
+ changed = true;
31437
+ nextContent.push({
31438
+ ...item,
31439
+ text: JSON.stringify(nextParsed, null, 2)
31440
+ });
31441
+ }
31442
+ return changed ? { ...options.result, content: nextContent } : options.result;
31443
+ }
31444
+ function shouldMaterializeRemoteProxyTool(toolName) {
31445
+ return [
31446
+ "generate_image",
31447
+ "batch_generate_images",
31448
+ "edit_image",
31449
+ "create_video_task",
31450
+ "text_to_music"
31451
+ ].includes(toolName);
31452
+ }
31453
+ function isTextContent(item) {
31454
+ return typeof item === "object" && item !== null && item.type === "text" && typeof item.text === "string";
31455
+ }
31456
+ function parseJsonObject(text) {
31457
+ try {
31458
+ const parsed = JSON.parse(text);
31459
+ return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : void 0;
31460
+ } catch {
31461
+ return void 0;
31462
+ }
31463
+ }
31464
+ async function materializeParsedProxyResult(options) {
31465
+ if (options.toolName === "generate_image") {
31466
+ return await materializeSingleImageResult(options, "generate_image");
31467
+ }
31468
+ if (options.toolName === "batch_generate_images") {
31469
+ return await materializeBatchImageResult(options);
31470
+ }
31471
+ if (options.toolName === "edit_image") {
31472
+ return await materializeSingleImageResult(options, "edit_image");
31473
+ }
31474
+ if (options.toolName === "create_video_task") {
31475
+ return await materializeVideoResult(options);
31476
+ }
31477
+ if (options.toolName === "text_to_music") {
31478
+ return await materializeMusicResult(options);
31479
+ }
31480
+ return options.payload;
31481
+ }
31482
+ async function materializeSingleImageResult(options, toolName) {
31483
+ if (options.payload.success !== true) {
31484
+ return options.payload;
31485
+ }
31486
+ const materialized = await materializeAsset({
31487
+ targetDir: options.targetDir,
31488
+ url: stringField2(options.payload.previewUrl),
31489
+ baseName: stringField2(options.payload.name),
31490
+ relativeDir: "assets/image",
31491
+ extension: "png",
31492
+ now: options.now,
31493
+ fetchImpl: options.fetchImpl
31494
+ });
31495
+ return materialized ? persistMaterializedAsset({
31496
+ targetDir: options.targetDir,
31497
+ toolName,
31498
+ payload: options.payload,
31499
+ materialized,
31500
+ cdnUrl: stringField2(options.payload.previewUrl),
31501
+ now: options.now
31502
+ }) : options.payload;
31503
+ }
31504
+ async function materializeBatchImageResult(options) {
31505
+ if (!Array.isArray(options.payload.results)) {
31506
+ return options.payload;
31507
+ }
31508
+ const results = [];
31509
+ for (const item of options.payload.results) {
31510
+ if (!isRecord(item) || item.success !== true) {
31511
+ results.push(item);
31512
+ continue;
31513
+ }
31514
+ const materialized = await materializeAsset({
31515
+ targetDir: options.targetDir,
31516
+ url: stringField2(item.previewUrl),
31517
+ baseName: stringField2(item.name),
31518
+ relativeDir: "assets/image",
31519
+ extension: "png",
31520
+ now: options.now,
31521
+ fetchImpl: options.fetchImpl
31522
+ });
31523
+ results.push(
31524
+ materialized ? persistMaterializedAsset({
31525
+ targetDir: options.targetDir,
31526
+ toolName: "batch_generate_images",
31527
+ payload: item,
31528
+ materialized,
31529
+ cdnUrl: stringField2(item.previewUrl),
31530
+ now: options.now
31531
+ }) : item
31532
+ );
31533
+ }
31534
+ return { ...options.payload, results };
31535
+ }
31536
+ async function materializeVideoResult(options) {
31537
+ if (options.payload.status !== "succeeded") {
31538
+ return options.payload;
31539
+ }
31540
+ const materialized = await materializeAsset({
31541
+ targetDir: options.targetDir,
31542
+ url: stringField2(options.payload.cdn_url),
31543
+ baseName: stringField2(options.payload.task_id),
31544
+ relativeDir: "assets/video",
31545
+ extension: "mp4",
31546
+ now: options.now,
31547
+ fetchImpl: options.fetchImpl
31548
+ });
31549
+ return materialized ? persistMaterializedAsset({
31550
+ targetDir: options.targetDir,
31551
+ toolName: "create_video_task",
31552
+ payload: options.payload,
31553
+ materialized,
31554
+ cdnUrl: stringField2(options.payload.cdn_url),
31555
+ now: options.now,
31556
+ extraRegistryFields: {
31557
+ taskId: stringField2(options.payload.task_id)
31558
+ }
31559
+ }) : options.payload;
31560
+ }
31561
+ async function materializeMusicResult(options) {
31562
+ if (options.payload.success !== true) {
31563
+ return options.payload;
31564
+ }
31565
+ if (!isRecord(options.payload.music)) {
31566
+ return options.payload;
31567
+ }
31568
+ const music = options.payload.music;
31569
+ const materialized = await materializeAsset({
31570
+ targetDir: options.targetDir,
31571
+ url: stringField2(music.audioUrl),
31572
+ baseName: stringField2(music.title) || stringField2(options.payload.taskId),
31573
+ relativeDir: "assets/audio",
31574
+ extension: extensionFromUrl(stringField2(music.audioUrl)) || "mp3",
31575
+ now: options.now,
31576
+ fetchImpl: options.fetchImpl
31577
+ });
31578
+ return materialized ? {
31579
+ ...options.payload,
31580
+ music: persistMaterializedAsset({
31581
+ targetDir: options.targetDir,
31582
+ toolName: "text_to_music",
31583
+ payload: music,
31584
+ materialized,
31585
+ cdnUrl: stringField2(music.audioUrl),
31586
+ now: options.now,
31587
+ extraRegistryFields: {
31588
+ taskId: stringField2(options.payload.taskId)
31589
+ }
31590
+ })
31591
+ } : options.payload;
31592
+ }
31593
+ function persistMaterializedAsset(options) {
31594
+ const nextPayload = { ...options.payload, ...options.materialized };
31595
+ if (!("localPath" in options.materialized) || !options.cdnUrl) {
31596
+ return nextPayload;
31597
+ }
31598
+ upsertGeneratedAssetRecord(options.targetDir, options.materialized.localPath, {
31599
+ tool: options.toolName,
31600
+ name: stringField2(options.payload.name) || stringField2(options.payload.title),
31601
+ prompt: stringField2(options.payload.prompt),
31602
+ cdnUrl: options.cdnUrl,
31603
+ previewUrl: options.cdnUrl,
31604
+ localPath: options.materialized.localPath,
31605
+ absolutePath: options.materialized.absolutePath,
31606
+ createdAt: options.now.toISOString(),
31607
+ ...options.extraRegistryFields
31608
+ });
31609
+ return nextPayload;
31610
+ }
31611
+ async function materializeAsset(options) {
31612
+ if (!options.url || !options.baseName) {
31613
+ return void 0;
31614
+ }
31615
+ const { absolutePath, relativePath } = createUniqueAssetPath({
31616
+ targetDir: options.targetDir,
31617
+ relativeDir: options.relativeDir,
31618
+ baseName: options.baseName,
31619
+ extension: options.extension,
31620
+ now: options.now
31621
+ });
31622
+ try {
31623
+ const response = await options.fetchImpl(options.url);
31624
+ if (!response.ok) {
31625
+ return {
31626
+ download: {
31627
+ success: false,
31628
+ error: `Asset download failed: HTTP ${response.status}`
31629
+ }
31630
+ };
31631
+ }
31632
+ const bytes = Buffer.from(await response.arrayBuffer());
31633
+ fs7.mkdirSync(path8.dirname(absolutePath), { recursive: true });
31634
+ fs7.writeFileSync(absolutePath, bytes);
31635
+ return { localPath: relativePath, absolutePath, download: { success: true } };
31636
+ } catch (error2) {
31637
+ return {
31638
+ download: {
31639
+ success: false,
31640
+ error: `Asset download failed: ${error2 instanceof Error ? error2.message : String(error2)}`
31641
+ }
31642
+ };
31643
+ }
31644
+ }
31645
+ function createUniqueAssetPath(options) {
31646
+ const stem = `${sanitizeAssetBaseName(options.baseName)}_${formatAssetTimestamp(options.now)}`;
31647
+ for (let index = 1; index <= 9999; index += 1) {
31648
+ const relativePath = path8.posix.join(
31649
+ options.relativeDir,
31650
+ `${stem}${index === 1 ? "" : `_${index}`}.${options.extension}`
31651
+ );
31652
+ const absolutePath = path8.join(options.targetDir, ...relativePath.split("/"));
31653
+ if (!fs7.existsSync(absolutePath)) {
31654
+ return { relativePath, absolutePath };
31655
+ }
31656
+ }
31657
+ throw new Error(`Unable to allocate unique asset path for ${stem}.${options.extension}`);
31658
+ }
31659
+ function rewriteEditImageAssetArgs(targetDir, args) {
31660
+ const registry2 = readGeneratedAssetRegistry(targetDir);
31661
+ return {
31662
+ ...args,
31663
+ image: rewriteGeneratedAssetReference(targetDir, args.image, registry2, IMAGE_ASSET_DIRS),
31664
+ reference_images: Array.isArray(args.reference_images) ? args.reference_images.map(
31665
+ (item) => rewriteGeneratedAssetReference(targetDir, item, registry2, IMAGE_ASSET_DIRS)
31666
+ ) : args.reference_images
31667
+ };
31668
+ }
31669
+ function normalizeImageReferenceAssetArgs(targetDir, args) {
31670
+ const registry2 = readGeneratedAssetRegistry(targetDir);
31671
+ return {
31672
+ ...args,
31673
+ image: normalizeLocalAssetReference(targetDir, args.image, registry2, IMAGE_ASSET_DIRS),
31674
+ reference_images: Array.isArray(args.reference_images) ? args.reference_images.map(
31675
+ (item) => normalizeLocalAssetReference(targetDir, item, registry2, IMAGE_ASSET_DIRS)
31676
+ ) : args.reference_images
31677
+ };
31678
+ }
31679
+ function rewriteVideoReferenceAssetArgs(targetDir, args) {
31680
+ const registry2 = readGeneratedAssetRegistry(targetDir);
31681
+ return {
31682
+ ...args,
31683
+ images: rewriteUrlObjectArray(targetDir, args.images, registry2, IMAGE_ASSET_DIRS),
31684
+ videos: rewriteUrlObjectArray(targetDir, args.videos, registry2, VIDEO_ASSET_DIRS),
31685
+ audios: rewriteUrlObjectArray(targetDir, args.audios, registry2, AUDIO_ASSET_DIRS)
31686
+ };
31687
+ }
31688
+ function rewriteUrlObjectArray(targetDir, value, registry2, assetDirs) {
31689
+ if (!Array.isArray(value)) {
31690
+ return value;
31691
+ }
31692
+ return value.map(
31693
+ (item) => isRecord(item) ? {
31694
+ ...item,
31695
+ url: rewriteGeneratedAssetReference(targetDir, item.url, registry2, assetDirs)
31696
+ } : item
31697
+ );
31698
+ }
31699
+ function rewriteGeneratedAssetReference(targetDir, value, registry2, assetDirs) {
31700
+ var _a3, _b;
31701
+ if (typeof value !== "string") {
31702
+ return value;
31703
+ }
31704
+ const localPath = resolveLocalAssetReference(targetDir, value, registry2, assetDirs);
31705
+ const cdnUrl = localPath ? ((_a3 = registry2[localPath]) == null ? void 0 : _a3.cdnUrl) || ((_b = registry2[localPath]) == null ? void 0 : _b.previewUrl) : void 0;
31706
+ return cdnUrl || localPath || value;
31707
+ }
31708
+ function normalizeLocalAssetReference(targetDir, value, registry2, assetDirs) {
31709
+ if (typeof value !== "string") {
31710
+ return value;
31711
+ }
31712
+ return resolveLocalAssetReference(targetDir, value, registry2, assetDirs) || value;
31713
+ }
31714
+ function resolveLocalAssetReference(targetDir, value, registry2, assetDirs) {
31715
+ if (/^https?:\/\//i.test(value) || value.startsWith("data:")) {
31716
+ return void 0;
31717
+ }
31718
+ const key = normalizeAssetRegistryKey(targetDir, value);
31719
+ if (key && registry2[key]) {
31720
+ return key;
31721
+ }
31722
+ if (key && isKnownAssetPath(key, assetDirs)) {
31723
+ return key;
31724
+ }
31725
+ if (!isBareAssetName(value)) {
31726
+ return void 0;
31727
+ }
31728
+ return findRegistryAssetByName(value, registry2, assetDirs) || findLocalAssetByName(targetDir, value, assetDirs);
31729
+ }
31730
+ function findRegistryAssetByName(value, registry2, assetDirs) {
31731
+ var _a3;
31732
+ const matches = Object.entries(registry2).filter(([localPath, record2]) => {
31733
+ if (!isKnownAssetPath(localPath, assetDirs)) {
31734
+ return false;
31735
+ }
31736
+ const basename = path8.posix.basename(localPath);
31737
+ const stem = basename.replace(/\.[^.]+$/, "");
31738
+ return basename === value || stem === value || record2.name === value || record2.taskId === value;
31739
+ });
31740
+ matches.sort(([, left], [, right]) => {
31741
+ const leftTime = Date.parse(left.createdAt || "") || 0;
31742
+ const rightTime = Date.parse(right.createdAt || "") || 0;
31743
+ return rightTime - leftTime;
31744
+ });
31745
+ return (_a3 = matches[0]) == null ? void 0 : _a3[0];
31746
+ }
31747
+ function findLocalAssetByName(targetDir, value, assetDirs) {
31748
+ var _a3;
31749
+ const hasExtension = Boolean(path8.extname(value));
31750
+ const candidates = [];
31751
+ for (const assetDir of assetDirs) {
31752
+ const absoluteDir = path8.join(targetDir, ...assetDir.split("/"));
31753
+ let entries;
31754
+ try {
31755
+ entries = fs7.readdirSync(absoluteDir);
31756
+ } catch {
31757
+ continue;
31758
+ }
31759
+ for (const entry of entries) {
31760
+ const stem = entry.replace(/\.[^.]+$/, "");
31761
+ if (hasExtension ? entry !== value : stem !== value && !stem.startsWith(`${value}_`)) {
31762
+ continue;
31763
+ }
31764
+ const absolutePath = path8.join(absoluteDir, entry);
31765
+ try {
31766
+ candidates.push({
31767
+ localPath: path8.posix.join(assetDir, entry),
31768
+ mtimeMs: fs7.statSync(absolutePath).mtimeMs
31769
+ });
31770
+ } catch {
31771
+ }
31772
+ }
31773
+ }
31774
+ candidates.sort((left, right) => right.mtimeMs - left.mtimeMs);
31775
+ return (_a3 = candidates[0]) == null ? void 0 : _a3.localPath;
31776
+ }
31777
+ function isKnownAssetPath(relativePath, assetDirs) {
31778
+ if (relativePath.startsWith("../") || path8.isAbsolute(relativePath)) {
31779
+ return false;
31780
+ }
31781
+ return assetDirs.some(
31782
+ (assetDir) => relativePath === assetDir || relativePath.startsWith(`${assetDir}/`)
31783
+ );
31784
+ }
31785
+ function isBareAssetName(value) {
31786
+ return !value.includes("/") && !value.includes("\\");
31787
+ }
31788
+ function upsertGeneratedAssetRecord(targetDir, localPath, record2) {
31789
+ const registry2 = readGeneratedAssetRegistry(targetDir);
31790
+ registry2[localPath] = record2;
31791
+ const registryPath = getGeneratedAssetRegistryPath(targetDir);
31792
+ fs7.mkdirSync(path8.dirname(registryPath), { recursive: true });
31793
+ fs7.writeFileSync(registryPath, `${JSON.stringify(registry2, null, 2)}
31794
+ `, "utf8");
31795
+ }
31796
+ function readGeneratedAssetRegistry(targetDir) {
31797
+ const registryPath = getGeneratedAssetRegistryPath(targetDir);
31798
+ if (!fs7.existsSync(registryPath)) {
31799
+ return {};
31800
+ }
31801
+ try {
31802
+ const parsed = JSON.parse(fs7.readFileSync(registryPath, "utf8"));
31803
+ return isRecord(parsed) ? parsed : {};
31804
+ } catch {
31805
+ return {};
31806
+ }
31807
+ }
31808
+ function getGeneratedAssetRegistryPath(targetDir) {
31809
+ return path8.join(targetDir, ".maker", "assets", "generated-assets.json");
31810
+ }
31811
+ function normalizeAssetRegistryKey(targetDir, value) {
31812
+ if (/^https?:\/\//i.test(value) || value.startsWith("data:")) {
31813
+ return void 0;
31814
+ }
31815
+ const relative = path8.isAbsolute(value) ? path8.relative(targetDir, value) : value;
31816
+ return relative.split(path8.sep).join("/");
31817
+ }
31818
+ function isRecord(value) {
31819
+ return typeof value === "object" && value !== null && !Array.isArray(value);
31820
+ }
31821
+ function stringField2(value) {
31822
+ return typeof value === "string" && value.trim() ? value : void 0;
31823
+ }
31824
+ function sanitizeAssetBaseName(value) {
31825
+ const sanitized = value.trim().replace(/\s+/g, "_").replace(/[/\\:*?"<>|]+/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "");
31826
+ return sanitized || "asset";
31827
+ }
31828
+ function formatAssetTimestamp(date5) {
31829
+ const pad = (value) => String(value).padStart(2, "0");
31830
+ return [
31831
+ date5.getUTCFullYear(),
31832
+ pad(date5.getUTCMonth() + 1),
31833
+ pad(date5.getUTCDate()),
31834
+ pad(date5.getUTCHours()),
31835
+ pad(date5.getUTCMinutes()),
31836
+ pad(date5.getUTCSeconds())
31837
+ ].join("");
31838
+ }
31839
+ function extensionFromUrl(url2) {
31840
+ if (!url2) {
31841
+ return void 0;
31842
+ }
31843
+ try {
31844
+ const pathname = new URL(url2).pathname;
31845
+ const extension = path8.extname(pathname).replace(/^\./, "").toLowerCase();
31846
+ return extension || void 0;
31847
+ } catch {
31848
+ return void 0;
31849
+ }
31850
+ }
31851
+
31218
31852
  // src/maker/server/mcp.ts
31219
- var VERSION = true ? "0.0.8" : "dev";
31853
+ var VERSION = true ? "0.0.9" : "dev";
31220
31854
  var DEFAULT_BUILD_TIMEOUT_MS = 10 * 60 * 1e3;
31855
+ var DEFAULT_PROXY_RETRY_ATTEMPTS = 5;
31856
+ var DEFAULT_PROXY_RETRY_DELAY_MS = 30 * 1e3;
31221
31857
  var PREVIEW_REFRESH_TIMEOUT_MS = 15 * 1e3;
31222
31858
  var WATCHER_STOP_TIMEOUT_MS = 1500;
31223
31859
  var WATCHER_PROCESS_PATTERN = /(?:\btaptap-maker\b|\bmaker\.js\b).*\blogs\b.*\bwatch\b/;
31224
31860
  var LONG_OPERATION_HEARTBEAT_MS = 3 * 60 * 1e3;
31861
+ var MAKER_REMOTE_PROXY_EXPOSED_TOOL_NAMES = [
31862
+ "generate_image",
31863
+ "batch_generate_images",
31864
+ "edit_image",
31865
+ "create_video_task",
31866
+ "text_to_music"
31867
+ ];
31225
31868
  var MakerCloneFailedError = class extends Error {
31226
31869
  constructor(targetDir, originalError) {
31227
31870
  const message = originalError instanceof Error ? originalError.message : String(originalError);
@@ -31234,7 +31877,7 @@ var MakerCloneFailedError = class extends Error {
31234
31877
  var tools = [
31235
31878
  {
31236
31879
  name: "maker_status_lite",
31237
- 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, and bundled workflow guide document paths. Maker initialization next_step: taptap-maker init.",
31880
+ 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.",
31238
31881
  inputSchema: {
31239
31882
  type: "object",
31240
31883
  properties: {
@@ -31251,7 +31894,7 @@ var tools = [
31251
31894
  },
31252
31895
  {
31253
31896
  name: "maker_build_current_directory",
31254
- description: 'Sync and build the current Maker game. Use this single tool for user requests like "构建", "build", "跑一下", "预览", "验证一下", "提交", "提交代码", "推送", or "push" in a Maker project. If local changes or committed-but-unpushed commits exist, the tool commits when needed, pushes to Maker remote, then triggers remote Maker build. 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.',
31897
+ 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. If local changes or committed-but-unpushed commits exist, the tool commits when needed, pushes to Maker remote, then triggers remote Maker build. 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.',
31255
31898
  inputSchema: {
31256
31899
  type: "object",
31257
31900
  properties: {
@@ -31299,7 +31942,7 @@ var tools = [
31299
31942
  files: {
31300
31943
  type: "array",
31301
31944
  items: { type: "string" },
31302
- description: "Optional files to stage before build. Defaults to all local changes."
31945
+ description: "Optional files to stage before build. Defaults to all local changes. Maker generated .gitignore changes are mandatory project files and are included even when omitted here."
31303
31946
  },
31304
31947
  confirm_remote_build_without_submit: {
31305
31948
  type: "boolean",
@@ -31317,6 +31960,133 @@ var resources = [
31317
31960
  mimeType: "text/plain"
31318
31961
  }
31319
31962
  ];
31963
+ async function listMakerTools(options) {
31964
+ let remoteTools = [];
31965
+ try {
31966
+ const listedRemoteTools = options.listRemoteTools ?? (() => listRemoteProxyTools({
31967
+ targetDir: resolveMakerToolTargetDir(options.targetDir),
31968
+ serverUrl: options.serverUrl,
31969
+ env: options.env
31970
+ }));
31971
+ remoteTools = filterExposedRemoteProxyTools(await listedRemoteTools());
31972
+ } catch {
31973
+ remoteTools = [];
31974
+ }
31975
+ return {
31976
+ tools: [...tools, ...remoteTools]
31977
+ };
31978
+ }
31979
+ function filterExposedRemoteProxyTools(toolsToFilter) {
31980
+ const exposedToolNames = new Set(MAKER_REMOTE_PROXY_EXPOSED_TOOL_NAMES);
31981
+ return toolsToFilter.filter((tool) => exposedToolNames.has(tool.name));
31982
+ }
31983
+ function isExposedRemoteProxyTool(name) {
31984
+ return MAKER_REMOTE_PROXY_EXPOSED_TOOL_NAMES.includes(name);
31985
+ }
31986
+ async function listRemoteProxyTools(options) {
31987
+ const proxy = createRemoteProxyContext({
31988
+ targetDir: options.targetDir,
31989
+ serverUrl: options.serverUrl,
31990
+ env: options.env,
31991
+ exposedTools: MAKER_REMOTE_PROXY_EXPOSED_TOOL_NAMES
31992
+ });
31993
+ const transport = new StdioClientTransport({
31994
+ command: proxy.command,
31995
+ args: proxy.args,
31996
+ env: mergeStringEnv(process.env, proxy.envVars),
31997
+ stderr: "pipe"
31998
+ });
31999
+ const client = new Client(
32000
+ {
32001
+ name: "taptap-maker-tool-list-forwarder",
32002
+ version: VERSION
32003
+ },
32004
+ {
32005
+ capabilities: {}
32006
+ }
32007
+ );
32008
+ try {
32009
+ await client.connect(transport);
32010
+ const result = await client.listTools();
32011
+ return result.tools;
32012
+ } finally {
32013
+ await client.close().catch(() => {
32014
+ });
32015
+ }
32016
+ }
32017
+ async function callRemoteProxyTool(options) {
32018
+ const proxy = createRemoteProxyContext({
32019
+ targetDir: options.targetDir,
32020
+ exposedTools: MAKER_REMOTE_PROXY_EXPOSED_TOOL_NAMES
32021
+ });
32022
+ const finalArgs = prepareRemoteProxyToolArgs({
32023
+ toolName: options.name,
32024
+ targetDir: proxy.projectRoot,
32025
+ args: options.args
32026
+ });
32027
+ const result = await retryMakerProxyOperation(
32028
+ async () => {
32029
+ const transport = new StdioClientTransport({
32030
+ command: proxy.command,
32031
+ args: proxy.args,
32032
+ env: mergeStringEnv(process.env, proxy.envVars),
32033
+ stderr: "pipe"
32034
+ });
32035
+ const client = new Client(
32036
+ {
32037
+ name: "taptap-maker-tool-call-forwarder",
32038
+ version: VERSION
32039
+ },
32040
+ {
32041
+ capabilities: {}
32042
+ }
32043
+ );
32044
+ try {
32045
+ await client.connect(transport);
32046
+ return await client.callTool(
32047
+ {
32048
+ name: options.name,
32049
+ arguments: finalArgs
32050
+ },
32051
+ void 0,
32052
+ {
32053
+ timeout: DEFAULT_BUILD_TIMEOUT_MS,
32054
+ resetTimeoutOnProgress: true,
32055
+ onprogress: options.progressToken ? (progress) => {
32056
+ options.extra.sendNotification({
32057
+ method: "notifications/progress",
32058
+ params: { progressToken: options.progressToken, ...progress }
32059
+ }).catch(() => {
32060
+ });
32061
+ } : void 0
32062
+ }
32063
+ );
32064
+ } finally {
32065
+ await client.close().catch(() => {
32066
+ });
32067
+ }
32068
+ },
32069
+ {
32070
+ onRetry: options.progressToken ? (event) => {
32071
+ options.extra.sendNotification({
32072
+ method: "notifications/progress",
32073
+ params: {
32074
+ progressToken: options.progressToken,
32075
+ progress: event.attempt,
32076
+ total: event.attempts,
32077
+ message: event.message
32078
+ }
32079
+ }).catch(() => {
32080
+ });
32081
+ } : void 0
32082
+ }
32083
+ );
32084
+ return await materializeRemoteProxyToolAssets({
32085
+ toolName: options.name,
32086
+ targetDir: proxy.projectRoot,
32087
+ result
32088
+ });
32089
+ }
31320
32090
  async function startMakerMcpServer() {
31321
32091
  const server = new Server(
31322
32092
  {
@@ -31330,7 +32100,10 @@ async function startMakerMcpServer() {
31330
32100
  }
31331
32101
  }
31332
32102
  );
31333
- server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools }));
32103
+ server.setRequestHandler(
32104
+ ListToolsRequestSchema,
32105
+ async () => listMakerTools({ targetDir: process.cwd() })
32106
+ );
31334
32107
  server.setRequestHandler(ListResourcesRequestSchema, async () => ({ resources }));
31335
32108
  server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
31336
32109
  const uri = request.params.uri;
@@ -31348,7 +32121,7 @@ async function startMakerMcpServer() {
31348
32121
  };
31349
32122
  });
31350
32123
  server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
31351
- var _a3;
32124
+ var _a3, _b;
31352
32125
  const name = request.params.name;
31353
32126
  try {
31354
32127
  if (name === "maker_status_lite") {
@@ -31404,6 +32177,15 @@ async function startMakerMcpServer() {
31404
32177
  ]
31405
32178
  };
31406
32179
  }
32180
+ if (isExposedRemoteProxyTool(name)) {
32181
+ return await callRemoteProxyTool({
32182
+ targetDir: process.cwd(),
32183
+ name,
32184
+ args: request.params.arguments || {},
32185
+ progressToken: (_b = request.params._meta) == null ? void 0 : _b.progressToken,
32186
+ extra
32187
+ });
32188
+ }
31407
32189
  throw new McpError(ErrorCode.MethodNotFound, `Unknown Maker tool: ${name}`);
31408
32190
  } catch (error2) {
31409
32191
  return {
@@ -31473,6 +32255,8 @@ async function formatStatus(options = {}) {
31473
32255
  "",
31474
32256
  remoteSyncText,
31475
32257
  "",
32258
+ identify.projectRoot ? await formatMakerProxyToolsStatusSafely({ targetDir: identify.projectRoot }) : "",
32259
+ "",
31476
32260
  pat ? "" : ["Auth next step", "", `Maker PAT 缺失。PAT 页面:${makerPatTokensUrl}`].join("\n"),
31477
32261
  "",
31478
32262
  tapAuthRefreshText,
@@ -31503,6 +32287,81 @@ async function formatMakerRemoteSyncStatusSafely(projectRoot) {
31503
32287
  return formatMakerRemoteSyncUnavailable(error2);
31504
32288
  }
31505
32289
  }
32290
+ async function formatMakerProxyToolsStatusSafely(options) {
32291
+ try {
32292
+ const listedRemoteTools = options.listRemoteTools ?? (() => listRemoteProxyTools({
32293
+ targetDir: options.targetDir
32294
+ }));
32295
+ const availableTools = filterExposedRemoteProxyTools(await listedRemoteTools()).map(
32296
+ (tool) => tool.name
32297
+ );
32298
+ const missingTools = MAKER_REMOTE_PROXY_EXPOSED_TOOL_NAMES.filter(
32299
+ (toolName) => !availableTools.includes(toolName)
32300
+ );
32301
+ const status = missingTools.length === 0 ? "ok" : "degraded";
32302
+ return [
32303
+ "Maker proxy tools",
32304
+ "",
32305
+ `- status: ${status}`,
32306
+ `- available_tools: ${availableTools.join(", ") || "(none)"}`,
32307
+ `- missing_tools: ${missingTools.join(", ") || "(none)"}`,
32308
+ "- build_available: yes",
32309
+ status === "ok" ? "- next_action: Maker proxy tools and remote build are available." : "- next_action: 部分 Maker proxy tools 未暴露;缺失的远端工具不可用,请检查 Maker MCP 配置或远端服务。"
32310
+ ].join("\n");
32311
+ } catch (error2) {
32312
+ return [
32313
+ "Maker proxy tools",
32314
+ "",
32315
+ "- status: unavailable",
32316
+ "- available_tools: (none)",
32317
+ `- missing_tools: ${MAKER_REMOTE_PROXY_EXPOSED_TOOL_NAMES.join(", ")}`,
32318
+ "- build_available: no",
32319
+ `- failure_message: ${error2 instanceof Error ? error2.message : String(error2)}`,
32320
+ "- retry_policy: explicit proxy tool/build calls retry 5 total attempts, 30s apart",
32321
+ "- next_action: Maker proxy 连接失败;远端 proxy tools 和 build 构建都不可用。请检查网络、PAT/TapTap token、Maker MCP 环境和远端服务后重试。"
32322
+ ].join("\n");
32323
+ }
32324
+ }
32325
+ async function retryMakerProxyOperation(operation, options = {}) {
32326
+ var _a3;
32327
+ const attempts = Math.max(1, options.attempts || DEFAULT_PROXY_RETRY_ATTEMPTS);
32328
+ const delayMs = Math.max(0, options.delayMs ?? DEFAULT_PROXY_RETRY_DELAY_MS);
32329
+ const sleep2 = options.sleep || sleepMs;
32330
+ const shouldRetry = options.shouldRetry || isRetryableMakerProxyError;
32331
+ let lastError;
32332
+ for (let attempt = 1; attempt <= attempts; attempt += 1) {
32333
+ try {
32334
+ return await operation();
32335
+ } catch (error2) {
32336
+ lastError = error2;
32337
+ if (attempt >= attempts || !shouldRetry(error2)) {
32338
+ throw error2;
32339
+ }
32340
+ const message = `Maker proxy connection failed on attempt ${attempt}/${attempts}; retrying in ${Math.round(
32341
+ delayMs / 1e3
32342
+ )}s. ${error2 instanceof Error ? error2.message : String(error2)}`;
32343
+ (_a3 = options.onRetry) == null ? void 0 : _a3.call(options, { attempt, attempts, delayMs, message });
32344
+ await sleep2(delayMs);
32345
+ }
32346
+ }
32347
+ throw lastError instanceof Error ? lastError : new Error(String(lastError));
32348
+ }
32349
+ function sleepMs(delayMs) {
32350
+ return new Promise((resolve) => {
32351
+ setTimeout(resolve, delayMs);
32352
+ });
32353
+ }
32354
+ function isRetryableMakerProxyError(error2) {
32355
+ const message = error2 instanceof Error ? error2.message : String(error2);
32356
+ if (/\bBUILD FAILED\b|validation|invalid arguments|bad request|forbidden|unauthorized/i.test(
32357
+ message
32358
+ )) {
32359
+ return false;
32360
+ }
32361
+ return /connect|connection|ECONN|ETIMEDOUT|EAI_AGAIN|ENOTFOUND|timeout|timed out|socket|closed|reset|refused|network|fetch failed|transport/i.test(
32362
+ message
32363
+ );
32364
+ }
31506
32365
  function formatMakerRemoteSyncUnavailable(error2) {
31507
32366
  const message = error2 instanceof Error ? error2.message : String(error2);
31508
32367
  return [
@@ -31574,7 +32433,7 @@ function formatAiDialogueDirectoryHint(targetDir) {
31574
32433
  }
31575
32434
  function resolveMakerToolTargetDir(targetDir) {
31576
32435
  if (targetDir) {
31577
- return path8.resolve(targetDir);
32436
+ return path9.resolve(targetDir);
31578
32437
  }
31579
32438
  return process.cwd();
31580
32439
  }
@@ -31664,14 +32523,14 @@ function formatStatusProjectList(projects) {
31664
32523
  ].filter((line) => line !== void 0).join("\n");
31665
32524
  }
31666
32525
  function formatClonePartialStateLines(targetDir) {
31667
- const resolvedTargetDir = path8.resolve(targetDir);
32526
+ const resolvedTargetDir = path9.resolve(targetDir);
31668
32527
  const identify = identifyMakerProject({ cwd: resolvedTargetDir });
31669
32528
  const gitStatus = inspectMakerDirectoryGitStatus(resolvedTargetDir);
31670
32529
  const devKitStatus = inspectAiDevKit(resolvedTargetDir);
31671
- const stagedDevKitGitignorePath = path8.join(resolvedTargetDir, DEV_KIT_GITIGNORE_STAGING_FILE);
32530
+ const stagedDevKitGitignorePath = path9.join(resolvedTargetDir, DEV_KIT_GITIGNORE_STAGING_FILE);
31672
32531
  const projectBound = Boolean(identify.projectId);
31673
32532
  const gitInitialized = Boolean(
31674
- gitStatus.isOwnGitRoot || fs7.existsSync(path8.join(resolvedTargetDir, ".git"))
32533
+ gitStatus.isOwnGitRoot || fs8.existsSync(path9.join(resolvedTargetDir, ".git"))
31675
32534
  );
31676
32535
  const safeToRetry = !projectBound;
31677
32536
  return [
@@ -31685,7 +32544,7 @@ function formatClonePartialStateLines(targetDir) {
31685
32544
  identify.configPath ? `- config: ${identify.configPath}` : "",
31686
32545
  `- ai_dev_kit_present: ${devKitStatus.ready ? "yes" : "no"}`,
31687
32546
  `- ai_dev_kit_missing_entries: ${devKitStatus.missingEntries.join(", ") || "(none)"}`,
31688
- `- staged_dev_kit_gitignore: ${fs7.existsSync(stagedDevKitGitignorePath) ? "yes" : "no"}`,
32547
+ `- staged_dev_kit_gitignore: ${fs8.existsSync(stagedDevKitGitignorePath) ? "yes" : "no"}`,
31689
32548
  `- safe_to_retry: ${safeToRetry ? "yes" : "no"}`,
31690
32549
  safeToRetry ? "- next_step: 可以直接重试 taptap-maker init;如果连续失败,建议换一个全新的独立目录重新 clone。" : "- next_step: 当前目录已经有 Maker 绑定信息;先运行 taptap-maker doctor 或读取 maker://status 确认状态。"
31691
32550
  ].filter(Boolean);
@@ -31729,7 +32588,10 @@ function createRemoteProxyContext(options) {
31729
32588
  token_type: tapAuth.token_type || "mac",
31730
32589
  mac_algorithm: tapAuth.mac_algorithm || "hmac-sha-1"
31731
32590
  },
31732
- options: { verbose: true }
32591
+ options: {
32592
+ verbose: true,
32593
+ exposed_tools: options.exposedTools
32594
+ }
31733
32595
  };
31734
32596
  const proxyConfigJson = JSON.stringify(proxyCfg);
31735
32597
  const proxyServer = resolveEmbeddedProxyCommand();
@@ -31755,7 +32617,7 @@ function resolveEmbeddedProxyCommand(options) {
31755
32617
  }
31756
32618
  return {
31757
32619
  command: process.execPath,
31758
- args: [path8.resolve(makerEntry), "__maker-proxy"]
32620
+ args: [path9.resolve(makerEntry), "__maker-proxy"]
31759
32621
  };
31760
32622
  }
31761
32623
  function createToolProgressReporter(progressToken, extra, operationName) {
@@ -31918,67 +32780,83 @@ async function runRemoteBuildCurrentDirectory(options, targetDir) {
31918
32780
  });
31919
32781
  const buildArgs = createBuildArgs(proxy.projectRoot, options);
31920
32782
  const timeoutMs = options.timeoutMs || DEFAULT_BUILD_TIMEOUT_MS;
31921
- const transport = new StdioClientTransport({
31922
- command: proxy.command,
31923
- args: proxy.args,
31924
- env: mergeStringEnv(process.env, proxy.envVars),
31925
- stderr: "pipe"
31926
- });
31927
- const client = new Client(
31928
- {
31929
- name: "taptap-maker-build-forwarder",
31930
- version: VERSION
32783
+ const result = await retryMakerProxyOperation(
32784
+ async () => {
32785
+ const transport = new StdioClientTransport({
32786
+ command: proxy.command,
32787
+ args: proxy.args,
32788
+ env: mergeStringEnv(process.env, proxy.envVars),
32789
+ stderr: "pipe"
32790
+ });
32791
+ const client = new Client(
32792
+ {
32793
+ name: "taptap-maker-build-forwarder",
32794
+ version: VERSION
32795
+ },
32796
+ {
32797
+ capabilities: {}
32798
+ }
32799
+ );
32800
+ try {
32801
+ await client.connect(transport);
32802
+ return await client.callTool(
32803
+ {
32804
+ name: "build",
32805
+ arguments: buildArgs
32806
+ },
32807
+ void 0,
32808
+ {
32809
+ timeout: timeoutMs,
32810
+ resetTimeoutOnProgress: true,
32811
+ onprogress: (progress) => {
32812
+ var _a3;
32813
+ (_a3 = options.onProgress) == null ? void 0 : _a3.call(options, {
32814
+ progress: progress.progress,
32815
+ total: progress.total,
32816
+ phase: "remote_build",
32817
+ message: progress.message || "Remote Maker build progress"
32818
+ });
32819
+ }
32820
+ }
32821
+ );
32822
+ } finally {
32823
+ await client.close().catch(() => {
32824
+ });
32825
+ }
31931
32826
  },
31932
32827
  {
31933
- capabilities: {}
31934
- }
31935
- );
31936
- try {
31937
- await client.connect(transport);
31938
- const result = await client.callTool(
31939
- {
31940
- name: "build",
31941
- arguments: buildArgs
31942
- },
31943
- void 0,
31944
- {
31945
- timeout: timeoutMs,
31946
- resetTimeoutOnProgress: true,
31947
- onprogress: (progress) => {
31948
- var _a3;
31949
- (_a3 = options.onProgress) == null ? void 0 : _a3.call(options, {
31950
- progress: progress.progress,
31951
- total: progress.total,
31952
- phase: "remote_build",
31953
- message: progress.message || "Remote Maker build progress"
31954
- });
31955
- }
32828
+ onRetry: (event) => {
32829
+ var _a3;
32830
+ (_a3 = options.onProgress) == null ? void 0 : _a3.call(options, {
32831
+ progress: event.attempt,
32832
+ total: event.attempts,
32833
+ phase: "remote_build",
32834
+ message: event.message
32835
+ });
31956
32836
  }
31957
- );
31958
- if (isRemoteToolError(result)) {
31959
- throw new Error(formatRemoteToolResult(result));
31960
32837
  }
31961
- return attachBuildSuccessSideEffects(
31962
- {
31963
- mode: "remote_build",
31964
- projectRoot: proxy.projectRoot,
31965
- projectId: proxy.projectId,
31966
- projectPath: proxy.projectPath,
31967
- serverUrl: proxy.serverUrl,
31968
- env: proxy.env,
31969
- makerUrl: formatMakerAppWebUrl(proxy.projectId, proxy.env),
31970
- timeoutMs,
31971
- buildArgs,
31972
- resultText: formatRemoteToolResult(result)
31973
- },
31974
- {
31975
- refreshPreview: options.refreshPreview,
31976
- startRuntimeLogWatch: options.startRuntimeLogWatch || startRuntimeLogWatch
31977
- }
31978
- );
31979
- } finally {
31980
- await client.close();
32838
+ );
32839
+ if (isRemoteToolError(result)) {
32840
+ throw new Error(formatRemoteToolResult(result));
31981
32841
  }
32842
+ return attachBuildSuccessSideEffects(
32843
+ {
32844
+ mode: "remote_build",
32845
+ projectRoot: proxy.projectRoot,
32846
+ projectId: proxy.projectId,
32847
+ projectPath: proxy.projectPath,
32848
+ serverUrl: proxy.serverUrl,
32849
+ env: proxy.env,
32850
+ makerUrl: formatMakerAppWebUrl(proxy.projectId, proxy.env),
32851
+ timeoutMs,
32852
+ buildArgs,
32853
+ resultText: formatRemoteToolResult(result)
32854
+ },
32855
+ {
32856
+ refreshPreview: options.refreshPreview,
32857
+ startRuntimeLogWatch: options.startRuntimeLogWatch || startRuntimeLogWatch
32858
+ }
32859
+ );
31982
32860
  }
31983
32861
  async function attachBuildSuccessSideEffects(buildResult, options) {
31984
32862
  if (isRemoteBuildFailureResult(buildResult)) {
@@ -32041,18 +32919,18 @@ async function attachRuntimeLogWatch(buildResult, startWatch) {
32041
32919
  }
32042
32920
  }
32043
32921
  async function startRuntimeLogWatch(buildResult) {
32044
- const runtimeDir = path8.join(buildResult.projectRoot, ".maker", "logs", "runtime");
32045
- fs7.mkdirSync(runtimeDir, { recursive: true });
32046
- const stdoutLog = path8.join(runtimeDir, "watcher.out.log");
32047
- const stderrLog = path8.join(runtimeDir, "watcher.err.log");
32048
- const pidFile = path8.join(runtimeDir, "watcher.pid");
32922
+ const runtimeDir = path9.join(buildResult.projectRoot, ".maker", "logs", "runtime");
32923
+ fs8.mkdirSync(runtimeDir, { recursive: true });
32924
+ const stdoutLog = path9.join(runtimeDir, "watcher.out.log");
32925
+ const stderrLog = path9.join(runtimeDir, "watcher.err.log");
32926
+ const pidFile = path9.join(runtimeDir, "watcher.pid");
32049
32927
  const previous = stopExistingRuntimeLogWatcher(pidFile);
32050
- const outFd = fs7.openSync(stdoutLog, "a");
32051
- const errFd = fs7.openSync(stderrLog, "a");
32928
+ const outFd = fs8.openSync(stdoutLog, "a");
32929
+ const errFd = fs8.openSync(stderrLog, "a");
32052
32930
  const command = formatRuntimeLogWatchCommand(buildResult);
32053
32931
  if (previous.previousStopError) {
32054
- fs7.closeSync(outFd);
32055
- fs7.closeSync(errFd);
32932
+ fs8.closeSync(outFd);
32933
+ fs8.closeSync(errFd);
32056
32934
  return {
32057
32935
  started: false,
32058
32936
  command: command.text,
@@ -32115,18 +32993,18 @@ async function startRuntimeLogWatch(buildResult) {
32115
32993
  ...previous
32116
32994
  };
32117
32995
  } finally {
32118
- fs7.closeSync(outFd);
32119
- fs7.closeSync(errFd);
32996
+ fs8.closeSync(outFd);
32997
+ fs8.closeSync(errFd);
32120
32998
  }
32121
32999
  }
32122
33000
  function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
32123
- if (!fs7.existsSync(pidFile)) {
33001
+ if (!fs8.existsSync(pidFile)) {
32124
33002
  return {};
32125
33003
  }
32126
33004
  const pidState = readRuntimeLogWatcherPidState(pidFile);
32127
33005
  const pid = pidState == null ? void 0 : pidState.pid;
32128
33006
  if (!Number.isInteger(pid) || pid <= 0) {
32129
- fs7.rmSync(pidFile, { force: true });
33007
+ fs8.rmSync(pidFile, { force: true });
32130
33008
  return {};
32131
33009
  }
32132
33010
  try {
@@ -32134,7 +33012,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
32134
33012
  const processCommand = (options.getProcessCommand || getProcessCommand)(pid);
32135
33013
  const verifiedCommand = getVerifiedRuntimeLogWatcherCommand(processCommand, pidState);
32136
33014
  if (!verifiedCommand) {
32137
- fs7.rmSync(pidFile, { force: true });
33015
+ fs8.rmSync(pidFile, { force: true });
32138
33016
  return {
32139
33017
  previousPid: pid,
32140
33018
  previousStopped: false,
@@ -32144,7 +33022,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
32144
33022
  process.kill(pid, "SIGTERM");
32145
33023
  const stopped = (options.waitForExit || waitForProcessExit)(pid, WATCHER_STOP_TIMEOUT_MS);
32146
33024
  if (stopped) {
32147
- fs7.rmSync(pidFile, { force: true });
33025
+ fs8.rmSync(pidFile, { force: true });
32148
33026
  return { previousPid: pid, previousStopped: true };
32149
33027
  }
32150
33028
  return {
@@ -32153,7 +33031,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
32153
33031
  previousStopError: `process ${pid} did not exit after SIGTERM within ${WATCHER_STOP_TIMEOUT_MS}ms`
32154
33032
  };
32155
33033
  } catch (error2) {
32156
- fs7.rmSync(pidFile, { force: true });
33034
+ fs8.rmSync(pidFile, { force: true });
32157
33035
  const code = error2 && typeof error2 === "object" && "code" in error2 ? String(error2.code) : "";
32158
33036
  if (code === "ESRCH") {
32159
33037
  return { previousPid: pid, previousStopped: false };
@@ -32166,7 +33044,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
32166
33044
  }
32167
33045
  }
32168
33046
  function readRuntimeLogWatcherPidState(pidFile) {
32169
- const raw = fs7.readFileSync(pidFile, "utf8").trim();
33047
+ const raw = fs8.readFileSync(pidFile, "utf8").trim();
32170
33048
  if (!raw) {
32171
33049
  return null;
32172
33050
  }
@@ -32182,7 +33060,7 @@ function readRuntimeLogWatcherPidState(pidFile) {
32182
33060
  }
32183
33061
  }
32184
33062
  function writeRuntimeLogWatcherPidFile(pidFile, state) {
32185
- fs7.writeFileSync(pidFile, `${JSON.stringify(state, null, 2)}
33063
+ fs8.writeFileSync(pidFile, `${JSON.stringify(state, null, 2)}
32186
33064
  `, "utf8");
32187
33065
  }
32188
33066
  function getProcessCommand(pid) {
@@ -32268,10 +33146,10 @@ function formatRuntimeLogWatchCommand(buildResult) {
32268
33146
  };
32269
33147
  }
32270
33148
  function resolveMakerCliEntry() {
32271
- return process.argv[1] || path8.resolve(process.cwd(), "dist", "maker.js");
33149
+ return process.argv[1] || path9.resolve(process.cwd(), "dist", "maker.js");
32272
33150
  }
32273
33151
  function getRuntimeLogFilePath(projectRoot) {
32274
- return path8.join(projectRoot, ".maker", "logs", "runtime", "runtime.log");
33152
+ return path9.join(projectRoot, ".maker", "logs", "runtime", "runtime.log");
32275
33153
  }
32276
33154
  async function refreshMakerPreview(buildResult) {
32277
33155
  const makerEnv = buildResult.env === "rnd" || buildResult.env === "production" ? buildResult.env : void 0;
@@ -32402,7 +33280,7 @@ function createBuildArgs(projectRoot, options) {
32402
33280
  if (options.scriptsPath) {
32403
33281
  buildArgs.scriptsPath = options.scriptsPath;
32404
33282
  }
32405
- if (!options.entry && !options.scriptsPath && !options.entryClient && !options.entryServer && !options.multiplayer && fs7.existsSync(path8.join(projectRoot, "scripts", "main.lua"))) {
33283
+ if (!options.entry && !options.scriptsPath && !options.entryClient && !options.entryServer && !options.multiplayer && fs8.existsSync(path9.join(projectRoot, "scripts", "main.lua"))) {
32406
33284
  buildArgs.entry = "main.lua";
32407
33285
  buildArgs.scriptsPath = "scripts";
32408
33286
  }
@@ -32414,7 +33292,7 @@ function createBuildArgs(projectRoot, options) {
32414
33292
  }
32415
33293
  if (options.multiplayer) {
32416
33294
  buildArgs.multiplayer = options.multiplayer;
32417
- } else if (!fs7.existsSync(path8.join(projectRoot, ".project", "settings.json"))) {
33295
+ } else if (!fs8.existsSync(path9.join(projectRoot, ".project", "settings.json"))) {
32418
33296
  buildArgs.multiplayer = { enabled: false };
32419
33297
  }
32420
33298
  return buildArgs;
@@ -32471,7 +33349,7 @@ function formatBuildResult(result, progressSummary) {
32471
33349
  }
32472
33350
  if (result.mode === "submit_failed_before_build") {
32473
33351
  return [
32474
- result.submitResult.pushed ? "✓ Maker project submitted; remote build was not started" : result.submitResult.status === "clean" ? "Maker project has no changes to submit; remote build was not started" : "✗ Maker project submit failed; remote build was not started",
33352
+ result.submitResult.failure ? "✗ Maker project submit blocked before commit/push; remote build was not started" : result.submitResult.pushed ? "✓ Maker project submitted; remote build was not started" : result.submitResult.status === "clean" ? "Maker project has no changes to submit; remote build was not started" : "✗ Maker project submit failed; remote build was not started",
32475
33353
  "",
32476
33354
  `- project_root: ${result.projectRoot}`,
32477
33355
  `- project_id: ${result.projectId}`,
@@ -32576,11 +33454,11 @@ function formatRuntimeLogWatchNextActionLines(result) {
32576
33454
  ((_a3 = result.runtimeLogWatch) == null ? void 0 : _a3.pid) ? `- watch_pid: ${result.runtimeLogWatch.pid}` : "",
32577
33455
  `- watch_command: ${command}`,
32578
33456
  ((_b = result.runtimeLogWatch) == null ? void 0 : _b.command) ? `- actual_watch_command: ${result.runtimeLogWatch.command}` : "",
32579
- `- local_file: ${path8.join(result.projectRoot, ".maker", "logs", "runtime", "runtime.log")}`,
33457
+ `- local_file: ${path9.join(result.projectRoot, ".maker", "logs", "runtime", "runtime.log")}`,
32580
33458
  ((_c = result.runtimeLogWatch) == null ? void 0 : _c.stdoutLog) ? `- watcher_stdout: ${result.runtimeLogWatch.stdoutLog}` : "",
32581
33459
  ((_d = result.runtimeLogWatch) == null ? void 0 : _d.stderrLog) ? `- watcher_stderr: ${result.runtimeLogWatch.stderrLog}` : "",
32582
33460
  ((_e = result.runtimeLogWatch) == null ? void 0 : _e.pidFile) ? `- watcher_pid_file: ${result.runtimeLogWatch.pidFile}` : "",
32583
- `- state_file: ${path8.join(result.projectRoot, ".maker", "logs", "runtime", "state.json")}`,
33461
+ `- state_file: ${path9.join(result.projectRoot, ".maker", "logs", "runtime", "state.json")}`,
32584
33462
  ((_f = result.runtimeLogWatch) == null ? void 0 : _f.previousPid) ? `- previous_watch_pid: ${result.runtimeLogWatch.previousPid}` : "",
32585
33463
  ((_g = result.runtimeLogWatch) == null ? void 0 : _g.previousStopped) !== void 0 ? `- previous_watch_stopped: ${result.runtimeLogWatch.previousStopped ? "yes" : "no"}` : "",
32586
33464
  ((_h = result.runtimeLogWatch) == null ? void 0 : _h.previousStopError) ? `- previous_watch_stop_error: ${result.runtimeLogWatch.previousStopError}` : "",
@@ -32697,9 +33575,9 @@ function indent(value) {
32697
33575
  // src/maker/cli/commands.ts
32698
33576
  import { spawnSync as spawnSync4 } from "node:child_process";
32699
33577
  import crypto from "node:crypto";
32700
- import fs8 from "node:fs";
33578
+ import fs9 from "node:fs";
32701
33579
  import os4 from "node:os";
32702
- import path9 from "node:path";
33580
+ import path10 from "node:path";
32703
33581
  import readline from "node:readline/promises";
32704
33582
  import { stdin as input, stdout as output } from "node:process";
32705
33583
  var DEFAULT_MCP_NAME = "taptap-maker";
@@ -32810,7 +33688,7 @@ function toOptionKey(value) {
32810
33688
  }
32811
33689
  async function runInit(parsed, ctx) {
32812
33690
  rejectPackageOption(parsed);
32813
- const targetDir = path9.resolve(stringOption(parsed, "target_dir") || process.cwd());
33691
+ const targetDir = path10.resolve(stringOption(parsed, "target_dir") || process.cwd());
32814
33692
  const env = makerEnvOption(parsed);
32815
33693
  const skipConfirm = booleanOption(parsed, "skip_confirm");
32816
33694
  const skipMcpInstall = booleanOption(parsed, "skip_mcp_install");
@@ -32891,7 +33769,7 @@ async function runInit(parsed, ctx) {
32891
33769
  });
32892
33770
  }
32893
33771
  async function runDoctor(parsed, ctx) {
32894
- const targetDir = path9.resolve(stringOption(parsed, "target_dir") || process.cwd());
33772
+ const targetDir = path10.resolve(stringOption(parsed, "target_dir") || process.cwd());
32895
33773
  const git = checkGitEnvironment();
32896
33774
  const pat = loadPat();
32897
33775
  const tapAuth = loadTapAuth();
@@ -32966,7 +33844,7 @@ async function runPatSet(parsed, ctx) {
32966
33844
  }
32967
33845
  async function resolvePatSet(parsed, ctx) {
32968
33846
  if (booleanOption(parsed, "pat_stdin") || booleanOption(parsed, "pat_from_stdin")) {
32969
- const pat = fs8.readFileSync(0, "utf8").trim();
33847
+ const pat = fs9.readFileSync(0, "utf8").trim();
32970
33848
  if (!pat) {
32971
33849
  throw new Error("No PAT found on stdin.");
32972
33850
  }
@@ -33094,7 +33972,7 @@ function getMcpVerifyNextSteps(mode, commandText) {
33094
33972
  ];
33095
33973
  }
33096
33974
  async function runDevKitUpdate(parsed, ctx) {
33097
- const targetDir = path9.resolve(stringOption(parsed, "target_dir") || process.cwd());
33975
+ const targetDir = path10.resolve(stringOption(parsed, "target_dir") || process.cwd());
33098
33976
  const result = await installAiDevKit({
33099
33977
  targetDir,
33100
33978
  preserveExisting: true
@@ -33104,7 +33982,7 @@ async function runDevKitUpdate(parsed, ctx) {
33104
33982
  emitDevKitSkillInstallerFailure(ctx, result.skillInstaller, "AI skills install failed");
33105
33983
  }
33106
33984
  async function runLogsWatch(parsed, ctx) {
33107
- const targetDir = path9.resolve(stringOption(parsed, "target_dir") || process.cwd());
33985
+ const targetDir = path10.resolve(stringOption(parsed, "target_dir") || process.cwd());
33108
33986
  const intervalMs = parseDurationMs(stringOption(parsed, "interval") || "5s");
33109
33987
  const timeoutMs = numberOption(parsed, "timeout_ms") ?? 60 * 1e3;
33110
33988
  const maxPolls = numberOption(parsed, "max_polls");
@@ -33114,9 +33992,9 @@ async function runLogsWatch(parsed, ctx) {
33114
33992
  serverUrl: stringOption(parsed, "server_url"),
33115
33993
  env: makerEnvOption(parsed)
33116
33994
  });
33117
- const runtimeDir = path9.join(proxy.projectRoot, ".maker", "logs", "runtime");
33118
- const runtimeLog = path9.join(runtimeDir, "runtime.log");
33119
- const pidFile = path9.join(runtimeDir, "watcher.pid");
33995
+ const runtimeDir = path10.join(proxy.projectRoot, ".maker", "logs", "runtime");
33996
+ const runtimeLog = path10.join(runtimeDir, "runtime.log");
33997
+ const pidFile = path10.join(runtimeDir, "watcher.pid");
33120
33998
  const replacedWatcher = registerRuntimeLogWatcherProcess(pidFile);
33121
33999
  const runtimeLogClient = createRemoteRuntimeLogClient(proxy, timeoutMs);
33122
34000
  emit(ctx, "logs_watch_start", "Maker runtime log watcher started", {
@@ -33161,10 +34039,10 @@ async function runLogsWatch(parsed, ctx) {
33161
34039
  }
33162
34040
  }
33163
34041
  function registerRuntimeLogWatcherProcess(pidFile) {
33164
- fs8.mkdirSync(path9.dirname(pidFile), { recursive: true });
34042
+ fs9.mkdirSync(path10.dirname(pidFile), { recursive: true });
33165
34043
  const existingPid = readPidFile(pidFile);
33166
34044
  const previous = existingPid && existingPid !== process.pid ? stopExistingRuntimeLogWatcher(pidFile) : {};
33167
- fs8.writeFileSync(
34045
+ fs9.writeFileSync(
33168
34046
  pidFile,
33169
34047
  `${JSON.stringify(
33170
34048
  {
@@ -33182,10 +34060,10 @@ function registerRuntimeLogWatcherProcess(pidFile) {
33182
34060
  return previous;
33183
34061
  }
33184
34062
  function readPidFile(pidFile) {
33185
- if (!fs8.existsSync(pidFile)) {
34063
+ if (!fs9.existsSync(pidFile)) {
33186
34064
  return void 0;
33187
34065
  }
33188
- const raw = fs8.readFileSync(pidFile, "utf8").trim();
34066
+ const raw = fs9.readFileSync(pidFile, "utf8").trim();
33189
34067
  let pid = Number(raw);
33190
34068
  if (!Number.isInteger(pid) || pid <= 0) {
33191
34069
  try {
@@ -33205,7 +34083,7 @@ function installRuntimeLogWatcherPidCleanup(pidFile) {
33205
34083
  }
33206
34084
  cleaned = true;
33207
34085
  if (readPidFile(pidFile) === process.pid) {
33208
- fs8.rmSync(pidFile, { force: true });
34086
+ fs9.rmSync(pidFile, { force: true });
33209
34087
  }
33210
34088
  };
33211
34089
  process.once("exit", cleanup);
@@ -33290,7 +34168,7 @@ async function prepareDevKit(targetDir, ctx, options = {}) {
33290
34168
  onStart: (event) => emitSkillInstallerStart(ctx, event)
33291
34169
  });
33292
34170
  writeDevKitStagedGitignore(
33293
- path9.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE),
34171
+ path10.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE),
33294
34172
  listPresentDevKitManagedEntries(targetDir)
33295
34173
  );
33296
34174
  if (options.finalizeGitignore) {
@@ -33307,7 +34185,7 @@ async function prepareDevKit(targetDir, ctx, options = {}) {
33307
34185
  );
33308
34186
  } catch (error2) {
33309
34187
  writeDevKitStagedGitignore(
33310
- path9.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE),
34188
+ path10.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE),
33311
34189
  listPresentDevKitManagedEntries(targetDir)
33312
34190
  );
33313
34191
  if (options.finalizeGitignore) {
@@ -33400,7 +34278,7 @@ function installMcpConfig(ide, options) {
33400
34278
  }
33401
34279
  function installMcpConfigUnsafe(ide, options) {
33402
34280
  if (ide === "codex") {
33403
- const configPath = path9.join(os4.homedir(), ".codex", "config.toml");
34281
+ const configPath = path10.join(os4.homedir(), ".codex", "config.toml");
33404
34282
  mergeCodexMcpConfig(configPath, options);
33405
34283
  return {
33406
34284
  ide,
@@ -33410,7 +34288,7 @@ function installMcpConfigUnsafe(ide, options) {
33410
34288
  };
33411
34289
  }
33412
34290
  if (ide === "cursor") {
33413
- const configPath = path9.join(os4.homedir(), ".cursor", "mcp.json");
34291
+ const configPath = path10.join(os4.homedir(), ".cursor", "mcp.json");
33414
34292
  mergeJsonMcpConfig(configPath, options);
33415
34293
  return {
33416
34294
  ide,
@@ -33424,7 +34302,7 @@ function installMcpConfigUnsafe(ide, options) {
33424
34302
  if (claudeResult.ok) {
33425
34303
  return { ide, ok: true, message: "✓ Claude Code MCP config updated with claude mcp add" };
33426
34304
  }
33427
- const configPath = path9.join(os4.homedir(), ".claude.json");
34305
+ const configPath = path10.join(os4.homedir(), ".claude.json");
33428
34306
  mergeJsonMcpConfig(configPath, options);
33429
34307
  return {
33430
34308
  ide,
@@ -33441,13 +34319,13 @@ function mergeJsonMcpConfig(configPath, options) {
33441
34319
  const mcpServers = asObject(existing.mcpServers);
33442
34320
  mcpServers[options.mcpName] = createJsonMcpServerConfig(options);
33443
34321
  existing.mcpServers = mcpServers;
33444
- fs8.mkdirSync(path9.dirname(configPath), { recursive: true });
33445
- fs8.writeFileSync(configPath, `${JSON.stringify(existing, null, 2)}
34322
+ fs9.mkdirSync(path10.dirname(configPath), { recursive: true });
34323
+ fs9.writeFileSync(configPath, `${JSON.stringify(existing, null, 2)}
33446
34324
  `, "utf8");
33447
34325
  }
33448
34326
  function mergeCodexMcpConfig(configPath, options) {
33449
34327
  const backupPath = backupIfExists(configPath);
33450
- const existing = fs8.existsSync(configPath) ? fs8.readFileSync(configPath, "utf8") : "";
34328
+ const existing = fs9.existsSync(configPath) ? fs9.readFileSync(configPath, "utf8") : "";
33451
34329
  const sectionPattern = createCodexMcpSectionPattern(options.mcpName);
33452
34330
  const withoutOld = existing.replace(sectionPattern, "").trimEnd();
33453
34331
  const command = getNpxCommand();
@@ -33460,9 +34338,9 @@ function mergeCodexMcpConfig(configPath, options) {
33460
34338
  `TAPTAP_MCP_ENV = "${options.env}"`,
33461
34339
  ""
33462
34340
  ].join("\n");
33463
- fs8.mkdirSync(path9.dirname(configPath), { recursive: true });
33464
- fs8.writeFileSync(configPath, [withoutOld, section].filter(Boolean).join("\n\n"), "utf8");
33465
- const updated = fs8.readFileSync(configPath, "utf8");
34341
+ fs9.mkdirSync(path10.dirname(configPath), { recursive: true });
34342
+ fs9.writeFileSync(configPath, [withoutOld, section].filter(Boolean).join("\n\n"), "utf8");
34343
+ const updated = fs9.readFileSync(configPath, "utf8");
33466
34344
  const duplicates = findCodexMcpTableDuplicates(updated, options.mcpName);
33467
34345
  if (duplicates.length > 0) {
33468
34346
  restoreBackup(configPath, backupPath);
@@ -33567,10 +34445,10 @@ function rejectPackageOption(parsed) {
33567
34445
  }
33568
34446
  }
33569
34447
  function readJsonObject(filePath) {
33570
- if (!fs8.existsSync(filePath)) {
34448
+ if (!fs9.existsSync(filePath)) {
33571
34449
  return {};
33572
34450
  }
33573
- return JSON.parse(fs8.readFileSync(filePath, "utf8"));
34451
+ return JSON.parse(fs9.readFileSync(filePath, "utf8"));
33574
34452
  }
33575
34453
  function asObject(value) {
33576
34454
  if (value && typeof value === "object" && !Array.isArray(value)) {
@@ -33579,26 +34457,26 @@ function asObject(value) {
33579
34457
  return {};
33580
34458
  }
33581
34459
  function backupIfExists(filePath) {
33582
- if (!fs8.existsSync(filePath)) {
34460
+ if (!fs9.existsSync(filePath)) {
33583
34461
  return void 0;
33584
34462
  }
33585
34463
  const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:]/g, "").replace(/\..+$/, "");
33586
34464
  const backupPath = `${filePath}.bak.${stamp}`;
33587
- fs8.copyFileSync(filePath, backupPath);
34465
+ fs9.copyFileSync(filePath, backupPath);
33588
34466
  return backupPath;
33589
34467
  }
33590
34468
  function restoreBackup(filePath, backupPath) {
33591
34469
  if (backupPath) {
33592
- fs8.copyFileSync(backupPath, filePath);
34470
+ fs9.copyFileSync(backupPath, filePath);
33593
34471
  return;
33594
34472
  }
33595
- fs8.rmSync(filePath, { force: true });
34473
+ fs9.rmSync(filePath, { force: true });
33596
34474
  }
33597
34475
  function saveInitState(targetDir, state) {
33598
- fs8.mkdirSync(getMakerHome(), { recursive: true });
33599
- const key = crypto.createHash("sha256").update(path9.resolve(targetDir)).digest("hex").slice(0, 16);
33600
- fs8.writeFileSync(
33601
- path9.join(getMakerHome(), `init-state-${key}.json`),
34476
+ fs9.mkdirSync(getMakerHome(), { recursive: true });
34477
+ const key = crypto.createHash("sha256").update(path10.resolve(targetDir)).digest("hex").slice(0, 16);
34478
+ fs9.writeFileSync(
34479
+ path10.join(getMakerHome(), `init-state-${key}.json`),
33602
34480
  `${JSON.stringify({ ...state, updated_at: (/* @__PURE__ */ new Date()).toISOString() }, null, 2)}
33603
34481
  `,
33604
34482
  "utf8"
@@ -33804,14 +34682,14 @@ function formatCliError(error2) {
33804
34682
  }
33805
34683
 
33806
34684
  // src/maker/crashLog.ts
33807
- import fs9 from "node:fs";
33808
- import path10 from "node:path";
34685
+ import fs10 from "node:fs";
34686
+ import path11 from "node:path";
33809
34687
  var DEFAULT_MAX_BYTES = 1024 * 1024;
33810
34688
  var DEFAULT_MAX_ENTRY_BYTES = 16 * 1024;
33811
34689
  function appendMakerCrashLog(source, error2, options = {}) {
33812
34690
  const makerHome = getMakerHome();
33813
- fs9.mkdirSync(makerHome, { recursive: true });
33814
- const logPath = path10.join(makerHome, "mcp-crash.log");
34691
+ fs10.mkdirSync(makerHome, { recursive: true });
34692
+ const logPath = path11.join(makerHome, "mcp-crash.log");
33815
34693
  const maxBytes = positiveInteger(options.maxBytes) || resolveEnvBytes("TAPTAP_MAKER_CRASH_LOG_MAX_BYTES", DEFAULT_MAX_BYTES);
33816
34694
  const maxEntryBytes = positiveInteger(options.maxEntryBytes) || resolveEnvBytes("TAPTAP_MAKER_CRASH_LOG_MAX_ENTRY_BYTES", DEFAULT_MAX_ENTRY_BYTES);
33817
34695
  const message = error2 instanceof Error ? error2.stack || error2.message : String(error2);
@@ -33821,31 +34699,31 @@ function appendMakerCrashLog(source, error2, options = {}) {
33821
34699
  );
33822
34700
  const entryBytes = Buffer.byteLength(entry, "utf8");
33823
34701
  rotateIfNeeded(logPath, maxBytes, entryBytes);
33824
- fs9.appendFileSync(logPath, entry, "utf8");
34702
+ fs10.appendFileSync(logPath, entry, "utf8");
33825
34703
  }
33826
34704
  function rotateIfNeeded(logPath, maxBytes, incomingBytes) {
33827
- if (!fs9.existsSync(logPath)) {
34705
+ if (!fs10.existsSync(logPath)) {
33828
34706
  return;
33829
34707
  }
33830
- const currentBytes = fs9.statSync(logPath).size;
34708
+ const currentBytes = fs10.statSync(logPath).size;
33831
34709
  if (currentBytes + incomingBytes <= maxBytes) {
33832
34710
  return;
33833
34711
  }
33834
34712
  const rotatedPath = `${logPath}.1`;
33835
34713
  writeFileTail(logPath, rotatedPath, maxBytes);
33836
- fs9.writeFileSync(logPath, "", "utf8");
34714
+ fs10.writeFileSync(logPath, "", "utf8");
33837
34715
  }
33838
34716
  function writeFileTail(sourcePath, targetPath, maxBytes) {
33839
- const size = fs9.statSync(sourcePath).size;
34717
+ const size = fs10.statSync(sourcePath).size;
33840
34718
  const bytesToRead = Math.min(size, maxBytes);
33841
34719
  const start = Math.max(0, size - bytesToRead);
33842
- const fd = fs9.openSync(sourcePath, "r");
34720
+ const fd = fs10.openSync(sourcePath, "r");
33843
34721
  try {
33844
34722
  const buffer = Buffer.alloc(bytesToRead);
33845
- fs9.readSync(fd, buffer, 0, bytesToRead, start);
33846
- fs9.writeFileSync(targetPath, buffer);
34723
+ fs10.readSync(fd, buffer, 0, bytesToRead, start);
34724
+ fs10.writeFileSync(targetPath, buffer);
33847
34725
  } finally {
33848
- fs9.closeSync(fd);
34726
+ fs10.closeSync(fd);
33849
34727
  }
33850
34728
  }
33851
34729
  function truncateUtf8(value, maxBytes) {
@@ -33918,6 +34796,7 @@ Received: ${configJson.substring(0, 100)}...`
33918
34796
  return applyDefaults(config2);
33919
34797
  }
33920
34798
  function validateConfig(config2) {
34799
+ var _a3;
33921
34800
  const errors = [];
33922
34801
  if (!config2.server) {
33923
34802
  errors.push("- Missing required field: server");
@@ -33957,13 +34836,21 @@ function validateConfig(config2) {
33957
34836
  errors.push('- Invalid auth.mac_algorithm: must be "hmac-sha-1"');
33958
34837
  }
33959
34838
  }
34839
+ if (((_a3 = config2.options) == null ? void 0 : _a3.exposed_tools) !== void 0) {
34840
+ const exposedTools = config2.options.exposed_tools;
34841
+ if (!Array.isArray(exposedTools)) {
34842
+ errors.push("- options.exposed_tools must be an array of tool names");
34843
+ } else if (!exposedTools.every((toolName) => typeof toolName === "string" && toolName.trim().length > 0)) {
34844
+ errors.push("- options.exposed_tools values must be non-empty strings");
34845
+ }
34846
+ }
33960
34847
  if (errors.length > 0) {
33961
34848
  throw new Error("Invalid configuration:\n" + errors.join("\n"));
33962
34849
  }
33963
34850
  }
33964
34851
  var DEFAULT_LOG_ROOT = "/tmp/taptap-mcp/logs";
33965
34852
  function applyDefaults(config2) {
33966
- var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
34853
+ var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
33967
34854
  const verbose = ((_a3 = config2.options) == null ? void 0 : _a3.verbose) ?? false;
33968
34855
  return {
33969
34856
  server: {
@@ -33988,12 +34875,13 @@ function applyDefaults(config2) {
33988
34875
  enable_cookie_sticky: ((_g = config2.options) == null ? void 0 : _g.enable_cookie_sticky) ?? true,
33989
34876
  inject_params_per_call: ((_h = config2.options) == null ? void 0 : _h.inject_params_per_call) ?? true,
33990
34877
  force_inject_progress_token: ((_i = config2.options) == null ? void 0 : _i.force_inject_progress_token) ?? false,
34878
+ exposed_tools: (_j = config2.options) == null ? void 0 : _j.exposed_tools,
33991
34879
  log: {
33992
- root: ((_k = (_j = config2.options) == null ? void 0 : _j.log) == null ? void 0 : _k.root) ?? DEFAULT_LOG_ROOT,
33993
- enabled: ((_m = (_l = config2.options) == null ? void 0 : _l.log) == null ? void 0 : _m.enabled) ?? false,
34880
+ root: ((_l = (_k = config2.options) == null ? void 0 : _k.log) == null ? void 0 : _l.root) ?? DEFAULT_LOG_ROOT,
34881
+ enabled: ((_n = (_m = config2.options) == null ? void 0 : _m.log) == null ? void 0 : _n.enabled) ?? false,
33994
34882
  // verbose=true 时自动使用 debug 级别
33995
- level: verbose ? "debug" : ((_o = (_n = config2.options) == null ? void 0 : _n.log) == null ? void 0 : _o.level) ?? "info",
33996
- max_days: ((_q = (_p = config2.options) == null ? void 0 : _p.log) == null ? void 0 : _q.max_days) ?? 7
34883
+ level: verbose ? "debug" : ((_p = (_o = config2.options) == null ? void 0 : _o.log) == null ? void 0 : _p.level) ?? "info",
34884
+ max_days: ((_r = (_q = config2.options) == null ? void 0 : _q.log) == null ? void 0 : _r.max_days) ?? 7
33997
34885
  }
33998
34886
  }
33999
34887
  };
@@ -35404,7 +36292,7 @@ var StreamableHTTPClientTransport = class {
35404
36292
  };
35405
36293
 
35406
36294
  // src/mcp-proxy/proxy.ts
35407
- import * as path12 from "node:path";
36295
+ import * as path13 from "node:path";
35408
36296
  import * as crypto4 from "node:crypto";
35409
36297
 
35410
36298
  // src/mcp-proxy/cookieJar.ts
@@ -35586,8 +36474,8 @@ function createCookieFetch(cookieJar) {
35586
36474
  }
35587
36475
 
35588
36476
  // src/core/utils/logWriter.ts
35589
- import * as fs10 from "node:fs";
35590
- import * as path11 from "node:path";
36477
+ import * as fs11 from "node:fs";
36478
+ import * as path12 from "node:path";
35591
36479
  import * as crypto3 from "node:crypto";
35592
36480
 
35593
36481
  // src/core/types/log.ts
@@ -35628,7 +36516,7 @@ var LogWriter = class {
35628
36516
  return;
35629
36517
  }
35630
36518
  try {
35631
- await fs10.promises.mkdir(this.config.logDir, { recursive: true });
36519
+ await fs11.promises.mkdir(this.config.logDir, { recursive: true });
35632
36520
  await this.cleanupOldLogs();
35633
36521
  this.initialized = true;
35634
36522
  } catch (error2) {
@@ -35651,7 +36539,7 @@ var LogWriter = class {
35651
36539
  */
35652
36540
  getLogFilePath(date5) {
35653
36541
  const d = date5 || this.getCurrentDate();
35654
- return path11.join(this.config.logDir, `${this.config.prefix}-${d}.log`);
36542
+ return path12.join(this.config.logDir, `${this.config.prefix}-${d}.log`);
35655
36543
  }
35656
36544
  /**
35657
36545
  * 获取或创建写入流
@@ -35666,7 +36554,7 @@ var LogWriter = class {
35666
36554
  }
35667
36555
  this.currentDate = date5;
35668
36556
  try {
35669
- this.writeStream = fs10.createWriteStream(this.getLogFilePath(date5), {
36557
+ this.writeStream = fs11.createWriteStream(this.getLogFilePath(date5), {
35670
36558
  flags: "a",
35671
36559
  encoding: "utf8"
35672
36560
  });
@@ -35718,11 +36606,11 @@ var LogWriter = class {
35718
36606
  if (this.shouldWriteToFile(level) && this.initialized && this.config.enabled) {
35719
36607
  try {
35720
36608
  const filePath = this.getLogFilePath();
35721
- const dir = path11.dirname(filePath);
35722
- if (!fs10.existsSync(dir)) {
35723
- fs10.mkdirSync(dir, { recursive: true });
36609
+ const dir = path12.dirname(filePath);
36610
+ if (!fs11.existsSync(dir)) {
36611
+ fs11.mkdirSync(dir, { recursive: true });
35724
36612
  }
35725
- fs10.appendFileSync(filePath, message, "utf8");
36613
+ fs11.appendFileSync(filePath, message, "utf8");
35726
36614
  } catch {
35727
36615
  }
35728
36616
  }
@@ -35733,7 +36621,7 @@ var LogWriter = class {
35733
36621
  async cleanupOldLogs() {
35734
36622
  if (this.config.maxDays <= 0) return;
35735
36623
  try {
35736
- const files = await fs10.promises.readdir(this.config.logDir);
36624
+ const files = await fs11.promises.readdir(this.config.logDir);
35737
36625
  const cutoffDate = /* @__PURE__ */ new Date();
35738
36626
  cutoffDate.setDate(cutoffDate.getDate() - this.config.maxDays);
35739
36627
  const prefix = this.config.prefix;
@@ -35748,7 +36636,7 @@ var LogWriter = class {
35748
36636
  if (!Number.isNaN(year) && !Number.isNaN(month) && !Number.isNaN(day)) {
35749
36637
  const fileDate = new Date(year, month - 1, day);
35750
36638
  if (fileDate < cutoffDate) {
35751
- await fs10.promises.unlink(path11.join(this.config.logDir, file2));
36639
+ await fs11.promises.unlink(path12.join(this.config.logDir, file2));
35752
36640
  process.stderr.write(`[LogWriter] Deleted old log: ${file2}
35753
36641
  `);
35754
36642
  }
@@ -35819,10 +36707,10 @@ var TapTapMCPProxy = class {
35819
36707
  const { user_id, project_id } = this.config.tenant;
35820
36708
  let logDir;
35821
36709
  if (user_id && project_id) {
35822
- logDir = path12.join(logRoot, "proxy", user_id, project_id);
36710
+ logDir = path13.join(logRoot, "proxy", user_id, project_id);
35823
36711
  } else {
35824
36712
  const kidHash = crypto4.createHash("sha256").update(this.config.auth.kid).digest("hex").substring(0, 8);
35825
- logDir = path12.join(logRoot, "proxy", kidHash);
36713
+ logDir = path13.join(logRoot, "proxy", kidHash);
35826
36714
  }
35827
36715
  return new LogWriter({
35828
36716
  logDir,
@@ -35942,6 +36830,37 @@ var TapTapMCPProxy = class {
35942
36830
  }
35943
36831
  return injected;
35944
36832
  }
36833
+ /**
36834
+ * Restrict the proxied tool list to the configured public surface.
36835
+ *
36836
+ * The proxy does not wrap or rewrite upstream tool definitions. It only hides tools that are not
36837
+ * included in options.exposed_tools. Omitting the option keeps the historical full passthrough.
36838
+ */
36839
+ filterListedTools(result) {
36840
+ var _a3;
36841
+ const exposedTools = (_a3 = this.config.options) == null ? void 0 : _a3.exposed_tools;
36842
+ if (!exposedTools) {
36843
+ return result;
36844
+ }
36845
+ const exposedToolNames = new Set(exposedTools);
36846
+ return {
36847
+ ...result,
36848
+ tools: result.tools.filter((tool) => exposedToolNames.has(tool.name))
36849
+ };
36850
+ }
36851
+ /**
36852
+ * Prevent callers from invoking tools hidden from tools/list.
36853
+ */
36854
+ assertToolExposed(name) {
36855
+ var _a3;
36856
+ const exposedTools = (_a3 = this.config.options) == null ? void 0 : _a3.exposed_tools;
36857
+ if (!exposedTools) {
36858
+ return;
36859
+ }
36860
+ if (!exposedTools.includes(name)) {
36861
+ throw new McpError(ErrorCode.MethodNotFound, `Tool is not exposed by this proxy: ${name}`);
36862
+ }
36863
+ }
35945
36864
  /**
35946
36865
  * 连接到 TapTap MCP Server
35947
36866
  */
@@ -36274,7 +37193,7 @@ var TapTapMCPProxy = class {
36274
37193
  );
36275
37194
  }
36276
37195
  const result = await this.client.listTools();
36277
- return result;
37196
+ return this.filterListedTools(result);
36278
37197
  });
36279
37198
  this.server.setRequestHandler(ListResourcesRequestSchema, async () => {
36280
37199
  if (!this.connected) {
@@ -36299,6 +37218,7 @@ var TapTapMCPProxy = class {
36299
37218
  this.server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
36300
37219
  var _a3, _b, _c, _d, _e, _f, _g;
36301
37220
  const { name, arguments: args } = request.params;
37221
+ this.assertToolExposed(name);
36302
37222
  const shouldInjectParams = ((_a3 = this.config.options) == null ? void 0 : _a3.inject_params_per_call) ?? true;
36303
37223
  const finalArgs = shouldInjectParams ? this.injectPrivateParams(args) : args;
36304
37224
  if ((_b = this.config.options) == null ? void 0 : _b.verbose) {