@taptap/maker 0.0.20 → 0.0.21-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/maker.js CHANGED
@@ -3233,8 +3233,8 @@ var require_utils = __commonJS({
3233
3233
  }
3234
3234
  return ind;
3235
3235
  }
3236
- function removeDotSegments(path18) {
3237
- let input2 = path18;
3236
+ function removeDotSegments(path19) {
3237
+ let input2 = path19;
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 [path18, query] = wsComponent.resourceName.split("?");
3437
- wsComponent.path = path18 && path18 !== "/" ? path18 : void 0;
3436
+ const [path19, query] = wsComponent.resourceName.split("?");
3437
+ wsComponent.path = path19 && path19 !== "/" ? path19 : 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, fs16, exportName) {
12494
+ function addFormats(ajv, list, fs17, 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, fs16[f]);
12499
+ ajv.addFormat(f, fs17[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 fs16 = __require("fs");
12513
- function checkPathExt(path18, options) {
12512
+ var fs17 = __require("fs");
12513
+ function checkPathExt(path19, 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 && path18.substr(-p.length).toLowerCase() === p) {
12524
+ if (p && path19.substr(-p.length).toLowerCase() === p) {
12525
12525
  return true;
12526
12526
  }
12527
12527
  }
12528
12528
  return false;
12529
12529
  }
12530
- function checkStat(stat, path18, options) {
12530
+ function checkStat(stat, path19, options) {
12531
12531
  if (!stat.isSymbolicLink() && !stat.isFile()) {
12532
12532
  return false;
12533
12533
  }
12534
- return checkPathExt(path18, options);
12534
+ return checkPathExt(path19, options);
12535
12535
  }
12536
- function isexe(path18, options, cb) {
12537
- fs16.stat(path18, function(er, stat) {
12538
- cb(er, er ? false : checkStat(stat, path18, options));
12536
+ function isexe(path19, options, cb) {
12537
+ fs17.stat(path19, function(er, stat) {
12538
+ cb(er, er ? false : checkStat(stat, path19, options));
12539
12539
  });
12540
12540
  }
12541
- function sync(path18, options) {
12542
- return checkStat(fs16.statSync(path18), path18, options);
12541
+ function sync(path19, options) {
12542
+ return checkStat(fs17.statSync(path19), path19, 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 fs16 = __require("fs");
12553
- function isexe(path18, options, cb) {
12554
- fs16.stat(path18, function(er, stat) {
12552
+ var fs17 = __require("fs");
12553
+ function isexe(path19, options, cb) {
12554
+ fs17.stat(path19, function(er, stat) {
12555
12555
  cb(er, er ? false : checkStat(stat, options));
12556
12556
  });
12557
12557
  }
12558
- function sync(path18, options) {
12559
- return checkStat(fs16.statSync(path18), options);
12558
+ function sync(path19, options) {
12559
+ return checkStat(fs17.statSync(path19), 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 fs16 = __require("fs");
12583
+ var fs17 = __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(path18, options, cb) {
12592
+ function isexe(path19, 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(path18, options || {}, function(er, is) {
12602
+ isexe(path19, 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(path18, options || {}, function(er, is) {
12611
+ core(path19, 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(path18, options) {
12621
+ function sync(path19, options) {
12622
12622
  try {
12623
- return core.sync(path18, options || {});
12623
+ return core.sync(path19, 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 path18 = __require("path");
12639
+ var path19 = __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 = path18.join(pathPart, cmd);
12677
+ const pCmd = path19.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 = path18.join(pathPart, cmd);
12704
+ const pCmd = path19.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 path18 = __require("path");
12752
+ var path19 = __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 ? path18.delimiter : void 0
12770
+ pathExt: withoutPathExt ? path19.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 = path18.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
12779
+ resolved = path19.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 [path18, argument] = match[0].replace(/#! ?/, "").split(" ");
12834
- const binary = path18.split("/").pop();
12833
+ const [path19, argument] = match[0].replace(/#! ?/, "").split(" ");
12834
+ const binary = path19.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 fs16 = __require("fs");
12847
+ var fs17 = __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 = fs16.openSync(command, "r");
12855
- fs16.readSync(fd, buffer, 0, size, 0);
12856
- fs16.closeSync(fd);
12854
+ fd = fs17.openSync(command, "r");
12855
+ fs17.readSync(fd, buffer, 0, size, 0);
12856
+ fs17.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 path18 = __require("path");
12869
+ var path19 = __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 = path18.normalize(parsed.command);
12894
+ parsed.command = path19.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, spawnSync as spawnSync6 } from "node:child_process";
13006
- import fs13 from "node:fs";
13007
- import path14 from "node:path";
13006
+ import fs14 from "node:fs";
13007
+ import path15 from "node:path";
13008
13008
  import { fileURLToPath as fileURLToPath2 } from "node:url";
13009
13009
 
13010
13010
  // node_modules/zod/v3/helpers/util.js
@@ -13366,8 +13366,8 @@ function getErrorMap() {
13366
13366
 
13367
13367
  // node_modules/zod/v3/helpers/parseUtil.js
13368
13368
  var makeIssue = (params) => {
13369
- const { data, path: path18, errorMaps, issueData } = params;
13370
- const fullPath = [...path18, ...issueData.path || []];
13369
+ const { data, path: path19, errorMaps, issueData } = params;
13370
+ const fullPath = [...path19, ...issueData.path || []];
13371
13371
  const fullIssue = {
13372
13372
  ...issueData,
13373
13373
  path: fullPath
@@ -13482,11 +13482,11 @@ var errorUtil;
13482
13482
 
13483
13483
  // node_modules/zod/v3/types.js
13484
13484
  var ParseInputLazyPath = class {
13485
- constructor(parent, value, path18, key) {
13485
+ constructor(parent, value, path19, key) {
13486
13486
  this._cachedPath = [];
13487
13487
  this.parent = parent;
13488
13488
  this.data = value;
13489
- this._path = path18;
13489
+ this._path = path19;
13490
13490
  this._key = key;
13491
13491
  }
13492
13492
  get path() {
@@ -17135,10 +17135,10 @@ function mergeDefs(...defs) {
17135
17135
  function cloneDef(schema) {
17136
17136
  return mergeDefs(schema._zod.def);
17137
17137
  }
17138
- function getElementAtPath(obj, path18) {
17139
- if (!path18)
17138
+ function getElementAtPath(obj, path19) {
17139
+ if (!path19)
17140
17140
  return obj;
17141
- return path18.reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
17141
+ return path19.reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
17142
17142
  }
17143
17143
  function promiseAllObject(promisesObj) {
17144
17144
  const keys = Object.keys(promisesObj);
@@ -17523,11 +17523,11 @@ function aborted(x, startIndex = 0) {
17523
17523
  }
17524
17524
  return false;
17525
17525
  }
17526
- function prefixIssues(path18, issues) {
17526
+ function prefixIssues(path19, issues) {
17527
17527
  return issues.map((iss) => {
17528
17528
  var _a3;
17529
17529
  (_a3 = iss).path ?? (_a3.path = []);
17530
- iss.path.unshift(path18);
17530
+ iss.path.unshift(path19);
17531
17531
  return iss;
17532
17532
  });
17533
17533
  }
@@ -32703,9 +32703,484 @@ function compactRuntimeLogEntry(entry) {
32703
32703
  return compact;
32704
32704
  }
32705
32705
 
32706
- // src/maker/server/proxyAssets.ts
32706
+ // src/maker/versionCheck.ts
32707
32707
  import fs12 from "node:fs";
32708
32708
  import path13 from "node:path";
32709
+ var DEFAULT_POLICY_URL = "https://raw.githubusercontent.com/taptap/instant-games-open-mcp/main/config/maker-version-policy.json";
32710
+ var POLICY_URL_ENV = "TAPTAP_MAKER_VERSION_POLICY_URL";
32711
+ var DEFAULT_PACKAGE_VERSION_CHECK_TIMEOUT_MS = 3e3;
32712
+ var PACKAGE_VERSION_CHECK_TTL_MS = 12 * 60 * 60 * 1e3;
32713
+ var PACKAGE_VERSION_CHECK_CACHE_FILE = "package-version-check.json";
32714
+ function decideMakerPackageUpdate(currentVersion, policy) {
32715
+ if (currentVersion === "dev") {
32716
+ return {
32717
+ status: "skipped",
32718
+ current_version: currentVersion,
32719
+ reason: "dev_version",
32720
+ latest: policy.latest,
32721
+ latest_beta: policy.latest_beta,
32722
+ minimum_supported: policy.minimum_supported,
32723
+ message: policy.message,
32724
+ next_action: "Continue normal work; dev builds do not use remote version policy.",
32725
+ restart_required: false
32726
+ };
32727
+ }
32728
+ const current = parseVersion(currentVersion);
32729
+ const latest = parseVersion(policy.latest);
32730
+ const latestBeta = parseVersion(policy.latest_beta);
32731
+ const minimumSupported = parseVersion(policy.minimum_supported);
32732
+ if (!current || !latest || !latestBeta || !minimumSupported) {
32733
+ throw new Error("Invalid version data for Maker package update decision.");
32734
+ }
32735
+ const isPrerelease = current.prerelease.length > 0;
32736
+ if (policy.blacklist.includes(currentVersion)) {
32737
+ return buildDecision("required_upgrade", currentVersion, policy, {
32738
+ reason: "blacklisted",
32739
+ target_version: isPrerelease ? policy.latest_beta : policy.latest,
32740
+ blacklist_match: currentVersion,
32741
+ restart_required: true,
32742
+ next_action: "Ask the user for approval, then run `taptap-maker upgrade --target-dir <PROJECT_DIR>`."
32743
+ });
32744
+ }
32745
+ if (compareVersions(current, minimumSupported) < 0) {
32746
+ return buildDecision("required_upgrade", currentVersion, policy, {
32747
+ reason: "below_minimum_supported",
32748
+ target_version: isPrerelease ? policy.latest_beta : policy.latest,
32749
+ restart_required: true,
32750
+ next_action: "Ask the user for approval, then run `taptap-maker upgrade --target-dir <PROJECT_DIR>`."
32751
+ });
32752
+ }
32753
+ if (isPrerelease && compareVersions(current, latestBeta) < 0) {
32754
+ return buildDecision("required_upgrade", currentVersion, policy, {
32755
+ reason: "beta_outdated",
32756
+ target_version: policy.latest_beta,
32757
+ restart_required: true,
32758
+ next_action: "Ask the user for approval, then run `taptap-maker upgrade --target-dir <PROJECT_DIR>`."
32759
+ });
32760
+ }
32761
+ if (!isPrerelease && compareVersions(current, latest) < 0) {
32762
+ return buildDecision("update_available", currentVersion, policy, {
32763
+ target_version: policy.latest,
32764
+ restart_required: false,
32765
+ next_action: "Tell the user an update is available. Only run `taptap-maker upgrade` after approval."
32766
+ });
32767
+ }
32768
+ return buildDecision("current", currentVersion, policy, {
32769
+ target_version: isPrerelease ? policy.latest_beta : policy.latest,
32770
+ restart_required: false,
32771
+ next_action: "Continue normal work; no package upgrade is required."
32772
+ });
32773
+ }
32774
+ async function checkMakerPackageUpdate(options) {
32775
+ const now = options.now ?? /* @__PURE__ */ new Date();
32776
+ const currentVersion = options.currentVersion;
32777
+ if (currentVersion === "dev") {
32778
+ return {
32779
+ status: "skipped",
32780
+ current_version: currentVersion,
32781
+ reason: "dev_version",
32782
+ checked_at: now.toISOString(),
32783
+ next_action: "Continue normal work; dev builds do not use remote version policy.",
32784
+ restart_required: false
32785
+ };
32786
+ }
32787
+ const policyUrl = resolvePolicyUrl(options.policyUrl);
32788
+ try {
32789
+ const policy = await fetchMakerPackageVersionPolicy({
32790
+ fetchImpl: options.fetchImpl,
32791
+ policyUrl,
32792
+ timeoutMs: options.timeoutMs
32793
+ });
32794
+ const decision = decideMakerPackageUpdate(currentVersion, policy);
32795
+ const status = {
32796
+ ...decision,
32797
+ current_version: currentVersion,
32798
+ checked_at: now.toISOString(),
32799
+ policy_url: policyUrl,
32800
+ latest: policy.latest,
32801
+ latest_beta: policy.latest_beta,
32802
+ minimum_supported: policy.minimum_supported,
32803
+ message: policy.message
32804
+ };
32805
+ writeCache({
32806
+ checked_at: status.checked_at,
32807
+ policy_url: policyUrl,
32808
+ policy,
32809
+ decision: status
32810
+ });
32811
+ return status;
32812
+ } catch (error2) {
32813
+ const message = error2 instanceof Error ? error2.message : String(error2);
32814
+ const latestCache = readCache();
32815
+ const unavailableStatus = buildUnavailableStatus({
32816
+ cache: latestCache,
32817
+ currentVersion,
32818
+ error: message,
32819
+ policyUrl
32820
+ });
32821
+ writeCache({
32822
+ checked_at: latestCache == null ? void 0 : latestCache.checked_at,
32823
+ policy_url: (latestCache == null ? void 0 : latestCache.policy_url) || policyUrl,
32824
+ policy: latestCache == null ? void 0 : latestCache.policy,
32825
+ decision: latestCache == null ? void 0 : latestCache.decision,
32826
+ error: message,
32827
+ error_checked_at: now.toISOString()
32828
+ });
32829
+ return unavailableStatus;
32830
+ }
32831
+ }
32832
+ async function getMakerPackageUpdateStatus(options) {
32833
+ var _a3, _b;
32834
+ const currentVersion = options.currentVersion;
32835
+ if (currentVersion === "dev") {
32836
+ return {
32837
+ status: "skipped",
32838
+ current_version: currentVersion,
32839
+ reason: "dev_version",
32840
+ checked_at: (options.now ?? /* @__PURE__ */ new Date()).toISOString(),
32841
+ next_action: "Continue normal work; dev builds do not use remote version policy.",
32842
+ restart_required: false
32843
+ };
32844
+ }
32845
+ const cache = readCache();
32846
+ const now = options.now ?? /* @__PURE__ */ new Date();
32847
+ const policyUrl = resolvePolicyUrl(options.policyUrl);
32848
+ const lastSuccessCheckedAt = getLastSuccessCheckedAt(cache);
32849
+ const lastErrorCheckedAt = getLastErrorCheckedAt(cache);
32850
+ const hasCurrentVersionDecision = ((_a3 = cache == null ? void 0 : cache.decision) == null ? void 0 : _a3.current_version) === currentVersion;
32851
+ const hasCurrentPolicyUrl = (cache == null ? void 0 : cache.policy_url) === policyUrl || ((_b = cache == null ? void 0 : cache.decision) == null ? void 0 : _b.policy_url) === policyUrl;
32852
+ const hasFreshErrorOnlyCache = Boolean(cache == null ? void 0 : cache.error) && !(cache == null ? void 0 : cache.decision) && hasCurrentPolicyUrl && lastErrorCheckedAt !== void 0 && isCacheFresh(lastErrorCheckedAt, now);
32853
+ if ((cache == null ? void 0 : cache.decision) && hasCurrentVersionDecision && hasCurrentPolicyUrl && lastSuccessCheckedAt && isCacheFresh(lastSuccessCheckedAt, now)) {
32854
+ return cache.error ? {
32855
+ ...cache.decision,
32856
+ error: cache.error
32857
+ } : cache.decision;
32858
+ }
32859
+ if (hasFreshErrorOnlyCache && options.allowRemoteFetch === false) {
32860
+ if (options.backgroundRefresh !== false) {
32861
+ startMakerPackageUpdateCheck(options);
32862
+ }
32863
+ return buildUnavailableStatus({
32864
+ cache,
32865
+ currentVersion,
32866
+ error: (cache == null ? void 0 : cache.error) || "Maker package version check is temporarily unavailable."
32867
+ });
32868
+ }
32869
+ if (options.allowRemoteFetch === false) {
32870
+ const shouldStartBackgroundRefresh = options.backgroundRefresh !== false;
32871
+ if (shouldStartBackgroundRefresh) {
32872
+ startMakerPackageUpdateCheck(options);
32873
+ }
32874
+ return buildUnavailableStatus({
32875
+ cache,
32876
+ currentVersion,
32877
+ error: formatUnavailableNonBlockingError(cache == null ? void 0 : cache.error, shouldStartBackgroundRefresh),
32878
+ checkedAt: now.toISOString(),
32879
+ policyUrl
32880
+ });
32881
+ }
32882
+ return checkMakerPackageUpdate(options);
32883
+ }
32884
+ var backgroundCheck;
32885
+ function startMakerPackageUpdateCheck(options) {
32886
+ const key = `${options.currentVersion}
32887
+ ${resolvePolicyUrl(options.policyUrl)}`;
32888
+ if ((backgroundCheck == null ? void 0 : backgroundCheck.key) === key) {
32889
+ return;
32890
+ }
32891
+ const promise2 = checkMakerPackageUpdate(options).then(() => void 0).catch(() => void 0).finally(() => {
32892
+ if ((backgroundCheck == null ? void 0 : backgroundCheck.promise) === promise2) {
32893
+ backgroundCheck = void 0;
32894
+ }
32895
+ });
32896
+ backgroundCheck = { key, promise: promise2 };
32897
+ }
32898
+ function formatMakerPackageUpdateStatus(status) {
32899
+ const lines = ["Maker MCP package update", ""];
32900
+ lines.push(`- status: ${status.status}`);
32901
+ lines.push(`- current_version: ${status.current_version}`);
32902
+ if (status.target_version) {
32903
+ lines.push(`- target_version: ${status.target_version}`);
32904
+ }
32905
+ if (status.reason) {
32906
+ lines.push(`- reason: ${status.reason}`);
32907
+ }
32908
+ if (status.minimum_supported) {
32909
+ lines.push(`- minimum_supported: ${status.minimum_supported}`);
32910
+ }
32911
+ if (status.latest) {
32912
+ lines.push(`- latest: ${status.latest}`);
32913
+ }
32914
+ if (status.latest_beta) {
32915
+ lines.push(`- latest_beta: ${status.latest_beta}`);
32916
+ }
32917
+ if (status.blacklist_match) {
32918
+ lines.push(`- blacklist_match: ${status.blacklist_match}`);
32919
+ } else if (status.status !== "skipped") {
32920
+ lines.push("- blacklist_match: no");
32921
+ }
32922
+ if (status.checked_at) {
32923
+ lines.push(`- checked_at: ${status.checked_at}`);
32924
+ }
32925
+ if (status.policy_url) {
32926
+ lines.push(`- policy_url: ${status.policy_url}`);
32927
+ }
32928
+ if (status.message) {
32929
+ lines.push(`- message: ${status.message}`);
32930
+ }
32931
+ if (status.error) {
32932
+ lines.push(`- error: ${status.error}`);
32933
+ }
32934
+ if (status.last_success_checked_at) {
32935
+ lines.push(`- last_success_checked_at: ${status.last_success_checked_at}`);
32936
+ }
32937
+ if (status.previous_status) {
32938
+ lines.push(`- previous_status: ${status.previous_status}`);
32939
+ }
32940
+ if (status.next_action) {
32941
+ lines.push(`- next_action: ${status.next_action}`);
32942
+ }
32943
+ if (typeof status.restart_required === "boolean") {
32944
+ lines.push(`- restart_required: ${status.restart_required ? "yes" : "no"}`);
32945
+ }
32946
+ return lines.join("\n");
32947
+ }
32948
+ function formatUnavailableNonBlockingError(previousError, backgroundRefresh) {
32949
+ if (backgroundRefresh) {
32950
+ return previousError ? `${previousError}; background retry started.` : "Maker package version check is running in the background.";
32951
+ }
32952
+ return previousError || "Maker package version check is temporarily unavailable.";
32953
+ }
32954
+ async function fetchMakerPackageVersionPolicy(options) {
32955
+ const fetchImpl = options.fetchImpl || fetch;
32956
+ const response = await fetchWithTimeout(
32957
+ fetchImpl,
32958
+ options.policyUrl,
32959
+ {
32960
+ headers: {
32961
+ Accept: "application/json"
32962
+ }
32963
+ },
32964
+ options.timeoutMs ?? DEFAULT_PACKAGE_VERSION_CHECK_TIMEOUT_MS,
32965
+ "Maker package version check"
32966
+ );
32967
+ if (!response.ok) {
32968
+ throw new Error(
32969
+ `Maker package version check failed: HTTP ${response.status} ${response.statusText}`
32970
+ );
32971
+ }
32972
+ const payload = await response.json();
32973
+ return parsePolicy(payload);
32974
+ }
32975
+ function parsePolicy(payload) {
32976
+ if (!payload || typeof payload !== "object") {
32977
+ throw new Error("Invalid Maker package version policy schema: expected an object.");
32978
+ }
32979
+ const policy = payload;
32980
+ if (policy.schema_version !== 1) {
32981
+ throw new Error("Invalid Maker package version policy schema: schema_version must be 1.");
32982
+ }
32983
+ if (!isValidVersionString(policy.latest)) {
32984
+ throw new Error("Invalid Maker package version policy schema: latest must be a semver string.");
32985
+ }
32986
+ if (!isValidVersionString(policy.latest_beta)) {
32987
+ throw new Error(
32988
+ "Invalid Maker package version policy schema: latest_beta must be a semver string."
32989
+ );
32990
+ }
32991
+ if (!isValidVersionString(policy.minimum_supported)) {
32992
+ throw new Error(
32993
+ "Invalid Maker package version policy schema: minimum_supported must be a semver string."
32994
+ );
32995
+ }
32996
+ if (!Array.isArray(policy.blacklist) || policy.blacklist.some((item) => !isValidVersionString(item))) {
32997
+ throw new Error(
32998
+ "Invalid Maker package version policy schema: blacklist must be a semver string array."
32999
+ );
33000
+ }
33001
+ if (typeof policy.updated_at !== "string" || Number.isNaN(Date.parse(policy.updated_at))) {
33002
+ throw new Error(
33003
+ "Invalid Maker package version policy schema: updated_at must be an ISO timestamp string."
33004
+ );
33005
+ }
33006
+ if (policy.message !== void 0 && typeof policy.message !== "string") {
33007
+ throw new Error("Invalid Maker package version policy schema: message must be a string.");
33008
+ }
33009
+ return {
33010
+ schema_version: 1,
33011
+ latest: policy.latest,
33012
+ latest_beta: policy.latest_beta,
33013
+ minimum_supported: policy.minimum_supported,
33014
+ blacklist: [...policy.blacklist],
33015
+ message: policy.message,
33016
+ updated_at: policy.updated_at
33017
+ };
33018
+ }
33019
+ function buildDecision(status, currentVersion, policy, overrides) {
33020
+ return {
33021
+ status,
33022
+ current_version: currentVersion,
33023
+ latest: policy.latest,
33024
+ latest_beta: policy.latest_beta,
33025
+ minimum_supported: policy.minimum_supported,
33026
+ message: policy.message,
33027
+ ...overrides
33028
+ };
33029
+ }
33030
+ function buildUnavailableStatus(options) {
33031
+ var _a3, _b, _c, _d;
33032
+ const previousDecision = (_a3 = options.cache) == null ? void 0 : _a3.decision;
33033
+ const hasCurrentVersionDecision = (previousDecision == null ? void 0 : previousDecision.current_version) === options.currentVersion;
33034
+ const hasCurrentPolicyUrl = !options.policyUrl || ((_b = options.cache) == null ? void 0 : _b.policy_url) === options.policyUrl || (previousDecision == null ? void 0 : previousDecision.policy_url) === options.policyUrl;
33035
+ const canUsePreviousDecision = hasCurrentVersionDecision && hasCurrentPolicyUrl;
33036
+ const lastSuccessCheckedAt = canUsePreviousDecision ? getLastSuccessCheckedAt(options.cache) : void 0;
33037
+ const previousPolicy = hasCurrentPolicyUrl ? (_c = options.cache) == null ? void 0 : _c.policy : void 0;
33038
+ return compactStatus({
33039
+ status: "unavailable",
33040
+ current_version: options.currentVersion,
33041
+ target_version: canUsePreviousDecision ? previousDecision == null ? void 0 : previousDecision.target_version : void 0,
33042
+ reason: canUsePreviousDecision ? previousDecision == null ? void 0 : previousDecision.reason : void 0,
33043
+ minimum_supported: (canUsePreviousDecision ? previousDecision == null ? void 0 : previousDecision.minimum_supported : void 0) ?? (previousPolicy == null ? void 0 : previousPolicy.minimum_supported),
33044
+ latest: (canUsePreviousDecision ? previousDecision == null ? void 0 : previousDecision.latest : void 0) ?? (previousPolicy == null ? void 0 : previousPolicy.latest),
33045
+ latest_beta: (canUsePreviousDecision ? previousDecision == null ? void 0 : previousDecision.latest_beta : void 0) ?? (previousPolicy == null ? void 0 : previousPolicy.latest_beta),
33046
+ blacklist_match: canUsePreviousDecision ? previousDecision == null ? void 0 : previousDecision.blacklist_match : void 0,
33047
+ checked_at: options.checkedAt,
33048
+ policy_url: options.policyUrl ?? ((_d = options.cache) == null ? void 0 : _d.policy_url),
33049
+ message: (canUsePreviousDecision ? previousDecision == null ? void 0 : previousDecision.message : void 0) ?? (previousPolicy == null ? void 0 : previousPolicy.message),
33050
+ error: options.error,
33051
+ last_success_checked_at: lastSuccessCheckedAt,
33052
+ previous_status: canUsePreviousDecision && (previousDecision == null ? void 0 : previousDecision.status) && previousDecision.status !== "unavailable" ? previousDecision.status : void 0,
33053
+ next_action: "Continue normal work; retry status later.",
33054
+ restart_required: false
33055
+ });
33056
+ }
33057
+ function compactStatus(status) {
33058
+ return Object.fromEntries(
33059
+ Object.entries(status).filter(([, value]) => value !== void 0)
33060
+ );
33061
+ }
33062
+ function readCache() {
33063
+ const cachePath = getMakerPackageVersionCheckCachePath();
33064
+ if (!fs12.existsSync(cachePath)) {
33065
+ return void 0;
33066
+ }
33067
+ try {
33068
+ return JSON.parse(fs12.readFileSync(cachePath, "utf8"));
33069
+ } catch {
33070
+ return void 0;
33071
+ }
33072
+ }
33073
+ function writeCache(cache) {
33074
+ const cachePath = getMakerPackageVersionCheckCachePath();
33075
+ fs12.mkdirSync(path13.dirname(cachePath), { recursive: true });
33076
+ fs12.writeFileSync(cachePath, `${JSON.stringify(cache, null, 2)}
33077
+ `, "utf8");
33078
+ }
33079
+ function getMakerPackageVersionCheckCachePath() {
33080
+ return path13.join(getMakerHome(), PACKAGE_VERSION_CHECK_CACHE_FILE);
33081
+ }
33082
+ function getLastSuccessCheckedAt(cache) {
33083
+ var _a3;
33084
+ if (!cache) {
33085
+ return void 0;
33086
+ }
33087
+ if (((_a3 = cache.decision) == null ? void 0 : _a3.status) && cache.decision.status !== "unavailable") {
33088
+ return cache.decision.checked_at || cache.checked_at;
33089
+ }
33090
+ return cache.checked_at;
33091
+ }
33092
+ function getLastErrorCheckedAt(cache) {
33093
+ return cache == null ? void 0 : cache.error_checked_at;
33094
+ }
33095
+ function isCacheFresh(checkedAt, now) {
33096
+ const checkedMs = Date.parse(checkedAt);
33097
+ if (Number.isNaN(checkedMs)) {
33098
+ return false;
33099
+ }
33100
+ return now.getTime() - checkedMs < PACKAGE_VERSION_CHECK_TTL_MS;
33101
+ }
33102
+ function resolvePolicyUrl(policyUrl) {
33103
+ return policyUrl || process.env[POLICY_URL_ENV] || DEFAULT_POLICY_URL;
33104
+ }
33105
+ function isValidVersionString(value) {
33106
+ return typeof value === "string" && parseVersion(value) !== void 0;
33107
+ }
33108
+ function parseVersion(version2) {
33109
+ const match = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/.exec(version2.trim());
33110
+ if (!match) {
33111
+ return void 0;
33112
+ }
33113
+ return {
33114
+ major: Number(match[1]),
33115
+ minor: Number(match[2]),
33116
+ patch: Number(match[3]),
33117
+ prerelease: match[4] ? match[4].split(".") : []
33118
+ };
33119
+ }
33120
+ function compareVersions(left, right) {
33121
+ if (left.major !== right.major) {
33122
+ return left.major - right.major;
33123
+ }
33124
+ if (left.minor !== right.minor) {
33125
+ return left.minor - right.minor;
33126
+ }
33127
+ if (left.patch !== right.patch) {
33128
+ return left.patch - right.patch;
33129
+ }
33130
+ const leftPre = left.prerelease;
33131
+ const rightPre = right.prerelease;
33132
+ if (leftPre.length === 0 && rightPre.length === 0) {
33133
+ return 0;
33134
+ }
33135
+ if (leftPre.length === 0) {
33136
+ return 1;
33137
+ }
33138
+ if (rightPre.length === 0) {
33139
+ return -1;
33140
+ }
33141
+ const length = Math.max(leftPre.length, rightPre.length);
33142
+ for (let index = 0; index < length; index += 1) {
33143
+ const leftIdentifier = leftPre[index];
33144
+ const rightIdentifier = rightPre[index];
33145
+ if (leftIdentifier === void 0) {
33146
+ return -1;
33147
+ }
33148
+ if (rightIdentifier === void 0) {
33149
+ return 1;
33150
+ }
33151
+ const compared = comparePrereleaseIdentifier(leftIdentifier, rightIdentifier);
33152
+ if (compared !== 0) {
33153
+ return compared;
33154
+ }
33155
+ }
33156
+ return 0;
33157
+ }
33158
+ function comparePrereleaseIdentifier(left, right) {
33159
+ const leftNumeric = /^\d+$/.test(left);
33160
+ const rightNumeric = /^\d+$/.test(right);
33161
+ if (leftNumeric && rightNumeric) {
33162
+ return compareNumericPrereleaseIdentifier(left, right);
33163
+ }
33164
+ if (leftNumeric) {
33165
+ return -1;
33166
+ }
33167
+ if (rightNumeric) {
33168
+ return 1;
33169
+ }
33170
+ return left.localeCompare(right);
33171
+ }
33172
+ function compareNumericPrereleaseIdentifier(left, right) {
33173
+ const normalizedLeft = left.replace(/^0+(?=\d)/, "");
33174
+ const normalizedRight = right.replace(/^0+(?=\d)/, "");
33175
+ if (normalizedLeft.length !== normalizedRight.length) {
33176
+ return normalizedLeft.length - normalizedRight.length;
33177
+ }
33178
+ return normalizedLeft.localeCompare(normalizedRight);
33179
+ }
33180
+
33181
+ // src/maker/server/proxyAssets.ts
33182
+ import fs13 from "node:fs";
33183
+ import path14 from "node:path";
32709
33184
  var IMAGE_ASSET_DIRS = ["assets/image"];
32710
33185
  var VIDEO_ASSET_DIRS = ["assets/video"];
32711
33186
  var AUDIO_ASSET_DIRS = ["assets/audio"];
@@ -32989,13 +33464,13 @@ function findExistingMaterializedVideo(targetDir, options) {
32989
33464
  function resolveExistingMaterializedAssetPath(targetDir, record2, localPath) {
32990
33465
  const candidates = [];
32991
33466
  const absolutePath = stringField2(record2.absolutePath);
32992
- if (absolutePath && path13.isAbsolute(absolutePath)) {
33467
+ if (absolutePath && path14.isAbsolute(absolutePath)) {
32993
33468
  candidates.push(absolutePath);
32994
33469
  }
32995
- candidates.push(path13.join(targetDir, ...localPath.split("/")));
33470
+ candidates.push(path14.join(targetDir, ...localPath.split("/")));
32996
33471
  for (const candidate of candidates) {
32997
33472
  try {
32998
- if (fs12.statSync(candidate).isFile()) {
33473
+ if (fs13.statSync(candidate).isFile()) {
32999
33474
  return candidate;
33000
33475
  }
33001
33476
  } catch {
@@ -33160,7 +33635,7 @@ async function materialize3dFinalResult(options, toolName) {
33160
33635
  try {
33161
33636
  extractZip(
33162
33637
  mdlMaterialized.absolutePath,
33163
- path13.join(options.targetDir, "assets"),
33638
+ path14.join(options.targetDir, "assets"),
33164
33639
  "3D model asset"
33165
33640
  );
33166
33641
  nextPayload.mdlExtracted = true;
@@ -33267,8 +33742,8 @@ async function materializeAsset(options) {
33267
33742
  };
33268
33743
  }
33269
33744
  const bytes = Buffer.from(await response.arrayBuffer());
33270
- fs12.mkdirSync(path13.dirname(absolutePath), { recursive: true });
33271
- fs12.writeFileSync(absolutePath, bytes);
33745
+ fs13.mkdirSync(path14.dirname(absolutePath), { recursive: true });
33746
+ fs13.writeFileSync(absolutePath, bytes);
33272
33747
  return { localPath: relativePath, absolutePath, download: { success: true } };
33273
33748
  } catch (error2) {
33274
33749
  return {
@@ -33282,12 +33757,12 @@ async function materializeAsset(options) {
33282
33757
  function createUniqueAssetPath(options) {
33283
33758
  const stem = `${sanitizeAssetBaseName(options.baseName)}_${formatAssetTimestamp(options.now)}`;
33284
33759
  for (let index = 1; index <= 9999; index += 1) {
33285
- const relativePath = path13.posix.join(
33760
+ const relativePath = path14.posix.join(
33286
33761
  options.relativeDir,
33287
33762
  `${stem}${index === 1 ? "" : `_${index}`}.${options.extension}`
33288
33763
  );
33289
- const absolutePath = path13.join(options.targetDir, ...relativePath.split("/"));
33290
- if (!fs12.existsSync(absolutePath)) {
33764
+ const absolutePath = path14.join(options.targetDir, ...relativePath.split("/"));
33765
+ if (!fs13.existsSync(absolutePath)) {
33291
33766
  return { relativePath, absolutePath };
33292
33767
  }
33293
33768
  }
@@ -33465,7 +33940,7 @@ function findRegistryAssetByName(value, registry2, assetDirs) {
33465
33940
  if (!isKnownAssetPath(localPath, assetDirs)) {
33466
33941
  return false;
33467
33942
  }
33468
- const basename = path13.posix.basename(localPath);
33943
+ const basename = path14.posix.basename(localPath);
33469
33944
  const stem = basename.replace(/\.[^.]+$/, "");
33470
33945
  return basename === value || stem === value || record2.name === value || record2.taskId === value;
33471
33946
  });
@@ -33478,13 +33953,13 @@ function findRegistryAssetByName(value, registry2, assetDirs) {
33478
33953
  }
33479
33954
  function findLocalAssetByName(targetDir, value, assetDirs) {
33480
33955
  var _a3;
33481
- const hasExtension = Boolean(path13.extname(value));
33956
+ const hasExtension = Boolean(path14.extname(value));
33482
33957
  const candidates = [];
33483
33958
  for (const assetDir of assetDirs) {
33484
- const absoluteDir = path13.join(targetDir, ...assetDir.split("/"));
33959
+ const absoluteDir = path14.join(targetDir, ...assetDir.split("/"));
33485
33960
  let entries;
33486
33961
  try {
33487
- entries = fs12.readdirSync(absoluteDir);
33962
+ entries = fs13.readdirSync(absoluteDir);
33488
33963
  } catch {
33489
33964
  continue;
33490
33965
  }
@@ -33493,11 +33968,11 @@ function findLocalAssetByName(targetDir, value, assetDirs) {
33493
33968
  if (hasExtension ? entry !== value : stem !== value && !stem.startsWith(`${value}_`)) {
33494
33969
  continue;
33495
33970
  }
33496
- const absolutePath = path13.join(absoluteDir, entry);
33971
+ const absolutePath = path14.join(absoluteDir, entry);
33497
33972
  try {
33498
33973
  candidates.push({
33499
- localPath: path13.posix.join(assetDir, entry),
33500
- mtimeMs: fs12.statSync(absolutePath).mtimeMs
33974
+ localPath: path14.posix.join(assetDir, entry),
33975
+ mtimeMs: fs13.statSync(absolutePath).mtimeMs
33501
33976
  });
33502
33977
  } catch {
33503
33978
  }
@@ -33507,7 +33982,7 @@ function findLocalAssetByName(targetDir, value, assetDirs) {
33507
33982
  return (_a3 = candidates[0]) == null ? void 0 : _a3.localPath;
33508
33983
  }
33509
33984
  function isKnownAssetPath(relativePath, assetDirs) {
33510
- if (relativePath.startsWith("../") || path13.isAbsolute(relativePath)) {
33985
+ if (relativePath.startsWith("../") || path14.isAbsolute(relativePath)) {
33511
33986
  return false;
33512
33987
  }
33513
33988
  return assetDirs.some(
@@ -33531,14 +34006,14 @@ function localAssetReferenceToDataUrl(options) {
33531
34006
  }
33532
34007
  let stat;
33533
34008
  try {
33534
- stat = fs12.statSync(absolutePath);
34009
+ stat = fs13.statSync(absolutePath);
33535
34010
  } catch {
33536
34011
  return void 0;
33537
34012
  }
33538
34013
  if (!stat.isFile() || stat.size > options.maxBytes) {
33539
34014
  return void 0;
33540
34015
  }
33541
- const bytes = fs12.readFileSync(absolutePath);
34016
+ const bytes = fs13.readFileSync(absolutePath);
33542
34017
  return `data:${mime};base64,${bytes.toString("base64")}`;
33543
34018
  }
33544
34019
  function resolveLocalAssetAbsolutePath(targetDir, options) {
@@ -33549,7 +34024,7 @@ function resolveLocalAssetAbsolutePath(targetDir, options) {
33549
34024
  candidates.push(localPath);
33550
34025
  }
33551
34026
  }
33552
- if (path13.isAbsolute(options.value)) {
34027
+ if (path14.isAbsolute(options.value)) {
33553
34028
  candidates.push(options.value);
33554
34029
  } else {
33555
34030
  const localPath = resolveProjectRelativePath(targetDir, options.value);
@@ -33558,54 +34033,54 @@ function resolveLocalAssetAbsolutePath(targetDir, options) {
33558
34033
  }
33559
34034
  }
33560
34035
  for (const candidate of candidates) {
33561
- if (fs12.existsSync(candidate)) {
34036
+ if (fs13.existsSync(candidate)) {
33562
34037
  return candidate;
33563
34038
  }
33564
34039
  }
33565
34040
  return void 0;
33566
34041
  }
33567
34042
  function resolveProjectRelativePath(targetDir, value) {
33568
- const root = path13.resolve(targetDir);
33569
- const absolutePath = path13.resolve(root, value);
33570
- const relativePath = path13.relative(root, absolutePath);
33571
- const escapesRoot = relativePath === ".." || relativePath.startsWith(`..${path13.sep}`) || path13.isAbsolute(relativePath);
34043
+ const root = path14.resolve(targetDir);
34044
+ const absolutePath = path14.resolve(root, value);
34045
+ const relativePath = path14.relative(root, absolutePath);
34046
+ const escapesRoot = relativePath === ".." || relativePath.startsWith(`..${path14.sep}`) || path14.isAbsolute(relativePath);
33572
34047
  if (!escapesRoot) {
33573
34048
  return absolutePath;
33574
34049
  }
33575
34050
  return void 0;
33576
34051
  }
33577
34052
  function dataUrlMimeForPath(filePath, mediaKind) {
33578
- return DATA_URL_MIME_BY_EXTENSION[mediaKind][path13.extname(filePath).toLowerCase()];
34053
+ return DATA_URL_MIME_BY_EXTENSION[mediaKind][path14.extname(filePath).toLowerCase()];
33579
34054
  }
33580
34055
  function upsertGeneratedAssetRecord(targetDir, localPath, record2) {
33581
34056
  const registry2 = readGeneratedAssetRegistry(targetDir);
33582
34057
  registry2[localPath] = record2;
33583
34058
  const registryPath = getGeneratedAssetRegistryPath(targetDir);
33584
- fs12.mkdirSync(path13.dirname(registryPath), { recursive: true });
33585
- fs12.writeFileSync(registryPath, `${JSON.stringify(registry2, null, 2)}
34059
+ fs13.mkdirSync(path14.dirname(registryPath), { recursive: true });
34060
+ fs13.writeFileSync(registryPath, `${JSON.stringify(registry2, null, 2)}
33586
34061
  `, "utf8");
33587
34062
  }
33588
34063
  function readGeneratedAssetRegistry(targetDir) {
33589
34064
  const registryPath = getGeneratedAssetRegistryPath(targetDir);
33590
- if (!fs12.existsSync(registryPath)) {
34065
+ if (!fs13.existsSync(registryPath)) {
33591
34066
  return {};
33592
34067
  }
33593
34068
  try {
33594
- const parsed = JSON.parse(fs12.readFileSync(registryPath, "utf8"));
34069
+ const parsed = JSON.parse(fs13.readFileSync(registryPath, "utf8"));
33595
34070
  return isRecord(parsed) ? parsed : {};
33596
34071
  } catch {
33597
34072
  return {};
33598
34073
  }
33599
34074
  }
33600
34075
  function getGeneratedAssetRegistryPath(targetDir) {
33601
- return path13.join(targetDir, ".maker", "assets", "generated-assets.json");
34076
+ return path14.join(targetDir, ".maker", "assets", "generated-assets.json");
33602
34077
  }
33603
34078
  function normalizeAssetRegistryKey(targetDir, value) {
33604
34079
  if (/^https?:\/\//i.test(value) || value.startsWith("data:")) {
33605
34080
  return void 0;
33606
34081
  }
33607
- const relative = path13.isAbsolute(value) ? path13.relative(targetDir, value) : value;
33608
- return relative.split(path13.sep).join("/");
34082
+ const relative = path14.isAbsolute(value) ? path14.relative(targetDir, value) : value;
34083
+ return relative.split(path14.sep).join("/");
33609
34084
  }
33610
34085
  function isRecord(value) {
33611
34086
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -33634,7 +34109,7 @@ function extensionFromUrl(url2) {
33634
34109
  }
33635
34110
  try {
33636
34111
  const pathname = new URL(url2).pathname;
33637
- const extension = path13.extname(pathname).replace(/^\./, "").toLowerCase();
34112
+ const extension = path14.extname(pathname).replace(/^\./, "").toLowerCase();
33638
34113
  return extension || void 0;
33639
34114
  } catch {
33640
34115
  return void 0;
@@ -33785,7 +34260,7 @@ function applyDefaults(config2) {
33785
34260
  }
33786
34261
 
33787
34262
  // src/maker/server/mcp.ts
33788
- var VERSION = true ? "0.0.20" : "dev";
34263
+ var VERSION = true ? "0.0.21-beta.2" : "dev";
33789
34264
  var DEFAULT_BUILD_TIMEOUT_MS = 10 * 60 * 1e3;
33790
34265
  var DEFAULT_PROXY_RETRY_ATTEMPTS = 5;
33791
34266
  var DEFAULT_PROXY_RETRY_DELAY_MS = 30 * 1e3;
@@ -34116,6 +34591,7 @@ function createRemoteProxyCallToolOptions(progressToken, extra) {
34116
34591
  };
34117
34592
  }
34118
34593
  async function startMakerMcpServer() {
34594
+ startMakerPackageUpdateCheck({ currentVersion: VERSION });
34119
34595
  const server = new Server(
34120
34596
  {
34121
34597
  name: "taptap-maker",
@@ -34284,7 +34760,7 @@ async function formatStatus(options = {}) {
34284
34760
  const env = getMakerEnvironment(void 0, targetDir);
34285
34761
  const identify = identifyMakerProject({ cwd: targetDir });
34286
34762
  const mcpCwd = process.cwd();
34287
- const mcpCwdIdentify = path14.resolve(mcpCwd) === path14.resolve(targetDir) ? identify : identifyMakerProject({ cwd: mcpCwd });
34763
+ const mcpCwdIdentify = path15.resolve(mcpCwd) === path15.resolve(targetDir) ? identify : identifyMakerProject({ cwd: mcpCwd });
34288
34764
  const gitDirectoryStatus = inspectMakerDirectoryGitStatus(targetDir);
34289
34765
  const remoteSyncText = identify.projectRoot && gitDirectoryStatus.isUsableMakerGitRepo && !options.skipRemoteSync ? await formatMakerRemoteSyncStatusSafely(identify.projectRoot) : identify.projectRoot && gitDirectoryStatus.isUsableMakerGitRepo ? formatMakerRemoteSyncSkipped() : "";
34290
34766
  const pat = loadPat();
@@ -34310,6 +34786,12 @@ async function formatStatus(options = {}) {
34310
34786
  const git = checkGitEnvironment();
34311
34787
  const python = checkMakerPythonEnvironment();
34312
34788
  const luaLsp = checkMakerLuaLspEnvironment({ pythonEnvironment: python });
34789
+ const packageUpdateText = formatMakerPackageUpdateStatus(
34790
+ await getMakerPackageUpdateStatus({
34791
+ currentVersion: VERSION,
34792
+ allowRemoteFetch: false
34793
+ })
34794
+ );
34313
34795
  const projectSection = identify.projectId ? [
34314
34796
  "目标目录已绑定 Maker 项目。",
34315
34797
  "请继续在当前绑定项目上执行状态、提交、构建等操作;用户明确要求切换或重新拉取项目时,再进入项目选择流程。",
@@ -34337,6 +34819,8 @@ async function formatStatus(options = {}) {
34337
34819
  "",
34338
34820
  formatMakerLuaLspEnvironmentStatus(luaLsp),
34339
34821
  "",
34822
+ packageUpdateText,
34823
+ "",
34340
34824
  formatMakerGitDirectoryStatus(gitDirectoryStatus),
34341
34825
  "",
34342
34826
  formatMakerClientRootsStatus(projectContext.roots),
@@ -34409,10 +34893,10 @@ function formatMakerToolRegistrationCwdStatus(options) {
34409
34893
  if (!options.projectRoot) {
34410
34894
  return "";
34411
34895
  }
34412
- const mcpCwd = path14.resolve(options.mcpCwd);
34413
- const targetDir = path14.resolve(options.targetDir);
34414
- const projectRoot = path14.resolve(options.projectRoot);
34415
- const mcpProjectRoot = options.mcpProjectRoot ? path14.resolve(options.mcpProjectRoot) : void 0;
34896
+ const mcpCwd = path15.resolve(options.mcpCwd);
34897
+ const targetDir = path15.resolve(options.targetDir);
34898
+ const projectRoot = path15.resolve(options.projectRoot);
34899
+ const mcpProjectRoot = options.mcpProjectRoot ? path15.resolve(options.mcpProjectRoot) : void 0;
34416
34900
  if (mcpProjectRoot === projectRoot) {
34417
34901
  return "";
34418
34902
  }
@@ -34585,7 +35069,7 @@ function createServerClientRootsProvider(server) {
34585
35069
  async function resolveMakerProjectContext(options = {}) {
34586
35070
  if (options.targetDir) {
34587
35071
  return {
34588
- targetDir: path14.resolve(options.targetDir),
35072
+ targetDir: path15.resolve(options.targetDir),
34589
35073
  source: "explicit_target_dir",
34590
35074
  roots: { status: "not_requested", roots: [] }
34591
35075
  };
@@ -34680,7 +35164,7 @@ function rootToLocalPath(root) {
34680
35164
  if (url2.protocol !== "file:") {
34681
35165
  return void 0;
34682
35166
  }
34683
- return path14.resolve(fileURLToPath2(url2));
35167
+ return path15.resolve(fileURLToPath2(url2));
34684
35168
  } catch {
34685
35169
  return void 0;
34686
35170
  }
@@ -34694,14 +35178,14 @@ function uniquePaths(values) {
34694
35178
  continue;
34695
35179
  }
34696
35180
  seen.add(normalized);
34697
- result.push(path14.resolve(value));
35181
+ result.push(path15.resolve(value));
34698
35182
  }
34699
35183
  return result;
34700
35184
  }
34701
35185
  function normalizePathForCompare2(value) {
34702
- const resolved = path14.resolve(value);
35186
+ const resolved = path15.resolve(value);
34703
35187
  try {
34704
- return fs13.realpathSync.native(resolved);
35188
+ return fs14.realpathSync.native(resolved);
34705
35189
  } catch {
34706
35190
  return resolved;
34707
35191
  }
@@ -34850,14 +35334,14 @@ function formatStatusProjectList(projects) {
34850
35334
  ].filter((line) => line !== void 0).join("\n");
34851
35335
  }
34852
35336
  function formatClonePartialStateLines(targetDir) {
34853
- const resolvedTargetDir = path14.resolve(targetDir);
35337
+ const resolvedTargetDir = path15.resolve(targetDir);
34854
35338
  const identify = identifyMakerProject({ cwd: resolvedTargetDir });
34855
35339
  const gitStatus = inspectMakerDirectoryGitStatus(resolvedTargetDir);
34856
35340
  const devKitStatus = inspectAiDevKit(resolvedTargetDir);
34857
- const stagedDevKitGitignorePath = path14.join(resolvedTargetDir, DEV_KIT_GITIGNORE_STAGING_FILE);
35341
+ const stagedDevKitGitignorePath = path15.join(resolvedTargetDir, DEV_KIT_GITIGNORE_STAGING_FILE);
34858
35342
  const projectBound = Boolean(identify.projectId);
34859
35343
  const gitInitialized = Boolean(
34860
- gitStatus.isOwnGitRoot || fs13.existsSync(path14.join(resolvedTargetDir, ".git"))
35344
+ gitStatus.isOwnGitRoot || fs14.existsSync(path15.join(resolvedTargetDir, ".git"))
34861
35345
  );
34862
35346
  const safeToRetry = !projectBound;
34863
35347
  return [
@@ -34871,7 +35355,7 @@ function formatClonePartialStateLines(targetDir) {
34871
35355
  identify.configPath ? `- config: ${identify.configPath}` : "",
34872
35356
  `- ai_dev_kit_present: ${devKitStatus.ready ? "yes" : "no"}`,
34873
35357
  `- ai_dev_kit_missing_entries: ${devKitStatus.missingEntries.join(", ") || "(none)"}`,
34874
- `- staged_dev_kit_gitignore: ${fs13.existsSync(stagedDevKitGitignorePath) ? "yes" : "no"}`,
35358
+ `- staged_dev_kit_gitignore: ${fs14.existsSync(stagedDevKitGitignorePath) ? "yes" : "no"}`,
34875
35359
  `- safe_to_retry: ${safeToRetry ? "yes" : "no"}`,
34876
35360
  safeToRetry ? "- next_step: 可以直接重试 taptap-maker init;如果连续失败,建议换一个全新的独立目录重新 clone。" : "- next_step: 当前目录已经有 Maker 绑定信息;先运行 taptap-maker doctor 或读取 maker://status 确认状态。"
34877
35361
  ].filter(Boolean);
@@ -34947,12 +35431,12 @@ function resolveEmbeddedProxyCommand(options) {
34947
35431
  }
34948
35432
  return {
34949
35433
  command: process.execPath,
34950
- args: [path14.resolve(makerEntry), "__maker-proxy"]
35434
+ args: [path15.resolve(makerEntry), "__maker-proxy"]
34951
35435
  };
34952
35436
  }
34953
35437
  function resolveBundledMakerEntry() {
34954
- const bundledEntry = path14.resolve(__dirname, "../../../bin/taptap-maker");
34955
- return fs13.existsSync(bundledEntry) ? bundledEntry : void 0;
35438
+ const bundledEntry = path15.resolve(__dirname, "../../../bin/taptap-maker");
35439
+ return fs14.existsSync(bundledEntry) ? bundledEntry : void 0;
34956
35440
  }
34957
35441
  function isUsableEmbeddedMakerEntry(entry) {
34958
35442
  if (!entry) {
@@ -35299,18 +35783,18 @@ async function attachRuntimeLogWatch(buildResult, startWatch) {
35299
35783
  }
35300
35784
  }
35301
35785
  async function startRuntimeLogWatch(buildResult) {
35302
- const runtimeDir = path14.join(buildResult.projectRoot, ".maker", "logs", "runtime");
35303
- fs13.mkdirSync(runtimeDir, { recursive: true });
35304
- const stdoutLog = path14.join(runtimeDir, "watcher.out.log");
35305
- const stderrLog = path14.join(runtimeDir, "watcher.err.log");
35306
- const pidFile = path14.join(runtimeDir, "watcher.pid");
35786
+ const runtimeDir = path15.join(buildResult.projectRoot, ".maker", "logs", "runtime");
35787
+ fs14.mkdirSync(runtimeDir, { recursive: true });
35788
+ const stdoutLog = path15.join(runtimeDir, "watcher.out.log");
35789
+ const stderrLog = path15.join(runtimeDir, "watcher.err.log");
35790
+ const pidFile = path15.join(runtimeDir, "watcher.pid");
35307
35791
  const previous = stopExistingRuntimeLogWatcher(pidFile);
35308
- const outFd = fs13.openSync(stdoutLog, "a");
35309
- const errFd = fs13.openSync(stderrLog, "a");
35792
+ const outFd = fs14.openSync(stdoutLog, "a");
35793
+ const errFd = fs14.openSync(stderrLog, "a");
35310
35794
  const command = formatRuntimeLogWatchCommand(buildResult);
35311
35795
  if (previous.previousStopError) {
35312
- fs13.closeSync(outFd);
35313
- fs13.closeSync(errFd);
35796
+ fs14.closeSync(outFd);
35797
+ fs14.closeSync(errFd);
35314
35798
  return {
35315
35799
  started: false,
35316
35800
  command: command.text,
@@ -35373,18 +35857,18 @@ async function startRuntimeLogWatch(buildResult) {
35373
35857
  ...previous
35374
35858
  };
35375
35859
  } finally {
35376
- fs13.closeSync(outFd);
35377
- fs13.closeSync(errFd);
35860
+ fs14.closeSync(outFd);
35861
+ fs14.closeSync(errFd);
35378
35862
  }
35379
35863
  }
35380
35864
  function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
35381
- if (!fs13.existsSync(pidFile)) {
35865
+ if (!fs14.existsSync(pidFile)) {
35382
35866
  return {};
35383
35867
  }
35384
35868
  const pidState = readRuntimeLogWatcherPidState(pidFile);
35385
35869
  const pid = pidState == null ? void 0 : pidState.pid;
35386
35870
  if (!Number.isInteger(pid) || pid <= 0) {
35387
- fs13.rmSync(pidFile, { force: true });
35871
+ fs14.rmSync(pidFile, { force: true });
35388
35872
  return {};
35389
35873
  }
35390
35874
  try {
@@ -35392,7 +35876,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
35392
35876
  const processCommand = (options.getProcessCommand || getProcessCommand)(pid);
35393
35877
  const verifiedCommand = getVerifiedRuntimeLogWatcherCommand(processCommand, pidState);
35394
35878
  if (!verifiedCommand) {
35395
- fs13.rmSync(pidFile, { force: true });
35879
+ fs14.rmSync(pidFile, { force: true });
35396
35880
  return {
35397
35881
  previousPid: pid,
35398
35882
  previousStopped: false,
@@ -35402,7 +35886,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
35402
35886
  process.kill(pid, "SIGTERM");
35403
35887
  const stopped = (options.waitForExit || waitForProcessExit)(pid, WATCHER_STOP_TIMEOUT_MS);
35404
35888
  if (stopped) {
35405
- fs13.rmSync(pidFile, { force: true });
35889
+ fs14.rmSync(pidFile, { force: true });
35406
35890
  return { previousPid: pid, previousStopped: true };
35407
35891
  }
35408
35892
  return {
@@ -35411,7 +35895,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
35411
35895
  previousStopError: `process ${pid} did not exit after SIGTERM within ${WATCHER_STOP_TIMEOUT_MS}ms`
35412
35896
  };
35413
35897
  } catch (error2) {
35414
- fs13.rmSync(pidFile, { force: true });
35898
+ fs14.rmSync(pidFile, { force: true });
35415
35899
  const code = error2 && typeof error2 === "object" && "code" in error2 ? String(error2.code) : "";
35416
35900
  if (code === "ESRCH") {
35417
35901
  return { previousPid: pid, previousStopped: false };
@@ -35424,7 +35908,7 @@ function stopExistingRuntimeLogWatcher(pidFile, options = {}) {
35424
35908
  }
35425
35909
  }
35426
35910
  function readRuntimeLogWatcherPidState(pidFile) {
35427
- const raw = fs13.readFileSync(pidFile, "utf8").trim();
35911
+ const raw = fs14.readFileSync(pidFile, "utf8").trim();
35428
35912
  if (!raw) {
35429
35913
  return null;
35430
35914
  }
@@ -35440,7 +35924,7 @@ function readRuntimeLogWatcherPidState(pidFile) {
35440
35924
  }
35441
35925
  }
35442
35926
  function writeRuntimeLogWatcherPidFile(pidFile, state) {
35443
- fs13.writeFileSync(pidFile, `${JSON.stringify(state, null, 2)}
35927
+ fs14.writeFileSync(pidFile, `${JSON.stringify(state, null, 2)}
35444
35928
  `, "utf8");
35445
35929
  }
35446
35930
  function getProcessCommand(pid) {
@@ -35526,10 +36010,10 @@ function formatRuntimeLogWatchCommand(buildResult) {
35526
36010
  };
35527
36011
  }
35528
36012
  function resolveMakerCliEntry() {
35529
- return process.argv[1] || path14.resolve(process.cwd(), "dist", "maker.js");
36013
+ return process.argv[1] || path15.resolve(process.cwd(), "dist", "maker.js");
35530
36014
  }
35531
36015
  function getRuntimeLogFilePath(projectRoot) {
35532
- return path14.join(projectRoot, ".maker", "logs", "runtime", "runtime.log");
36016
+ return path15.join(projectRoot, ".maker", "logs", "runtime", "runtime.log");
35533
36017
  }
35534
36018
  async function refreshMakerPreview(buildResult) {
35535
36019
  const makerEnv = buildResult.env === "rnd" || buildResult.env === "production" ? buildResult.env : void 0;
@@ -35662,7 +36146,7 @@ function createBuildArgs(projectRoot, options) {
35662
36146
  if (options.scriptsPath) {
35663
36147
  buildArgs.scriptsPath = options.scriptsPath;
35664
36148
  }
35665
- if (!options.entry && !options.scriptsPath && !options.entryClient && !options.entryServer && !options.multiplayer && fs13.existsSync(path14.join(projectRoot, "scripts", "main.lua"))) {
36149
+ if (!options.entry && !options.scriptsPath && !options.entryClient && !options.entryServer && !options.multiplayer && fs14.existsSync(path15.join(projectRoot, "scripts", "main.lua"))) {
35666
36150
  buildArgs.entry = "main.lua";
35667
36151
  buildArgs.scriptsPath = "scripts";
35668
36152
  }
@@ -35674,7 +36158,7 @@ function createBuildArgs(projectRoot, options) {
35674
36158
  }
35675
36159
  if (options.multiplayer) {
35676
36160
  buildArgs.multiplayer = options.multiplayer;
35677
- } else if (!fs13.existsSync(path14.join(projectRoot, ".project", "settings.json"))) {
36161
+ } else if (!fs14.existsSync(path15.join(projectRoot, ".project", "settings.json"))) {
35678
36162
  buildArgs.multiplayer = { enabled: false };
35679
36163
  }
35680
36164
  return buildArgs;
@@ -35849,11 +36333,11 @@ function formatRuntimeLogWatchNextActionLines(result) {
35849
36333
  ((_a3 = result.runtimeLogWatch) == null ? void 0 : _a3.pid) ? `- watch_pid: ${result.runtimeLogWatch.pid}` : "",
35850
36334
  `- watch_command: ${command}`,
35851
36335
  ((_b = result.runtimeLogWatch) == null ? void 0 : _b.command) ? `- actual_watch_command: ${result.runtimeLogWatch.command}` : "",
35852
- `- local_file: ${path14.join(result.projectRoot, ".maker", "logs", "runtime", "runtime.log")}`,
36336
+ `- local_file: ${path15.join(result.projectRoot, ".maker", "logs", "runtime", "runtime.log")}`,
35853
36337
  ((_c = result.runtimeLogWatch) == null ? void 0 : _c.stdoutLog) ? `- watcher_stdout: ${result.runtimeLogWatch.stdoutLog}` : "",
35854
36338
  ((_d = result.runtimeLogWatch) == null ? void 0 : _d.stderrLog) ? `- watcher_stderr: ${result.runtimeLogWatch.stderrLog}` : "",
35855
36339
  ((_e = result.runtimeLogWatch) == null ? void 0 : _e.pidFile) ? `- watcher_pid_file: ${result.runtimeLogWatch.pidFile}` : "",
35856
- `- state_file: ${path14.join(result.projectRoot, ".maker", "logs", "runtime", "state.json")}`,
36340
+ `- state_file: ${path15.join(result.projectRoot, ".maker", "logs", "runtime", "state.json")}`,
35857
36341
  ((_f = result.runtimeLogWatch) == null ? void 0 : _f.previousPid) ? `- previous_watch_pid: ${result.runtimeLogWatch.previousPid}` : "",
35858
36342
  ((_g = result.runtimeLogWatch) == null ? void 0 : _g.previousStopped) !== void 0 ? `- previous_watch_stopped: ${result.runtimeLogWatch.previousStopped ? "yes" : "no"}` : "",
35859
36343
  ((_h = result.runtimeLogWatch) == null ? void 0 : _h.previousStopError) ? `- previous_watch_stop_error: ${result.runtimeLogWatch.previousStopError}` : "",
@@ -36031,9 +36515,9 @@ function indent2(value) {
36031
36515
  // src/maker/cli/commands.ts
36032
36516
  import { spawnSync as spawnSync8 } from "node:child_process";
36033
36517
  import crypto3 from "node:crypto";
36034
- import fs14 from "node:fs";
36518
+ import fs15 from "node:fs";
36035
36519
  import os4 from "node:os";
36036
- import path15 from "node:path";
36520
+ import path16 from "node:path";
36037
36521
  import readline from "node:readline/promises";
36038
36522
  import { stdin as input, stdout as output } from "node:process";
36039
36523
 
@@ -36179,6 +36663,7 @@ function formatError2(error2) {
36179
36663
  }
36180
36664
 
36181
36665
  // src/maker/cli/commands.ts
36666
+ var VERSION2 = true ? "0.0.21-beta.2" : "dev";
36182
36667
  var DEFAULT_MCP_NAME = "taptap-maker";
36183
36668
  var MAKER_NPM_PACKAGE = "@taptap/maker";
36184
36669
  var TWO_PART_COMMANDS = /* @__PURE__ */ new Set(["pat", "mcp", "dev-kit", "logs", "python", "lua-lsp", "agents"]);
@@ -36313,7 +36798,7 @@ function toOptionKey(value) {
36313
36798
  }
36314
36799
  async function runInit(parsed, ctx) {
36315
36800
  rejectPackageOption(parsed);
36316
- const targetDir = path15.resolve(stringOption(parsed, "target_dir") || process.cwd());
36801
+ const targetDir = path16.resolve(stringOption(parsed, "target_dir") || process.cwd());
36317
36802
  const env = makerEnvOption(parsed);
36318
36803
  const skipConfirm = booleanOption(parsed, "skip_confirm");
36319
36804
  const skipMcpInstall = booleanOption(parsed, "skip_mcp_install");
@@ -36406,7 +36891,7 @@ async function runInit(parsed, ctx) {
36406
36891
  }
36407
36892
  async function runDoctor(parsed, ctx) {
36408
36893
  var _a3, _b;
36409
- const targetDir = path15.resolve(stringOption(parsed, "target_dir") || process.cwd());
36894
+ const targetDir = path16.resolve(stringOption(parsed, "target_dir") || process.cwd());
36410
36895
  const env = makerEnvOption(parsed);
36411
36896
  const git = checkGitEnvironment();
36412
36897
  const python = checkMakerPythonEnvironment();
@@ -36418,6 +36903,11 @@ async function runDoctor(parsed, ctx) {
36418
36903
  const projectRoot = identify.projectRoot || targetDir;
36419
36904
  const devKit = inspectAiDevKit(projectRoot);
36420
36905
  const devKitUpdate = await checkAiDevKitUpdate(projectRoot, { environment: env });
36906
+ const packageUpdate = await getMakerPackageUpdateStatus({
36907
+ currentVersion: VERSION2,
36908
+ allowRemoteFetch: false,
36909
+ backgroundRefresh: false
36910
+ });
36421
36911
  const agentsPolicy = isProjectBound ? inspectMakerAgentsPolicy(projectRoot) : void 0;
36422
36912
  const orphanProcessCheck = inspectMakerOrphanProcesses();
36423
36913
  const mcpToolsAvailability = inspectMakerMcpToolsAvailability({
@@ -36437,6 +36927,7 @@ async function runDoctor(parsed, ctx) {
36437
36927
  agents_policy: agentsPolicy,
36438
36928
  dev_kit: devKit,
36439
36929
  dev_kit_update: devKitUpdate,
36930
+ package_update: packageUpdate,
36440
36931
  mcp_tools_availability: mcpToolsAvailability,
36441
36932
  orphan_process_check: orphanProcessCheck
36442
36933
  });
@@ -36473,6 +36964,8 @@ async function runDoctor(parsed, ctx) {
36473
36964
  `- update_available: ${devKitUpdate.updateAvailable ? "yes" : "no"}`,
36474
36965
  devKitUpdate.versionCheckError ? `- version_check: ${devKitUpdate.versionCheckError}` : "",
36475
36966
  "",
36967
+ formatMakerPackageUpdateStatus(packageUpdate),
36968
+ "",
36476
36969
  formatMakerMcpToolsAvailability(mcpToolsAvailability),
36477
36970
  "",
36478
36971
  formatMakerOrphanProcessStatus(orphanProcessCheck),
@@ -36483,9 +36976,9 @@ async function runDoctor(parsed, ctx) {
36483
36976
  );
36484
36977
  }
36485
36978
  function inspectMakerMcpToolsAvailability(options) {
36486
- const aiPwd = path15.resolve(process.cwd());
36979
+ const aiPwd = path16.resolve(process.cwd());
36487
36980
  const aiPwdIdentify = identifyMakerProject({ cwd: aiPwd });
36488
- const makerProjectDir = options.makerProjectDir ? path15.resolve(options.makerProjectDir) : void 0;
36981
+ const makerProjectDir = options.makerProjectDir ? path16.resolve(options.makerProjectDir) : void 0;
36489
36982
  if (!makerProjectDir) {
36490
36983
  return {
36491
36984
  tools_visibility: "refresh_ai_client_if_missing",
@@ -36527,9 +37020,9 @@ function samePath2(left, right) {
36527
37020
  return normalizePathForCompare3(left) === normalizePathForCompare3(right);
36528
37021
  }
36529
37022
  function normalizePathForCompare3(value) {
36530
- const resolved = path15.resolve(value);
37023
+ const resolved = path16.resolve(value);
36531
37024
  try {
36532
- return fs14.realpathSync.native(resolved);
37025
+ return fs15.realpathSync.native(resolved);
36533
37026
  } catch {
36534
37027
  return resolved;
36535
37028
  }
@@ -36847,7 +37340,7 @@ async function runPatSet(parsed, ctx) {
36847
37340
  }
36848
37341
  async function resolvePatSet(parsed, ctx) {
36849
37342
  if (booleanOption(parsed, "pat_stdin") || booleanOption(parsed, "pat_from_stdin")) {
36850
- const pat = fs14.readFileSync(0, "utf8").trim();
37343
+ const pat = fs15.readFileSync(0, "utf8").trim();
36851
37344
  if (!pat) {
36852
37345
  throw new Error("No PAT found on stdin.");
36853
37346
  }
@@ -36877,7 +37370,7 @@ async function runMcpInstall(parsed, ctx) {
36877
37370
  env: makerEnvOption(parsed),
36878
37371
  pkg: MAKER_NPM_PACKAGE,
36879
37372
  mcpName: stringOption(parsed, "name") || DEFAULT_MCP_NAME,
36880
- cwd: explicitTargetDir ? path15.resolve(explicitTargetDir) : void 0
37373
+ cwd: explicitTargetDir ? path16.resolve(explicitTargetDir) : void 0
36881
37374
  });
36882
37375
  if (ctx.json) {
36883
37376
  writeJson(results);
@@ -36936,7 +37429,7 @@ ${indent3(payload.stderr)}` : "",
36936
37429
  );
36937
37430
  }
36938
37431
  async function runAgentsUpdate(parsed, ctx) {
36939
- const targetDir = path15.resolve(stringOption(parsed, "target_dir") || process.cwd());
37432
+ const targetDir = path16.resolve(stringOption(parsed, "target_dir") || process.cwd());
36940
37433
  const result = updateMakerAgentsPolicy(targetDir);
36941
37434
  if (ctx.json) {
36942
37435
  writeJson(result);
@@ -36955,7 +37448,7 @@ async function runAgentsUpdate(parsed, ctx) {
36955
37448
  async function runUpgrade(parsed, ctx) {
36956
37449
  rejectPackageOption(parsed);
36957
37450
  const explicitTargetDir = stringOption(parsed, "target_dir");
36958
- const targetDir = path15.resolve(explicitTargetDir || process.cwd());
37451
+ const targetDir = path16.resolve(explicitTargetDir || process.cwd());
36959
37452
  const env = makerEnvOption(parsed);
36960
37453
  const ides = parseIdeList(stringOption(parsed, "ide") || stringOption(parsed, "ides") || "");
36961
37454
  const installResults = installMcpConfigs({
@@ -37040,7 +37533,7 @@ function getMcpVerifyNextSteps(mode, commandText) {
37040
37533
  ];
37041
37534
  }
37042
37535
  async function runDevKitUpdate(parsed, ctx) {
37043
- const targetDir = path15.resolve(stringOption(parsed, "target_dir") || process.cwd());
37536
+ const targetDir = path16.resolve(stringOption(parsed, "target_dir") || process.cwd());
37044
37537
  const result = await installAiDevKit({
37045
37538
  targetDir,
37046
37539
  preserveExisting: false,
@@ -37052,7 +37545,7 @@ async function runDevKitUpdate(parsed, ctx) {
37052
37545
  emitDevKitSkillInstallerFailure(ctx, result.skillInstaller, "AI skills install failed");
37053
37546
  }
37054
37547
  async function runLogsWatch(parsed, ctx) {
37055
- const targetDir = path15.resolve(stringOption(parsed, "target_dir") || process.cwd());
37548
+ const targetDir = path16.resolve(stringOption(parsed, "target_dir") || process.cwd());
37056
37549
  const intervalMs = parseDurationMs(stringOption(parsed, "interval") || "5s");
37057
37550
  const timeoutMs = numberOption(parsed, "timeout_ms") ?? DEFAULT_TOOL_CALL_TIMEOUT_MS;
37058
37551
  const maxPolls = numberOption(parsed, "max_polls");
@@ -37062,9 +37555,9 @@ async function runLogsWatch(parsed, ctx) {
37062
37555
  serverUrl: stringOption(parsed, "server_url"),
37063
37556
  env: makerEnvOption(parsed)
37064
37557
  });
37065
- const runtimeDir = path15.join(proxy.projectRoot, ".maker", "logs", "runtime");
37066
- const runtimeLog = path15.join(runtimeDir, "runtime.log");
37067
- const pidFile = path15.join(runtimeDir, "watcher.pid");
37558
+ const runtimeDir = path16.join(proxy.projectRoot, ".maker", "logs", "runtime");
37559
+ const runtimeLog = path16.join(runtimeDir, "runtime.log");
37560
+ const pidFile = path16.join(runtimeDir, "watcher.pid");
37068
37561
  const replacedWatcher = registerRuntimeLogWatcherProcess(pidFile);
37069
37562
  const runtimeLogClient = createRemoteRuntimeLogClient(proxy, timeoutMs);
37070
37563
  emit(ctx, "logs_watch_start", "Maker runtime log watcher started", {
@@ -37109,10 +37602,10 @@ async function runLogsWatch(parsed, ctx) {
37109
37602
  }
37110
37603
  }
37111
37604
  function registerRuntimeLogWatcherProcess(pidFile) {
37112
- fs14.mkdirSync(path15.dirname(pidFile), { recursive: true });
37605
+ fs15.mkdirSync(path16.dirname(pidFile), { recursive: true });
37113
37606
  const existingPid = readPidFile(pidFile);
37114
37607
  const previous = existingPid && existingPid !== process.pid ? stopExistingRuntimeLogWatcher(pidFile) : {};
37115
- fs14.writeFileSync(
37608
+ fs15.writeFileSync(
37116
37609
  pidFile,
37117
37610
  `${JSON.stringify(
37118
37611
  {
@@ -37130,10 +37623,10 @@ function registerRuntimeLogWatcherProcess(pidFile) {
37130
37623
  return previous;
37131
37624
  }
37132
37625
  function readPidFile(pidFile) {
37133
- if (!fs14.existsSync(pidFile)) {
37626
+ if (!fs15.existsSync(pidFile)) {
37134
37627
  return void 0;
37135
37628
  }
37136
- const raw = fs14.readFileSync(pidFile, "utf8").trim();
37629
+ const raw = fs15.readFileSync(pidFile, "utf8").trim();
37137
37630
  let pid = Number(raw);
37138
37631
  if (!Number.isInteger(pid) || pid <= 0) {
37139
37632
  try {
@@ -37153,7 +37646,7 @@ function installRuntimeLogWatcherPidCleanup(pidFile) {
37153
37646
  }
37154
37647
  cleaned = true;
37155
37648
  if (readPidFile(pidFile) === process.pid) {
37156
- fs14.rmSync(pidFile, { force: true });
37649
+ fs15.rmSync(pidFile, { force: true });
37157
37650
  }
37158
37651
  };
37159
37652
  process.once("exit", cleanup);
@@ -37304,7 +37797,7 @@ async function prepareDevKit(targetDir, ctx, options = {}) {
37304
37797
  onStart: (event) => emitSkillInstallerStart(ctx, event)
37305
37798
  });
37306
37799
  writeDevKitStagedGitignore(
37307
- path15.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE),
37800
+ path16.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE),
37308
37801
  listPresentDevKitManagedEntries(targetDir)
37309
37802
  );
37310
37803
  if (options.finalizeGitignore) {
@@ -37321,7 +37814,7 @@ async function prepareDevKit(targetDir, ctx, options = {}) {
37321
37814
  );
37322
37815
  } catch (error2) {
37323
37816
  writeDevKitStagedGitignore(
37324
- path15.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE),
37817
+ path16.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE),
37325
37818
  listPresentDevKitManagedEntries(targetDir)
37326
37819
  );
37327
37820
  if (options.finalizeGitignore) {
@@ -37409,7 +37902,7 @@ function installMcpConfig(ide, options) {
37409
37902
  }
37410
37903
  function installMcpConfigUnsafe(ide, options) {
37411
37904
  if (ide === "codex") {
37412
- const configPath = path15.join(os4.homedir(), ".codex", "config.toml");
37905
+ const configPath = path16.join(os4.homedir(), ".codex", "config.toml");
37413
37906
  const write = mergeCodexMcpConfig(configPath, options);
37414
37907
  return {
37415
37908
  ide,
@@ -37421,7 +37914,7 @@ function installMcpConfigUnsafe(ide, options) {
37421
37914
  };
37422
37915
  }
37423
37916
  if (ide === "cursor") {
37424
- const configPath = path15.join(os4.homedir(), ".cursor", "mcp.json");
37917
+ const configPath = path16.join(os4.homedir(), ".cursor", "mcp.json");
37425
37918
  const write = mergeJsonMcpConfig(configPath, options);
37426
37919
  return {
37427
37920
  ide,
@@ -37439,7 +37932,7 @@ function installMcpConfigUnsafe(ide, options) {
37439
37932
  return { ide, ok: true, message: "✓ Claude Code MCP config updated with claude mcp add" };
37440
37933
  }
37441
37934
  }
37442
- const configPath = path15.join(os4.homedir(), ".claude.json");
37935
+ const configPath = path16.join(os4.homedir(), ".claude.json");
37443
37936
  const write = mergeJsonMcpConfig(configPath, options);
37444
37937
  return {
37445
37938
  ide,
@@ -37461,7 +37954,7 @@ function mergeJsonMcpConfig(configPath, options) {
37461
37954
  `);
37462
37955
  }
37463
37956
  function mergeCodexMcpConfig(configPath, options) {
37464
- const existing = fs14.existsSync(configPath) ? fs14.readFileSync(configPath, "utf8") : "";
37957
+ const existing = fs15.existsSync(configPath) ? fs15.readFileSync(configPath, "utf8") : "";
37465
37958
  const sectionPattern = createCodexMcpSectionPattern(options.mcpName);
37466
37959
  const withoutOld = existing.replace(sectionPattern, "").trimEnd();
37467
37960
  const launch = getNpxCliCommand(options.pkg);
@@ -37596,10 +38089,10 @@ function rejectPackageOption(parsed) {
37596
38089
  }
37597
38090
  }
37598
38091
  function readJsonObject(filePath) {
37599
- if (!fs14.existsSync(filePath)) {
38092
+ if (!fs15.existsSync(filePath)) {
37600
38093
  return {};
37601
38094
  }
37602
- return JSON.parse(fs14.readFileSync(filePath, "utf8"));
38095
+ return JSON.parse(fs15.readFileSync(filePath, "utf8"));
37603
38096
  }
37604
38097
  function asObject(value) {
37605
38098
  if (value && typeof value === "object" && !Array.isArray(value)) {
@@ -37608,25 +38101,25 @@ function asObject(value) {
37608
38101
  return {};
37609
38102
  }
37610
38103
  function writeConfigWithTapTapBackupIfChanged(filePath, nextContent, validate) {
37611
- const existed = fs14.existsSync(filePath);
37612
- const previousContent = existed ? fs14.readFileSync(filePath, "utf8") : void 0;
38104
+ const existed = fs15.existsSync(filePath);
38105
+ const previousContent = existed ? fs15.readFileSync(filePath, "utf8") : void 0;
37613
38106
  if (previousContent === nextContent) {
37614
38107
  return { changed: false };
37615
38108
  }
37616
38109
  const backupPath = existed ? `${filePath}.taptap-maker.bak.latest` : void 0;
37617
- fs14.mkdirSync(path15.dirname(filePath), { recursive: true });
38110
+ fs15.mkdirSync(path16.dirname(filePath), { recursive: true });
37618
38111
  if (previousContent !== void 0 && backupPath) {
37619
- fs14.writeFileSync(backupPath, previousContent, "utf8");
38112
+ fs15.writeFileSync(backupPath, previousContent, "utf8");
37620
38113
  }
37621
38114
  try {
37622
- fs14.writeFileSync(filePath, nextContent, "utf8");
37623
- validate == null ? void 0 : validate(fs14.readFileSync(filePath, "utf8"));
38115
+ fs15.writeFileSync(filePath, nextContent, "utf8");
38116
+ validate == null ? void 0 : validate(fs15.readFileSync(filePath, "utf8"));
37624
38117
  return { changed: true, backupPath };
37625
38118
  } catch (error2) {
37626
38119
  if (previousContent !== void 0) {
37627
- fs14.writeFileSync(filePath, previousContent, "utf8");
38120
+ fs15.writeFileSync(filePath, previousContent, "utf8");
37628
38121
  } else {
37629
- fs14.rmSync(filePath, { force: true });
38122
+ fs15.rmSync(filePath, { force: true });
37630
38123
  }
37631
38124
  throw error2;
37632
38125
  }
@@ -37641,10 +38134,10 @@ function formatMcpInstallMessage(label, configPath, write) {
37641
38134
  ].filter(Boolean).join("\n");
37642
38135
  }
37643
38136
  function saveInitState(targetDir, state) {
37644
- fs14.mkdirSync(getMakerHome(), { recursive: true });
37645
- const key = crypto3.createHash("sha256").update(path15.resolve(targetDir)).digest("hex").slice(0, 16);
37646
- fs14.writeFileSync(
37647
- path15.join(getMakerHome(), `init-state-${key}.json`),
38137
+ fs15.mkdirSync(getMakerHome(), { recursive: true });
38138
+ const key = crypto3.createHash("sha256").update(path16.resolve(targetDir)).digest("hex").slice(0, 16);
38139
+ fs15.writeFileSync(
38140
+ path16.join(getMakerHome(), `init-state-${key}.json`),
37648
38141
  `${JSON.stringify({ ...state, updated_at: (/* @__PURE__ */ new Date()).toISOString() }, null, 2)}
37649
38142
  `,
37650
38143
  "utf8"
@@ -37792,7 +38285,7 @@ function makerEnvOption(parsed) {
37792
38285
  return env;
37793
38286
  }
37794
38287
  const targetDir = stringOption(parsed, "target_dir");
37795
- return getMakerEnvironment(void 0, targetDir ? path15.resolve(targetDir) : process.cwd());
38288
+ return getMakerEnvironment(void 0, targetDir ? path16.resolve(targetDir) : process.cwd());
37796
38289
  }
37797
38290
  function mcpVerifyModeOption(parsed) {
37798
38291
  const mode = stringOption(parsed, "mode") || "npx";
@@ -39285,7 +39778,7 @@ var StreamableHTTPClientTransport = class {
39285
39778
  };
39286
39779
 
39287
39780
  // src/mcp-proxy/proxy.ts
39288
- import * as path17 from "node:path";
39781
+ import * as path18 from "node:path";
39289
39782
  import * as crypto6 from "node:crypto";
39290
39783
 
39291
39784
  // src/mcp-proxy/cookieJar.ts
@@ -39467,8 +39960,8 @@ function createCookieFetch(cookieJar) {
39467
39960
  }
39468
39961
 
39469
39962
  // src/core/utils/logWriter.ts
39470
- import * as fs15 from "node:fs";
39471
- import * as path16 from "node:path";
39963
+ import * as fs16 from "node:fs";
39964
+ import * as path17 from "node:path";
39472
39965
  import * as crypto5 from "node:crypto";
39473
39966
 
39474
39967
  // src/core/types/log.ts
@@ -39509,7 +40002,7 @@ var LogWriter = class {
39509
40002
  return;
39510
40003
  }
39511
40004
  try {
39512
- await fs15.promises.mkdir(this.config.logDir, { recursive: true });
40005
+ await fs16.promises.mkdir(this.config.logDir, { recursive: true });
39513
40006
  await this.cleanupOldLogs();
39514
40007
  this.initialized = true;
39515
40008
  } catch (error2) {
@@ -39532,7 +40025,7 @@ var LogWriter = class {
39532
40025
  */
39533
40026
  getLogFilePath(date5) {
39534
40027
  const d = date5 || this.getCurrentDate();
39535
- return path16.join(this.config.logDir, `${this.config.prefix}-${d}.log`);
40028
+ return path17.join(this.config.logDir, `${this.config.prefix}-${d}.log`);
39536
40029
  }
39537
40030
  /**
39538
40031
  * 获取或创建写入流
@@ -39547,7 +40040,7 @@ var LogWriter = class {
39547
40040
  }
39548
40041
  this.currentDate = date5;
39549
40042
  try {
39550
- this.writeStream = fs15.createWriteStream(this.getLogFilePath(date5), {
40043
+ this.writeStream = fs16.createWriteStream(this.getLogFilePath(date5), {
39551
40044
  flags: "a",
39552
40045
  encoding: "utf8"
39553
40046
  });
@@ -39599,11 +40092,11 @@ var LogWriter = class {
39599
40092
  if (this.shouldWriteToFile(level) && this.initialized && this.config.enabled) {
39600
40093
  try {
39601
40094
  const filePath = this.getLogFilePath();
39602
- const dir = path16.dirname(filePath);
39603
- if (!fs15.existsSync(dir)) {
39604
- fs15.mkdirSync(dir, { recursive: true });
40095
+ const dir = path17.dirname(filePath);
40096
+ if (!fs16.existsSync(dir)) {
40097
+ fs16.mkdirSync(dir, { recursive: true });
39605
40098
  }
39606
- fs15.appendFileSync(filePath, message, "utf8");
40099
+ fs16.appendFileSync(filePath, message, "utf8");
39607
40100
  } catch {
39608
40101
  }
39609
40102
  }
@@ -39614,7 +40107,7 @@ var LogWriter = class {
39614
40107
  async cleanupOldLogs() {
39615
40108
  if (this.config.maxDays <= 0) return;
39616
40109
  try {
39617
- const files = await fs15.promises.readdir(this.config.logDir);
40110
+ const files = await fs16.promises.readdir(this.config.logDir);
39618
40111
  const cutoffDate = /* @__PURE__ */ new Date();
39619
40112
  cutoffDate.setDate(cutoffDate.getDate() - this.config.maxDays);
39620
40113
  const prefix = this.config.prefix;
@@ -39629,7 +40122,7 @@ var LogWriter = class {
39629
40122
  if (!Number.isNaN(year) && !Number.isNaN(month) && !Number.isNaN(day)) {
39630
40123
  const fileDate = new Date(year, month - 1, day);
39631
40124
  if (fileDate < cutoffDate) {
39632
- await fs15.promises.unlink(path16.join(this.config.logDir, file2));
40125
+ await fs16.promises.unlink(path17.join(this.config.logDir, file2));
39633
40126
  process.stderr.write(`[LogWriter] Deleted old log: ${file2}
39634
40127
  `);
39635
40128
  }
@@ -39664,7 +40157,7 @@ var LogWriter = class {
39664
40157
  };
39665
40158
 
39666
40159
  // src/mcp-proxy/proxy.ts
39667
- var VERSION2 = typeof __PROXY_VERSION__ !== "undefined" ? __PROXY_VERSION__ : "dev";
40160
+ var VERSION3 = typeof __PROXY_VERSION__ !== "undefined" ? __PROXY_VERSION__ : "dev";
39668
40161
  var LOCAL_PROXY_TAG = "local";
39669
40162
  var DEFAULT_RECONNECT_INTERVAL_MS = 5e3;
39670
40163
  var MAX_RECONNECT_INTERVAL_MS = 60 * 1e3;
@@ -39703,10 +40196,10 @@ var TapTapMCPProxy = class {
39703
40196
  const { user_id, project_id } = this.config.tenant;
39704
40197
  let logDir;
39705
40198
  if (user_id && project_id) {
39706
- logDir = path17.join(logRoot, "proxy", user_id, project_id);
40199
+ logDir = path18.join(logRoot, "proxy", user_id, project_id);
39707
40200
  } else {
39708
40201
  const kidHash = crypto6.createHash("sha256").update(this.config.auth.kid).digest("hex").substring(0, 8);
39709
- logDir = path17.join(logRoot, "proxy", kidHash);
40202
+ logDir = path18.join(logRoot, "proxy", kidHash);
39710
40203
  }
39711
40204
  return new LogWriter({
39712
40205
  logDir,
@@ -39742,7 +40235,7 @@ var TapTapMCPProxy = class {
39742
40235
  */
39743
40236
  async start() {
39744
40237
  var _a3, _b;
39745
- this.log("info", `TapTap MCP Proxy v${VERSION2}`);
40238
+ this.log("info", `TapTap MCP Proxy v${VERSION3}`);
39746
40239
  this.log("info", "Starting...");
39747
40240
  this.log("info", `Server URL: ${this.config.server.url}`);
39748
40241
  this.log("info", `Project Path: ${this.config.tenant.project_path}`);