@taptap/maker 0.0.26 → 0.0.27-beta.1

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(path22) {
3237
- let input2 = path22;
3236
+ function removeDotSegments(path23) {
3237
+ let input2 = path23;
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 [path22, query] = wsComponent.resourceName.split("?");
3437
- wsComponent.path = path22 && path22 !== "/" ? path22 : void 0;
3436
+ const [path23, query] = wsComponent.resourceName.split("?");
3437
+ wsComponent.path = path23 && path23 !== "/" ? path23 : 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, fs20, exportName) {
12494
+ function addFormats(ajv, list, fs21, 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, fs20[f]);
12499
+ ajv.addFormat(f, fs21[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 fs20 = __require("fs");
12513
- function checkPathExt(path22, options) {
12512
+ var fs21 = __require("fs");
12513
+ function checkPathExt(path23, 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 && path22.substr(-p.length).toLowerCase() === p) {
12524
+ if (p && path23.substr(-p.length).toLowerCase() === p) {
12525
12525
  return true;
12526
12526
  }
12527
12527
  }
12528
12528
  return false;
12529
12529
  }
12530
- function checkStat(stat, path22, options) {
12530
+ function checkStat(stat, path23, options) {
12531
12531
  if (!stat.isSymbolicLink() && !stat.isFile()) {
12532
12532
  return false;
12533
12533
  }
12534
- return checkPathExt(path22, options);
12534
+ return checkPathExt(path23, options);
12535
12535
  }
12536
- function isexe(path22, options, cb) {
12537
- fs20.stat(path22, function(er, stat) {
12538
- cb(er, er ? false : checkStat(stat, path22, options));
12536
+ function isexe(path23, options, cb) {
12537
+ fs21.stat(path23, function(er, stat) {
12538
+ cb(er, er ? false : checkStat(stat, path23, options));
12539
12539
  });
12540
12540
  }
12541
- function sync(path22, options) {
12542
- return checkStat(fs20.statSync(path22), path22, options);
12541
+ function sync(path23, options) {
12542
+ return checkStat(fs21.statSync(path23), path23, 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 fs20 = __require("fs");
12553
- function isexe(path22, options, cb) {
12554
- fs20.stat(path22, function(er, stat) {
12552
+ var fs21 = __require("fs");
12553
+ function isexe(path23, options, cb) {
12554
+ fs21.stat(path23, function(er, stat) {
12555
12555
  cb(er, er ? false : checkStat(stat, options));
12556
12556
  });
12557
12557
  }
12558
- function sync(path22, options) {
12559
- return checkStat(fs20.statSync(path22), options);
12558
+ function sync(path23, options) {
12559
+ return checkStat(fs21.statSync(path23), 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 fs20 = __require("fs");
12583
+ var fs21 = __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(path22, options, cb) {
12592
+ function isexe(path23, 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(path22, options || {}, function(er, is) {
12602
+ isexe(path23, 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(path22, options || {}, function(er, is) {
12611
+ core(path23, 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(path22, options) {
12621
+ function sync(path23, options) {
12622
12622
  try {
12623
- return core.sync(path22, options || {});
12623
+ return core.sync(path23, 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 path22 = __require("path");
12639
+ var path23 = __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 = path22.join(pathPart, cmd);
12677
+ const pCmd = path23.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 = path22.join(pathPart, cmd);
12704
+ const pCmd = path23.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 path22 = __require("path");
12752
+ var path23 = __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 ? path22.delimiter : void 0
12770
+ pathExt: withoutPathExt ? path23.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 = path22.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
12779
+ resolved = path23.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 [path22, argument] = match[0].replace(/#! ?/, "").split(" ");
12834
- const binary = path22.split("/").pop();
12833
+ const [path23, argument] = match[0].replace(/#! ?/, "").split(" ");
12834
+ const binary = path23.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 fs20 = __require("fs");
12847
+ var fs21 = __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 = fs20.openSync(command, "r");
12855
- fs20.readSync(fd, buffer, 0, size, 0);
12856
- fs20.closeSync(fd);
12854
+ fd = fs21.openSync(command, "r");
12855
+ fs21.readSync(fd, buffer, 0, size, 0);
12856
+ fs21.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 path22 = __require("path");
12869
+ var path23 = __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 = path22.normalize(parsed.command);
12894
+ parsed.command = path23.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(" ");
@@ -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: path22, errorMaps, issueData } = params;
13370
- const fullPath = [...path22, ...issueData.path || []];
13369
+ const { data, path: path23, errorMaps, issueData } = params;
13370
+ const fullPath = [...path23, ...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, path22, key) {
13485
+ constructor(parent, value, path23, key) {
13486
13486
  this._cachedPath = [];
13487
13487
  this.parent = parent;
13488
13488
  this.data = value;
13489
- this._path = path22;
13489
+ this._path = path23;
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, path22) {
17139
- if (!path22)
17138
+ function getElementAtPath(obj, path23) {
17139
+ if (!path23)
17140
17140
  return obj;
17141
- return path22.reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
17141
+ return path23.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(path22, issues) {
17526
+ function prefixIssues(path23, issues) {
17527
17527
  return issues.map((iss) => {
17528
17528
  var _a3;
17529
17529
  (_a3 = iss).path ?? (_a3.path = []);
17530
- iss.path.unshift(path22);
17530
+ iss.path.unshift(path23);
17531
17531
  return iss;
17532
17532
  });
17533
17533
  }
@@ -29163,9 +29163,9 @@ var MAKER_CAPABILITY_ROUTING_INDEX = `TapTap Maker routing index:
29163
29163
  maker://status; use maker_status_lite when resources are unavailable.
29164
29164
  - Build, preview, run, submit, or push: after checking project status, use
29165
29165
  maker_build_current_directory.
29166
- - Tap flows: test QR -> generate_test_qrcode; ads or ad code -> first check
29167
- Maker project status, then use get_ad_config when primary configs are ready;
29168
- online player feedback, logs, or screenshots -> get_debug_feedbacks.
29166
+ - Ads: read maker://ads-integration-guide before any ad-related work.
29167
+ - Tap flows: test QR -> generate_test_qrcode; online player feedback, logs, or
29168
+ screenshots -> get_debug_feedbacks.
29169
29169
  - Game assets: Maker MCP also provides image, video, music, sound-effect,
29170
29170
  dialogue/voice, and 3D generation tools when exposed.
29171
29171
 
@@ -29283,12 +29283,15 @@ function createMakerAgentsPolicyBody() {
29283
29283
  "- Attempt `npx -y -p @taptap/maker taptap-maker mcp verify --json`; on Windows use",
29284
29284
  " `npx.cmd -y -p @taptap/maker taptap-maker mcp verify --json`. Record command failure as",
29285
29285
  " diagnostic evidence instead of skipping the check.",
29286
- "- This verifies only the standard `@taptap/maker` npx/CLI launch path and returns command,",
29287
- " status, signal, stdout, stderr, error, and failure_type. It does not start the Maker MCP server",
29288
- " and does not read or validate the client's active MCP config, WorkBuddy trust, cwd, or Roots.",
29289
- " A successful verify result does not prove that the client MCP config works.",
29290
- "- Then inspect and reproduce the active config path, command, ordered args, cwd, WorkBuddy",
29291
- " enable/trust state, workspace/Roots, Node/npm/npx paths, client PATH, exit status, and stderr.",
29286
+ "- This uses the same resolved launcher as MCP install, starts `@taptap/maker`, completes MCP",
29287
+ " initialize and tools/list, and returns launcher_kind, command, stage, tools, stderr, error,",
29288
+ " and failure_type. It does not read the client's active config or validate client trust,",
29289
+ " client config caching, or Roots.",
29290
+ "- First identify the active AI client from reliable evidence, then inspect only that client's",
29291
+ " active config path, command, ordered args, cwd, workspace/Roots, Node/npm/npx paths,",
29292
+ " client PATH, exit status, and stderr.",
29293
+ "- Only when the active client is confirmed to be WorkBuddy, inspect its enable/trust state.",
29294
+ "- Never use one client's configuration or trust state to diagnose another client.",
29292
29295
  "- Classify the root cause from evidence before repairing it. Do not automatically change trust",
29293
29296
  " storage, PATH, cwd, credentials, or game code.",
29294
29297
  "- Treat `taptap-maker mcp install --ide <client>` as an optional recovery only after evidence",
@@ -29308,20 +29311,24 @@ function createMakerAgentsPolicyBody() {
29308
29311
  "- If the MCP connection is established but a tool or resource call fails, including `-32003`,",
29309
29312
  " use a separate evidence-first runtime-error workflow. Do not assign a fixed meaning to the",
29310
29313
  " error code; preserve the exact client error.",
29311
- "- `mcp verify` is not the primary check for an already connected session because it only tests",
29312
- " the standard npx/CLI launch path.",
29314
+ "- `mcp verify` is not the primary check for an already connected session because it tests only",
29315
+ " the local launcher and stdio MCP path.",
29313
29316
  "- Collect the failed tool/resource, redacted request parameters, current `tools/list`, exact",
29314
29317
  " error code/message/data, complete sanitized `remote_result`, request/correlation IDs,",
29315
29318
  " timestamp with timezone, OS/architecture, AI client and `@taptap/maker` package versions,",
29316
29319
  " and stable reproduction steps. Preserve useful nested fields while removing credentials.",
29320
+ "- Python and maker-lua-lsp affect local Lua diagnostics, not MCP connection or remote build.",
29321
+ "- Dev-kit, package update, and AGENTS policy checks are maintenance checks, not proof of a",
29322
+ " client connection failure.",
29317
29323
  "- Do not rewrite command, cwd, PATH, trust state, credentials, or game code unless the",
29318
29324
  " collected evidence identifies that cause.",
29319
29325
  "",
29320
29326
  "Maker ad workflow:",
29321
29327
  "",
29322
- "- For any ad-related request or code touching ads, first inspect Maker project status. Call",
29323
- " `get_ad_config` only after primary local project configs are initialized and before reading",
29324
- " local SDK docs, editing ad code, or testing ad behavior. Triggers include 广告, 激励视频,",
29328
+ "- For any ad-related request or code touching ads, first read",
29329
+ " `maker://ads-integration-guide`, then follow it to inspect Maker project status, call",
29330
+ " `get_ad_config`, and read the project engine document before editing ad code or testing",
29331
+ " ad behavior. Triggers include 广告, 激励视频,",
29325
29332
  " 播放广告, ad ID, ad placement, ad status, ad config, and `ShowRewardVideoAd`.",
29326
29333
  "- Treat `get_ad_config` as the source of truth for current project ad activation status and",
29327
29334
  " ad config. Do not infer ad readiness from local SDK docs, `.maker-mcp/config.json`, or",
@@ -32432,7 +32439,7 @@ function formatMakerSkillStatus(_options = {}) {
32432
32439
  "- Voice audition previews are not saved to the project.",
32433
32440
  "- Local MCP does not transcode generated audio to OGG.",
32434
32441
  "- Use create_3d_asset with start/query/continue/post_process for game 3D model assets.",
32435
- "- For any ad-related request, inspect Maker project status first and call get_ad_config only after primary local project configs are initialized.",
32442
+ "- For any ad-related request, first read `maker://ads-integration-guide`, then follow it to inspect Maker project status, call get_ad_config, and read the project engine document.",
32436
32443
  "- Do not infer ad readiness from local SDK docs, .maker-mcp/config.json, or runtime callbacks.",
32437
32444
  "- If primary local project configs are missing, keep ad config unavailable. Build only for an explicit user build/submit/preview request, and do not automatically rebuild when local configs remain missing after success.",
32438
32445
  "- If get_ad_config reports missing app_id or developer_id, call generate_test_qrcode once, then call get_ad_config again.",
@@ -36132,7 +36139,7 @@ var MAKER_REMOTE_PROXY_PUBLIC_DESCRIPTIONS = {
36132
36139
  "Call it only with the TapTap user_id explicitly provided by the user; never infer an account ID."
36133
36140
  ].join(" "),
36134
36141
  get_ad_config: [
36135
- "After Maker project status confirms the primary local project configs are initialized, use this as the first remote step for ad-related requests.",
36142
+ "For any ad-related request, read maker://ads-integration-guide first. After Maker project status confirms the primary local project configs are initialized, use this as the first remote step.",
36136
36143
  "It is the source of truth for current ad activation and configuration, and synchronizes the result into .project/settings.json at @runtime.ad.",
36137
36144
  "The local preflight does not call the remote tool while project.json or settings.json is missing. Missing local configs do not authorize an automatic build.",
36138
36145
  "Use maker_build_current_directory only for an explicit user build, submit, or preview request, then check project status again. If configs remain missing, report the limitation and do not rebuild automatically.",
@@ -36297,7 +36304,7 @@ function applyDefaults(config2) {
36297
36304
  var MAKER_MCP_TRACKING_ACTION = "tapmaker_mcp_call";
36298
36305
  var MAKER_MCP_TRACKING_SOURCE = "local_mcp";
36299
36306
  var MAKER_MCP_TRACKING_TIMEOUT_MS = 1500;
36300
- var MAKER_MCP_VERSION = "0.0.26".trim() ? "0.0.26".trim() : "dev";
36307
+ var MAKER_MCP_VERSION = "0.0.27-beta.1".trim() ? "0.0.27-beta.1".trim() : "dev";
36301
36308
  var TRACKING_ERROR_MAX_LENGTH = 500;
36302
36309
  function buildMakerMcpTrackingPayload(event) {
36303
36310
  var _a3, _b, _c;
@@ -36373,8 +36380,34 @@ async function reportMakerMcpActivity(event) {
36373
36380
  }
36374
36381
  }
36375
36382
 
36383
+ // src/maker/server/adIntegrationGuide.ts
36384
+ var MAKER_ADS_INTEGRATION_GUIDE_URI = "maker://ads-integration-guide";
36385
+ function formatMakerAdsIntegrationGuide() {
36386
+ return `TapTap Maker ads integration guide
36387
+
36388
+ Use the MCP tool and the project engine document as consecutive steps in one workflow. They are
36389
+ not competing ad integrations.
36390
+
36391
+ 1. Read maker://status, or call maker_status_lite when resources are unavailable, and confirm the
36392
+ primary Maker project configs are initialized.
36393
+ 2. Call get_ad_config before reading ad readiness from any local file or writing ad code. This tool
36394
+ checks activation and synchronizes the current ad configuration into
36395
+ .project/settings.json at @runtime.ad.
36396
+ 3. If get_ad_config reports that app_id or developer_id is missing, call generate_test_qrcode once
36397
+ and then retry get_ad_config. If ad.status is not 1, report warning and ad.url and wait for the
36398
+ user to complete the returned action before retrying.
36399
+ 4. After get_ad_config returns a usable configuration, read the project-local engine document
36400
+ engine-docs/recipes/sdk.md. Treat that document as the source of truth for Maker ad code and do
36401
+ not search the web for an alternative integration.
36402
+ 5. Implement rewarded video ads with sdk:ShowRewardVideoAd as documented there. Grant the reward
36403
+ only when result.success is true.
36404
+
36405
+ Do not build automatically just because local project configs are missing. Use
36406
+ maker_build_current_directory only when the user explicitly requests build, submit, or preview.`;
36407
+ }
36408
+
36376
36409
  // src/maker/server/mcp.ts
36377
- var VERSION = true ? "0.0.26" : "dev";
36410
+ var VERSION = true ? "0.0.27-beta.1" : "dev";
36378
36411
  var DEFAULT_BUILD_TIMEOUT_MS = 10 * 60 * 1e3;
36379
36412
  var DEFAULT_PROXY_RETRY_ATTEMPTS = 5;
36380
36413
  var DEFAULT_PROXY_RETRY_DELAY_MS = 30 * 1e3;
@@ -36538,6 +36571,12 @@ var resources = [
36538
36571
  name: "Maker status",
36539
36572
  description: "Local TapTap Maker project status, including Git, PAT/TapTap auth, project binding, AI dev kit status, and bundled workflow guide document paths. Maker initialization next_step: taptap-maker init. Standard init/clone/download flow: show the Maker app list first and let the user choose an existing app or 0/new. Create-new-project flow: use taptap-maker init --create only when the user clearly asks to create a new Maker project.",
36540
36573
  mimeType: "text/plain"
36574
+ },
36575
+ {
36576
+ uri: MAKER_ADS_INTEGRATION_GUIDE_URI,
36577
+ name: "Maker ads integration guide",
36578
+ description: "Canonical entry document for Maker ads. Connects get_ad_config activation and configuration checks with the project-local engine-docs/recipes/sdk.md implementation guide.",
36579
+ mimeType: "text/plain"
36541
36580
  }
36542
36581
  ];
36543
36582
  async function listMakerTools(options) {
@@ -36935,7 +36974,7 @@ async function startMakerMcpServer() {
36935
36974
  });
36936
36975
  server.setRequestHandler(ReadResourceRequestSchema, async (request, extra) => {
36937
36976
  const uri = request.params.uri;
36938
- if (uri !== "maker://status") {
36977
+ if (uri !== "maker://status" && uri !== MAKER_ADS_INTEGRATION_GUIDE_URI) {
36939
36978
  throw new McpError(ErrorCode.InvalidParams, `Unknown Maker resource: ${uri}`);
36940
36979
  }
36941
36980
  const startedAt = Date.now();
@@ -36947,7 +36986,7 @@ async function startMakerMcpServer() {
36947
36986
  {
36948
36987
  uri,
36949
36988
  mimeType: "text/plain",
36950
- text: await formatStatus({ listClientRoots })
36989
+ text: uri === MAKER_ADS_INTEGRATION_GUIDE_URI ? formatMakerAdsIntegrationGuide() : await formatStatus({ listClientRoots })
36951
36990
  }
36952
36991
  ]
36953
36992
  };
@@ -39133,9 +39172,9 @@ function indent2(value) {
39133
39172
  // src/maker/cli/commands.ts
39134
39173
  import { spawnSync as spawnSync7 } from "node:child_process";
39135
39174
  import crypto3 from "node:crypto";
39136
- import fs18 from "node:fs";
39175
+ import fs19 from "node:fs";
39137
39176
  import os4 from "node:os";
39138
- import path19 from "node:path";
39177
+ import path20 from "node:path";
39139
39178
  import readline from "node:readline/promises";
39140
39179
  import { stdin as input, stdout as output } from "node:process";
39141
39180
 
@@ -39280,8 +39319,160 @@ function formatError2(error2) {
39280
39319
  return error2 instanceof Error ? error2.message : String(error2);
39281
39320
  }
39282
39321
 
39322
+ // src/maker/cli/mcpLauncher.ts
39323
+ import fs18 from "node:fs";
39324
+ import path19 from "node:path";
39325
+ var DEFAULT_VERIFY_TIMEOUT_MS = 9e4;
39326
+ var VERIFY_CLIENT_VERSION = "1.0.0";
39327
+ var REQUIRED_TOOL_NAME = "maker_status_lite";
39328
+ function resolveMakerMcpLauncher(options) {
39329
+ const platform = options.platform ?? process.platform;
39330
+ if (platform !== "win32") {
39331
+ const args = ["-y", "-p", options.packageName, "taptap-maker"];
39332
+ return {
39333
+ kind: "path_npx",
39334
+ command: "npx",
39335
+ args,
39336
+ commandAndArgs: ["npx", ...args]
39337
+ };
39338
+ }
39339
+ const existsSync2 = options.existsSync ?? fs18.existsSync;
39340
+ const execPath = options.execPath ?? process.execPath;
39341
+ const npmExecPath = options.npmExecPath ?? process.env.npm_execpath;
39342
+ const windowsPath = path19.win32;
39343
+ const npmCliCandidates = uniqueStrings([
39344
+ npmExecPath,
39345
+ windowsPath.join(windowsPath.dirname(execPath), "node_modules", "npm", "bin", "npm-cli.js")
39346
+ ]).filter(
39347
+ (candidate) => windowsPath.isAbsolute(candidate) && windowsPath.basename(candidate).toLowerCase() === "npm-cli.js" && existsSync2(candidate)
39348
+ );
39349
+ if (windowsPath.isAbsolute(execPath) && existsSync2(execPath) && npmCliCandidates[0]) {
39350
+ const args = [
39351
+ npmCliCandidates[0],
39352
+ "exec",
39353
+ "--yes",
39354
+ "--package",
39355
+ options.packageName,
39356
+ "--",
39357
+ "taptap-maker"
39358
+ ];
39359
+ return {
39360
+ kind: "node_npm_cli",
39361
+ command: execPath,
39362
+ args,
39363
+ commandAndArgs: [execPath, ...args]
39364
+ };
39365
+ }
39366
+ throw new Error(
39367
+ "No runnable absolute Node/npm launcher was found. Install Node.js with npm, then rerun taptap-maker mcp install."
39368
+ );
39369
+ }
39370
+ async function verifyMakerMcpLauncher(launcher, options = {}) {
39371
+ var _a3;
39372
+ const timeoutMs = options.timeoutMs ?? DEFAULT_VERIFY_TIMEOUT_MS;
39373
+ const transport = new StdioClientTransport({
39374
+ command: launcher.command,
39375
+ args: launcher.args,
39376
+ cwd: options.cwd,
39377
+ env: options.env,
39378
+ stderr: "pipe"
39379
+ });
39380
+ const client = new Client(
39381
+ { name: "taptap-maker-launcher-verifier", version: VERIFY_CLIENT_VERSION },
39382
+ { capabilities: {} }
39383
+ );
39384
+ let stderr = "";
39385
+ (_a3 = transport.stderr) == null ? void 0 : _a3.on("data", (chunk) => {
39386
+ stderr += chunk.toString();
39387
+ });
39388
+ let stage = "initialize";
39389
+ try {
39390
+ await withTimeout(client.connect(transport), timeoutMs, stage);
39391
+ stage = "tools_list";
39392
+ const result = await withTimeout(client.listTools(), timeoutMs, stage);
39393
+ const toolNames = result.tools.map((tool) => tool.name);
39394
+ if (!toolNames.includes(REQUIRED_TOOL_NAME)) {
39395
+ return failureResult(
39396
+ launcher,
39397
+ stage,
39398
+ stderr,
39399
+ "missing_required_tool",
39400
+ `MCP tools/list did not include ${REQUIRED_TOOL_NAME}.`,
39401
+ toolNames
39402
+ );
39403
+ }
39404
+ return {
39405
+ ok: true,
39406
+ stage,
39407
+ launcherKind: launcher.kind,
39408
+ command: formatCommand(launcher),
39409
+ toolNames,
39410
+ ...stderr.trim() ? { stderr: stderr.trim() } : {}
39411
+ };
39412
+ } catch (error2) {
39413
+ const message = error2 instanceof Error ? error2.message : String(error2);
39414
+ return failureResult(launcher, stage, stderr, classifyVerificationFailure(message), message);
39415
+ } finally {
39416
+ await closeClient(client);
39417
+ }
39418
+ }
39419
+ function failureResult(launcher, stage, stderr, failureType, error2, toolNames = []) {
39420
+ return {
39421
+ ok: false,
39422
+ stage,
39423
+ launcherKind: launcher.kind,
39424
+ command: formatCommand(launcher),
39425
+ toolNames,
39426
+ ...stderr.trim() ? { stderr: stderr.trim() } : {},
39427
+ error: error2,
39428
+ failureType
39429
+ };
39430
+ }
39431
+ function classifyVerificationFailure(message) {
39432
+ if (/timed out/i.test(message)) {
39433
+ return "timeout";
39434
+ }
39435
+ if (/ENOENT|not recognized|spawn/i.test(message)) {
39436
+ return "spawn_error";
39437
+ }
39438
+ return "protocol_error";
39439
+ }
39440
+ async function withTimeout(promise2, timeoutMs, stage) {
39441
+ let timer;
39442
+ try {
39443
+ return await Promise.race([
39444
+ promise2,
39445
+ new Promise((_resolve, reject) => {
39446
+ timer = setTimeout(
39447
+ () => reject(new Error(`Maker MCP launcher verification timed out during ${stage}.`)),
39448
+ timeoutMs
39449
+ );
39450
+ })
39451
+ ]);
39452
+ } finally {
39453
+ if (timer) {
39454
+ clearTimeout(timer);
39455
+ }
39456
+ }
39457
+ }
39458
+ async function closeClient(client) {
39459
+ try {
39460
+ await withTimeout(client.close(), 5e3, "close");
39461
+ } catch {
39462
+ }
39463
+ }
39464
+ function formatCommand(launcher) {
39465
+ return launcher.commandAndArgs.map(quoteCommandArgument).join(" ");
39466
+ }
39467
+ function quoteCommandArgument(value) {
39468
+ return /\s/.test(value) ? JSON.stringify(value) : value;
39469
+ }
39470
+ function uniqueStrings(values) {
39471
+ return Array.from(new Set(values.filter((value) => Boolean(value))));
39472
+ }
39473
+
39283
39474
  // src/maker/cli/commands.ts
39284
- var VERSION2 = true ? "0.0.26" : "dev";
39475
+ var VERSION2 = true ? "0.0.27-beta.1" : "dev";
39285
39476
  var DEFAULT_MCP_NAME = "taptap-maker";
39286
39477
  var MAKER_NPM_PACKAGE = "@taptap/maker";
39287
39478
  var TWO_PART_COMMANDS = /* @__PURE__ */ new Set(["pat", "mcp", "dev-kit", "logs", "python", "lua-lsp", "agents"]);
@@ -39416,7 +39607,7 @@ function toOptionKey(value) {
39416
39607
  }
39417
39608
  async function runInit(parsed, ctx) {
39418
39609
  rejectPackageOption(parsed);
39419
- const targetDir = path19.resolve(stringOption(parsed, "target_dir") || process.cwd());
39610
+ const targetDir = path20.resolve(stringOption(parsed, "target_dir") || process.cwd());
39420
39611
  const env = makerEnvOption(parsed);
39421
39612
  const skipConfirm = booleanOption(parsed, "skip_confirm");
39422
39613
  const skipMcpInstall = booleanOption(parsed, "skip_mcp_install");
@@ -39485,15 +39676,36 @@ async function runInit(parsed, ctx) {
39485
39676
  });
39486
39677
  if (!skipMcpInstall) {
39487
39678
  const ides = parseIdeList(stringOption(parsed, "register_mcp") || "");
39679
+ const prepared = await prepareMcpLauncher({ env });
39680
+ if (!prepared.ok) {
39681
+ emit(ctx, "mcp_install", formatMcpLauncherFailure(prepared), prepared);
39682
+ throw new Error(prepared.error);
39683
+ }
39488
39684
  const installResults = installMcpConfigs({
39489
39685
  ides: ides.length > 0 ? ides : getDefaultMcpInstallIdes(),
39490
39686
  env,
39491
- pkg: MAKER_NPM_PACKAGE,
39492
- mcpName: DEFAULT_MCP_NAME
39687
+ mcpName: DEFAULT_MCP_NAME,
39688
+ launcher: prepared.launcher
39493
39689
  });
39494
39690
  for (const result of installResults) {
39495
39691
  emit(ctx, "mcp_install", result.message, result);
39496
39692
  }
39693
+ const failedInstalls = installResults.filter((result) => !result.ok);
39694
+ if (failedInstalls.length > 0) {
39695
+ saveInitState(targetDir, {
39696
+ status: "mcp_install_failed",
39697
+ target_dir: targetDir,
39698
+ env,
39699
+ selected_app_id: selected.id,
39700
+ mcp_install_failures: failedInstalls.map((result) => ({
39701
+ ide: result.ide,
39702
+ message: result.message
39703
+ }))
39704
+ });
39705
+ throw new Error(
39706
+ `Maker project checkout completed, but MCP config installation failed for: ${failedInstalls.map((result) => result.ide).join(", ")}. Fix the reported client config issue, then rerun taptap-maker mcp install.`
39707
+ );
39708
+ }
39497
39709
  }
39498
39710
  saveInitState(targetDir, {
39499
39711
  status: "completed",
@@ -39509,7 +39721,7 @@ async function runInit(parsed, ctx) {
39509
39721
  }
39510
39722
  async function runDoctor(parsed, ctx) {
39511
39723
  var _a3, _b;
39512
- const targetDir = path19.resolve(stringOption(parsed, "target_dir") || process.cwd());
39724
+ const targetDir = path20.resolve(stringOption(parsed, "target_dir") || process.cwd());
39513
39725
  const env = makerEnvOption(parsed);
39514
39726
  const git = checkGitEnvironment();
39515
39727
  const python = checkMakerPythonEnvironment();
@@ -39528,12 +39740,11 @@ async function runDoctor(parsed, ctx) {
39528
39740
  });
39529
39741
  const agentsPolicy = isProjectBound ? inspectMakerAgentsPolicy(projectRoot) : void 0;
39530
39742
  const orphanProcessCheck = inspectMakerOrphanProcesses();
39531
- const mcpToolsAvailability = inspectMakerMcpToolsAvailability({
39743
+ const doctorExecutionContext = inspectMakerDoctorExecutionContext({
39532
39744
  makerProjectDir: identify.projectRoot
39533
39745
  });
39534
39746
  const projectInitialization = isProjectBound ? inspectMakerProjectInitialization(projectRoot) : void 0;
39535
39747
  const projectSettings = isProjectBound ? inspectMakerProjectSettings(projectRoot) : void 0;
39536
- const workBuddyTrust = shouldShowWorkBuddyTrustInspection() ? inspectWorkBuddyTrustState(DEFAULT_MCP_NAME) : void 0;
39537
39748
  if (ctx.json) {
39538
39749
  writeJson({
39539
39750
  env,
@@ -39551,8 +39762,7 @@ async function runDoctor(parsed, ctx) {
39551
39762
  package_update: packageUpdate,
39552
39763
  project_initialization: projectInitialization,
39553
39764
  project_settings: projectSettings,
39554
- mcp_tools_availability: mcpToolsAvailability,
39555
- ...workBuddyTrust ? { workbuddy_trust: workBuddyTrust } : {},
39765
+ doctor_execution_context: doctorExecutionContext,
39556
39766
  orphan_process_check: orphanProcessCheck
39557
39767
  });
39558
39768
  return;
@@ -39592,9 +39802,8 @@ async function runDoctor(parsed, ctx) {
39592
39802
  "",
39593
39803
  formatMakerPackageUpdateStatus(packageUpdate),
39594
39804
  "",
39595
- formatMakerMcpToolsAvailability(mcpToolsAvailability),
39805
+ formatMakerDoctorExecutionContext(doctorExecutionContext),
39596
39806
  "",
39597
- workBuddyTrust ? formatWorkBuddyTrustInspection(workBuddyTrust) : "",
39598
39807
  formatMakerOrphanProcessStatus(orphanProcessCheck),
39599
39808
  "",
39600
39809
  formatMakerSkillStatus({ projectRoot }),
@@ -39602,44 +39811,36 @@ async function runDoctor(parsed, ctx) {
39602
39811
  ].filter(Boolean).join("\n")
39603
39812
  );
39604
39813
  }
39605
- function inspectMakerMcpToolsAvailability(options) {
39606
- const aiPwd = path19.resolve(process.cwd());
39607
- const aiPwdIdentify = identifyMakerProject({ cwd: aiPwd });
39608
- const makerProjectDir = options.makerProjectDir ? path19.resolve(options.makerProjectDir) : void 0;
39814
+ function inspectMakerDoctorExecutionContext(options) {
39815
+ const doctorCwd = path20.resolve(process.cwd());
39816
+ const makerProjectDir = options.makerProjectDir ? path20.resolve(options.makerProjectDir) : void 0;
39609
39817
  if (!makerProjectDir) {
39610
39818
  return {
39611
- tools_visibility: "refresh_ai_client_if_missing",
39612
- pwd_alignment: "not_bound",
39613
- ai_pwd: aiPwd,
39614
- ai_pwd_project_dir: aiPwdIdentify.projectRoot
39819
+ active_client_session: "not_checked",
39820
+ tools_visibility: "not_checked",
39821
+ doctor_cwd: doctorCwd,
39822
+ doctor_cwd_alignment: "not_bound"
39615
39823
  };
39616
39824
  }
39617
39825
  return {
39618
- tools_visibility: "refresh_ai_client_if_missing",
39619
- pwd_alignment: aiPwdIdentify.projectRoot && samePath2(aiPwdIdentify.projectRoot, makerProjectDir) ? "same_project" : "cwd_mismatch",
39620
- maker_project_dir: makerProjectDir,
39621
- ai_pwd: aiPwd,
39622
- ai_pwd_project_dir: aiPwdIdentify.projectRoot
39826
+ active_client_session: "not_checked",
39827
+ tools_visibility: "not_checked",
39828
+ target_dir: makerProjectDir,
39829
+ doctor_cwd: doctorCwd,
39830
+ doctor_cwd_alignment: samePath2(doctorCwd, makerProjectDir) ? "same_project" : "different_from_target"
39623
39831
  };
39624
39832
  }
39625
- function formatMakerMcpToolsAvailability(availability) {
39833
+ function formatMakerDoctorExecutionContext(context) {
39626
39834
  const lines = [
39627
- "Maker MCP tools availability",
39628
- `- tools_visibility: ${availability.tools_visibility}`,
39629
- "- hint: If Maker proxy tools are missing in this AI chat, this is common after install.",
39630
- "- next_action: Restart the AI client or open a new AI conversation; /mcp clients can Reconnect taptap-maker.",
39631
- `- pwd_alignment: ${availability.pwd_alignment}`
39835
+ "Doctor execution context",
39836
+ `- active_client_session: ${context.active_client_session}`,
39837
+ `- tools_visibility: ${context.tools_visibility}`,
39838
+ "- note: doctor cannot inspect the active AI client's loaded tools or configuration.",
39839
+ `- doctor_cwd_alignment: ${context.doctor_cwd_alignment}`,
39840
+ `- doctor_cwd: ${context.doctor_cwd}`
39632
39841
  ];
39633
- if (availability.pwd_alignment === "cwd_mismatch") {
39634
- lines.push(`- maker_project_dir: ${availability.maker_project_dir}`);
39635
- lines.push(`- ai_pwd: ${availability.ai_pwd}`);
39636
- lines.push(`- ai_pwd_project_dir: ${availability.ai_pwd_project_dir || "(none)"}`);
39637
- lines.push(
39638
- "- impact: Maker proxy tools may not appear because tools/list uses the AI client pwd."
39639
- );
39640
- lines.push(
39641
- "- next_action: Run the AI client from the Maker project directory, or reinstall MCP with --target-dir."
39642
- );
39842
+ if (context.target_dir) {
39843
+ lines.push(`- target_dir: ${context.target_dir}`);
39643
39844
  }
39644
39845
  return lines.join("\n");
39645
39846
  }
@@ -39647,9 +39848,9 @@ function samePath2(left, right) {
39647
39848
  return normalizePathForCompare3(left) === normalizePathForCompare3(right);
39648
39849
  }
39649
39850
  function normalizePathForCompare3(value) {
39650
- const resolved = path19.resolve(value);
39851
+ const resolved = path20.resolve(value);
39651
39852
  try {
39652
- return fs18.realpathSync.native(resolved);
39853
+ return fs19.realpathSync.native(resolved);
39653
39854
  } catch {
39654
39855
  return resolved;
39655
39856
  }
@@ -39967,7 +40168,7 @@ async function runPatSet(parsed, ctx) {
39967
40168
  }
39968
40169
  async function resolvePatSet(parsed, ctx) {
39969
40170
  if (booleanOption(parsed, "pat_stdin") || booleanOption(parsed, "pat_from_stdin")) {
39970
- const pat = fs18.readFileSync(0, "utf8").trim();
40171
+ const pat = fs19.readFileSync(0, "utf8").trim();
39971
40172
  if (!pat) {
39972
40173
  throw new Error("No PAT found on stdin.");
39973
40174
  }
@@ -39992,13 +40193,24 @@ async function runMcpInstall(parsed, ctx) {
39992
40193
  rejectPackageOption(parsed);
39993
40194
  const ides = parseIdeList(stringOption(parsed, "ide") || stringOption(parsed, "ides") || "");
39994
40195
  const explicitTargetDir = stringOption(parsed, "target_dir");
40196
+ const env = makerEnvOption(parsed);
40197
+ const cwd = explicitTargetDir ? path20.resolve(explicitTargetDir) : void 0;
40198
+ const prepared = await prepareMcpLauncher({ env, cwd });
40199
+ if (!prepared.ok) {
40200
+ writeMcpLauncherFailure(ctx, prepared);
40201
+ return;
40202
+ }
39995
40203
  const results = installMcpConfigs({
39996
40204
  ides: ides.length > 0 ? ides : getDefaultMcpInstallIdes(),
39997
- env: makerEnvOption(parsed),
39998
- pkg: MAKER_NPM_PACKAGE,
40205
+ env,
39999
40206
  mcpName: stringOption(parsed, "name") || DEFAULT_MCP_NAME,
40000
- cwd: explicitTargetDir ? path19.resolve(explicitTargetDir) : void 0
40207
+ cwd,
40208
+ launcher: prepared.launcher
40001
40209
  });
40210
+ const ok = results.every((result) => result.ok);
40211
+ if (!ok) {
40212
+ process.exitCode = 1;
40213
+ }
40002
40214
  if (ctx.json) {
40003
40215
  writeJson(results);
40004
40216
  return;
@@ -40006,43 +40218,103 @@ async function runMcpInstall(parsed, ctx) {
40006
40218
  process.stdout.write(`${results.map((result) => result.message).join("\n")}
40007
40219
  `);
40008
40220
  }
40221
+ async function prepareMcpLauncher(options) {
40222
+ let launcher;
40223
+ try {
40224
+ launcher = resolveMakerMcpLauncher({ packageName: MAKER_NPM_PACKAGE });
40225
+ } catch (error2) {
40226
+ return createMcpLauncherResolutionFailure(error2);
40227
+ }
40228
+ const verification = await verifyMakerMcpLauncher(launcher, {
40229
+ cwd: options.cwd,
40230
+ env: options.env === "production" ? void 0 : { TAPTAP_MCP_ENV: options.env }
40231
+ });
40232
+ if (!verification.ok) {
40233
+ return {
40234
+ ok: false,
40235
+ stage: verification.stage,
40236
+ launcher_kind: verification.launcherKind,
40237
+ command: verification.command,
40238
+ failure_type: verification.failureType || "protocol_error",
40239
+ error: verification.error || "Maker MCP launcher connectivity check failed.",
40240
+ stderr: verification.stderr,
40241
+ tools: verification.toolNames
40242
+ };
40243
+ }
40244
+ return { ok: true, launcher, verification };
40245
+ }
40246
+ function createMcpLauncherResolutionFailure(error2) {
40247
+ return {
40248
+ ok: false,
40249
+ stage: "resolve",
40250
+ failure_type: "launcher_not_found",
40251
+ error: error2 instanceof Error ? error2.message : String(error2),
40252
+ tools: []
40253
+ };
40254
+ }
40255
+ function writeMcpLauncherFailure(ctx, failure) {
40256
+ process.exitCode = 1;
40257
+ if (ctx.json) {
40258
+ writeJson(failure);
40259
+ return;
40260
+ }
40261
+ process.stdout.write(`${formatMcpLauncherFailure(failure)}
40262
+ `);
40263
+ }
40264
+ function formatMcpLauncherFailure(failure) {
40265
+ return [
40266
+ "✗ Maker MCP launcher connectivity check failed; no client config was changed",
40267
+ `- stage: ${failure.stage}`,
40268
+ failure.launcher_kind ? `- launcher_kind: ${failure.launcher_kind}` : "",
40269
+ failure.command ? `- command: ${failure.command}` : "",
40270
+ `- failure_type: ${failure.failure_type}`,
40271
+ `- error: ${failure.error}`,
40272
+ failure.stderr ? `- stderr:
40273
+ ${indent3(failure.stderr)}` : "",
40274
+ "- next_action: Fix the launcher shown above, then rerun taptap-maker mcp install."
40275
+ ].filter(Boolean).join("\n");
40276
+ }
40009
40277
  async function runMcpVerify(parsed, ctx) {
40010
- var _a3;
40011
40278
  rejectPackageOption(parsed);
40012
40279
  const mode = mcpVerifyModeOption(parsed);
40013
- const command = mode === "npx" ? getNpxCliCommand(MAKER_NPM_PACKAGE) : getCurrentCliCommand();
40014
- const result = spawnSync7(command.command, [...command.args, "help"], {
40015
- encoding: "utf8"
40016
- });
40017
- const failureType = classifyMcpVerifyFailure(result);
40018
- const commandText = formatShellCommand([command.command, ...command.args, "help"]);
40280
+ let launcher;
40281
+ try {
40282
+ launcher = mode === "npx" ? resolveMakerMcpLauncher({ packageName: MAKER_NPM_PACKAGE }) : getCurrentCliCommand();
40283
+ } catch (error2) {
40284
+ writeMcpLauncherFailure(ctx, createMcpLauncherResolutionFailure(error2));
40285
+ return;
40286
+ }
40287
+ const result = await verifyMakerMcpLauncher(launcher);
40019
40288
  const payload = {
40020
40289
  mode,
40021
40290
  package: mode === "npx" ? MAKER_NPM_PACKAGE : void 0,
40022
- command: commandText,
40023
- status: result.status,
40024
- signal: result.signal,
40025
- ok: result.status === 0,
40026
- stdout: result.stdout,
40291
+ launcher_kind: result.launcherKind,
40292
+ command: result.command,
40293
+ stage: result.stage,
40294
+ ok: result.ok,
40295
+ tools: result.toolNames,
40027
40296
  stderr: result.stderr,
40028
- error: (_a3 = result.error) == null ? void 0 : _a3.message,
40029
- failure_type: failureType,
40030
- explanation: failureType ? getMcpVerifyFailureExplanation(mode, failureType) : void 0,
40031
- next_steps: failureType ? getMcpVerifyNextSteps(mode, commandText) : void 0,
40032
- is_maker_mcp_started: false
40297
+ error: result.error,
40298
+ failure_type: result.failureType,
40299
+ explanation: result.ok ? void 0 : getMcpVerifyFailureExplanation(mode, result),
40300
+ next_steps: result.ok ? void 0 : getMcpVerifyNextSteps(mode, result.command),
40301
+ is_maker_mcp_started: result.stage === "tools_list"
40033
40302
  };
40303
+ if (!payload.ok) {
40304
+ process.exitCode = 1;
40305
+ }
40034
40306
  if (ctx.json) {
40035
40307
  writeJson(payload);
40036
40308
  return;
40037
40309
  }
40038
40310
  process.stdout.write(
40039
40311
  [
40040
- payload.ok ? "✓ MCP config command can spawn taptap-maker" : "✗ MCP config command check failed before Maker MCP started",
40312
+ payload.ok ? "✓ Maker MCP launcher connectivity verified" : payload.stage === "tools_list" ? "✗ Maker MCP started but tools/list validation failed" : "✗ MCP config command check failed before Maker MCP started",
40041
40313
  `- mode: ${payload.mode}`,
40042
40314
  `- command: ${payload.command}`,
40043
- mode === "npx" ? "- scope: verifies the npx command written by taptap-maker mcp install" : "- scope: verifies only the currently running CLI binary",
40044
- `- status: ${payload.status}`,
40045
- payload.signal ? `- signal: ${payload.signal}` : "",
40315
+ mode === "npx" ? "- scope: verifies the package launcher written by taptap-maker mcp install" : "- scope: verifies only the currently running CLI binary",
40316
+ `- launcher_kind: ${payload.launcher_kind}`,
40317
+ `- stage: ${payload.stage}`,
40046
40318
  payload.failure_type ? `- failure_type: ${payload.failure_type}` : "",
40047
40319
  payload.explanation ? `- explanation: ${payload.explanation}` : "",
40048
40320
  payload.error ? `- error: ${payload.error}` : "",
@@ -40056,7 +40328,7 @@ ${indent3(payload.stderr)}` : "",
40056
40328
  );
40057
40329
  }
40058
40330
  async function runAgentsUpdate(parsed, ctx) {
40059
- const targetDir = path19.resolve(stringOption(parsed, "target_dir") || process.cwd());
40331
+ const targetDir = path20.resolve(stringOption(parsed, "target_dir") || process.cwd());
40060
40332
  const result = updateMakerAgentsPolicy(targetDir);
40061
40333
  if (ctx.json) {
40062
40334
  writeJson(result);
@@ -40075,32 +40347,42 @@ async function runAgentsUpdate(parsed, ctx) {
40075
40347
  async function runUpgrade(parsed, ctx) {
40076
40348
  rejectPackageOption(parsed);
40077
40349
  const explicitTargetDir = stringOption(parsed, "target_dir");
40078
- const targetDir = path19.resolve(explicitTargetDir || process.cwd());
40350
+ const targetDir = path20.resolve(explicitTargetDir || process.cwd());
40079
40351
  const env = makerEnvOption(parsed);
40080
40352
  const ides = parseIdeList(stringOption(parsed, "ide") || stringOption(parsed, "ides") || "");
40353
+ const cwd = explicitTargetDir ? targetDir : void 0;
40354
+ const prepared = await prepareMcpLauncher({ env, cwd });
40355
+ if (!prepared.ok) {
40356
+ writeMcpLauncherFailure(ctx, prepared);
40357
+ return;
40358
+ }
40081
40359
  const installResults = installMcpConfigs({
40082
40360
  ides: ides.length > 0 ? ides : getDefaultMcpInstallIdes(),
40083
40361
  env,
40084
- pkg: MAKER_NPM_PACKAGE,
40085
40362
  mcpName: stringOption(parsed, "name") || DEFAULT_MCP_NAME,
40086
- cwd: explicitTargetDir ? targetDir : void 0
40363
+ cwd,
40364
+ launcher: prepared.launcher
40087
40365
  });
40088
40366
  const identify = identifyMakerProject({ cwd: targetDir });
40089
40367
  const agentsResult = identify.projectRoot ? updateMakerAgentsPolicy(identify.projectRoot) : void 0;
40090
40368
  const payload = {
40369
+ ok: installResults.every((result) => result.ok),
40091
40370
  target_dir: targetDir,
40092
40371
  env,
40093
40372
  mcp_install: installResults,
40094
40373
  agents_policy: agentsResult,
40095
40374
  restart_required: true
40096
40375
  };
40376
+ if (!payload.ok) {
40377
+ process.exitCode = 1;
40378
+ }
40097
40379
  if (ctx.json) {
40098
40380
  writeJson(payload);
40099
40381
  return;
40100
40382
  }
40101
40383
  process.stdout.write(
40102
40384
  [
40103
- "TapTap Maker upgrade completed",
40385
+ payload.ok ? "TapTap Maker upgrade completed" : "TapTap Maker upgrade completed with errors",
40104
40386
  "",
40105
40387
  ...installResults.map((result) => result.message),
40106
40388
  "",
@@ -40115,39 +40397,17 @@ async function runUpgrade(parsed, ctx) {
40115
40397
  ].join("\n")
40116
40398
  );
40117
40399
  }
40118
- function classifyMcpVerifyFailure(result) {
40119
- if (result.status === 0) {
40120
- return void 0;
40121
- }
40122
- if (result.error) {
40123
- return "spawn_error";
40124
- }
40125
- if (result.signal) {
40126
- return "signal";
40127
- }
40128
- if (typeof result.status === "number") {
40129
- return "non_zero_exit";
40130
- }
40131
- return "unknown_no_status";
40132
- }
40133
- function getMcpVerifyFailureExplanation(mode, failureType) {
40400
+ function getMcpVerifyFailureExplanation(mode, result) {
40134
40401
  if (mode === "self") {
40135
40402
  return [
40136
40403
  "The current taptap-maker CLI help command did not exit cleanly.",
40137
40404
  "This is a local CLI startup check, not a Maker MCP business error."
40138
40405
  ].join(" ");
40139
40406
  }
40140
- const base = "This is a local Node/npm/npx startup check, not a Maker MCP business error.";
40141
- if (failureType === "non_zero_exit") {
40142
- return `The configured npx command exited with a non-zero status. ${base}`;
40143
- }
40144
- if (failureType === "spawn_error") {
40145
- return `The configured npx command could not be spawned. ${base}`;
40146
- }
40147
- if (failureType === "signal") {
40148
- return `The configured npx command was terminated by a signal. ${base}`;
40149
- }
40150
- return `The configured npx command did not exit normally. ${base}`;
40407
+ return [
40408
+ `The configured package launcher failed during MCP ${result.stage}.`,
40409
+ "This is a local Node/npm/npx and stdio MCP connectivity check, not a Maker business tool error."
40410
+ ].join(" ");
40151
40411
  }
40152
40412
  function getMcpVerifyNextSteps(mode, commandText) {
40153
40413
  if (mode === "self") {
@@ -40156,11 +40416,11 @@ function getMcpVerifyNextSteps(mode, commandText) {
40156
40416
  return [
40157
40417
  `Run the command above directly: ${commandText}`,
40158
40418
  "Run `taptap-maker mcp verify --mode self` to verify the current CLI binary.",
40159
- "If direct npx also fails, check `where.exe npx`, `where.exe node`, `where.exe npm`, `node -v`, and `npm -v`."
40419
+ "On Windows, check the absolute node/npm paths shown above; do not repair cwd with `cd && npx.cmd`."
40160
40420
  ];
40161
40421
  }
40162
40422
  async function runDevKitUpdate(parsed, ctx) {
40163
- const targetDir = path19.resolve(stringOption(parsed, "target_dir") || process.cwd());
40423
+ const targetDir = path20.resolve(stringOption(parsed, "target_dir") || process.cwd());
40164
40424
  const result = await installAiDevKit({
40165
40425
  targetDir,
40166
40426
  preserveExisting: false,
@@ -40172,7 +40432,7 @@ async function runDevKitUpdate(parsed, ctx) {
40172
40432
  emitDevKitSkillInstallerFailure(ctx, result.skillInstaller, "AI skills install failed");
40173
40433
  }
40174
40434
  async function runLogsWatch(parsed, ctx) {
40175
- const targetDir = path19.resolve(stringOption(parsed, "target_dir") || process.cwd());
40435
+ const targetDir = path20.resolve(stringOption(parsed, "target_dir") || process.cwd());
40176
40436
  const intervalMs = parseDurationMs(stringOption(parsed, "interval") || "5s");
40177
40437
  const timeoutMs = numberOption(parsed, "timeout_ms") ?? DEFAULT_TOOL_CALL_TIMEOUT_MS;
40178
40438
  const maxPolls = numberOption(parsed, "max_polls");
@@ -40182,9 +40442,9 @@ async function runLogsWatch(parsed, ctx) {
40182
40442
  serverUrl: stringOption(parsed, "server_url"),
40183
40443
  env: makerEnvOption(parsed)
40184
40444
  });
40185
- const runtimeDir = path19.join(proxy.projectRoot, ".maker", "logs", "runtime");
40186
- const runtimeLog = path19.join(runtimeDir, "runtime.log");
40187
- const pidFile = path19.join(runtimeDir, "watcher.pid");
40445
+ const runtimeDir = path20.join(proxy.projectRoot, ".maker", "logs", "runtime");
40446
+ const runtimeLog = path20.join(runtimeDir, "runtime.log");
40447
+ const pidFile = path20.join(runtimeDir, "watcher.pid");
40188
40448
  const replacedWatcher = registerRuntimeLogWatcherProcess(pidFile);
40189
40449
  const runtimeLogClient = createRemoteRuntimeLogClient(proxy, timeoutMs);
40190
40450
  emit(ctx, "logs_watch_start", "Maker runtime log watcher started", {
@@ -40229,10 +40489,10 @@ async function runLogsWatch(parsed, ctx) {
40229
40489
  }
40230
40490
  }
40231
40491
  function registerRuntimeLogWatcherProcess(pidFile) {
40232
- fs18.mkdirSync(path19.dirname(pidFile), { recursive: true });
40492
+ fs19.mkdirSync(path20.dirname(pidFile), { recursive: true });
40233
40493
  const existingPid = readPidFile(pidFile);
40234
40494
  const previous = existingPid && existingPid !== process.pid ? stopExistingRuntimeLogWatcher(pidFile) : {};
40235
- fs18.writeFileSync(
40495
+ fs19.writeFileSync(
40236
40496
  pidFile,
40237
40497
  `${JSON.stringify(
40238
40498
  {
@@ -40250,10 +40510,10 @@ function registerRuntimeLogWatcherProcess(pidFile) {
40250
40510
  return previous;
40251
40511
  }
40252
40512
  function readPidFile(pidFile) {
40253
- if (!fs18.existsSync(pidFile)) {
40513
+ if (!fs19.existsSync(pidFile)) {
40254
40514
  return void 0;
40255
40515
  }
40256
- const raw = fs18.readFileSync(pidFile, "utf8").trim();
40516
+ const raw = fs19.readFileSync(pidFile, "utf8").trim();
40257
40517
  let pid = Number(raw);
40258
40518
  if (!Number.isInteger(pid) || pid <= 0) {
40259
40519
  try {
@@ -40273,7 +40533,7 @@ function installRuntimeLogWatcherPidCleanup(pidFile) {
40273
40533
  }
40274
40534
  cleaned = true;
40275
40535
  if (readPidFile(pidFile) === process.pid) {
40276
- fs18.rmSync(pidFile, { force: true });
40536
+ fs19.rmSync(pidFile, { force: true });
40277
40537
  }
40278
40538
  };
40279
40539
  process.once("exit", cleanup);
@@ -40424,7 +40684,7 @@ async function prepareDevKit(targetDir, ctx, options = {}) {
40424
40684
  onStart: (event) => emitSkillInstallerStart(ctx, event)
40425
40685
  });
40426
40686
  writeDevKitStagedGitignore(
40427
- path19.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE),
40687
+ path20.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE),
40428
40688
  listPresentDevKitManagedEntries(targetDir)
40429
40689
  );
40430
40690
  if (options.finalizeGitignore) {
@@ -40441,7 +40701,7 @@ async function prepareDevKit(targetDir, ctx, options = {}) {
40441
40701
  );
40442
40702
  } catch (error2) {
40443
40703
  writeDevKitStagedGitignore(
40444
- path19.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE),
40704
+ path20.join(targetDir, DEV_KIT_GITIGNORE_STAGING_FILE),
40445
40705
  listPresentDevKitManagedEntries(targetDir)
40446
40706
  );
40447
40707
  if (options.finalizeGitignore) {
@@ -40514,7 +40774,11 @@ function isPatValidationFailure(message) {
40514
40774
  ) || /(?:过期|失效)/.test(message);
40515
40775
  }
40516
40776
  function installMcpConfigs(options) {
40517
- return uniqueStrings(options.ides).flatMap((ide) => installMcpConfig(ide, options));
40777
+ return uniqueStrings2(options.ides).flatMap((ide) => installMcpConfig(ide, options)).map((result) => ({
40778
+ ...result,
40779
+ launcher_kind: options.launcher.kind,
40780
+ verified: true
40781
+ }));
40518
40782
  }
40519
40783
  function installMcpConfig(ide, options) {
40520
40784
  try {
@@ -40531,12 +40795,12 @@ function installMcpConfig(ide, options) {
40531
40795
  }
40532
40796
  function installMcpConfigUnsafe(ide, options) {
40533
40797
  if (ide === "codex") {
40534
- const configPath = path19.join(os4.homedir(), ".codex", "config.toml");
40798
+ const configPath = path20.join(os4.homedir(), ".codex", "config.toml");
40535
40799
  const write = mergeCodexMcpConfig(configPath, withClientIde(options, "codex"));
40536
40800
  return [createMcpInstallResult(ide, "Codex", configPath, write)];
40537
40801
  }
40538
40802
  if (ide === "cursor") {
40539
- const configPath = path19.join(os4.homedir(), ".cursor", "mcp.json");
40803
+ const configPath = path20.join(os4.homedir(), ".cursor", "mcp.json");
40540
40804
  const write = mergeJsonMcpConfig(configPath, withClientIde(options, "cursor"));
40541
40805
  return [createMcpInstallResult(ide, "Cursor", configPath, write)];
40542
40806
  }
@@ -40554,7 +40818,7 @@ function installMcpConfigUnsafe(ide, options) {
40554
40818
  ];
40555
40819
  }
40556
40820
  }
40557
- const configPath = path19.join(os4.homedir(), ".claude.json");
40821
+ const configPath = path20.join(os4.homedir(), ".claude.json");
40558
40822
  const write = mergeJsonMcpConfig(configPath, claudeOptions);
40559
40823
  return [createMcpInstallResult(ide, "Claude fallback", configPath, write)];
40560
40824
  }
@@ -40568,7 +40832,7 @@ function installMcpConfigUnsafe(ide, options) {
40568
40832
  }
40569
40833
  if (ide === "opencode") {
40570
40834
  const configPath = getOpenCodeMcpConfigPath();
40571
- if (!fs18.existsSync(configPath)) {
40835
+ if (!fs19.existsSync(configPath)) {
40572
40836
  return [{ ide, ok: false, message: "Skipped OpenCode: no supported config file found" }];
40573
40837
  }
40574
40838
  const write = mergeOpenCodeMcpConfig(configPath, withClientIde(options, "opencode"));
@@ -40636,7 +40900,7 @@ function getDefaultMcpInstallIdes() {
40636
40900
  if (getTraeMcpInstallPaths().length > 0) {
40637
40901
  ides.push("trae");
40638
40902
  }
40639
- if (fs18.existsSync(getOpenCodeMcpConfigPath())) {
40903
+ if (fs19.existsSync(getOpenCodeMcpConfigPath())) {
40640
40904
  ides.push("opencode");
40641
40905
  }
40642
40906
  if (getWorkBuddyMcpInstallPaths().length > 0) {
@@ -40647,13 +40911,13 @@ function getDefaultMcpInstallIdes() {
40647
40911
  function getTraeMcpInstallPaths() {
40648
40912
  const soloPaths = getExistingTraeUserConfigPaths(getTraeSoloMcpConfigPaths());
40649
40913
  const unverifiedPaths = getExistingConfigPaths(getTraeUnverifiedMcpConfigPaths());
40650
- return uniqueStrings([...soloPaths, ...unverifiedPaths]);
40914
+ return uniqueStrings2([...soloPaths, ...unverifiedPaths]);
40651
40915
  }
40652
40916
  function getExistingTraeUserConfigPaths(paths) {
40653
40917
  const seen = /* @__PURE__ */ new Set();
40654
40918
  return paths.filter((configPath) => {
40655
40919
  const key = normalizeConfigPathKey(configPath);
40656
- if (seen.has(key) || !fs18.existsSync(path19.dirname(configPath))) {
40920
+ if (seen.has(key) || !fs19.existsSync(path20.dirname(configPath))) {
40657
40921
  return false;
40658
40922
  }
40659
40923
  seen.add(key);
@@ -40664,7 +40928,7 @@ function getExistingConfigPaths(paths) {
40664
40928
  const seen = /* @__PURE__ */ new Set();
40665
40929
  return paths.filter((configPath) => {
40666
40930
  const key = normalizeConfigPathKey(configPath);
40667
- if (seen.has(key) || !fs18.existsSync(configPath)) {
40931
+ if (seen.has(key) || !fs19.existsSync(configPath)) {
40668
40932
  return false;
40669
40933
  }
40670
40934
  seen.add(key);
@@ -40672,65 +40936,62 @@ function getExistingConfigPaths(paths) {
40672
40936
  });
40673
40937
  }
40674
40938
  function normalizeConfigPathKey(configPath) {
40675
- const resolved = path19.resolve(configPath);
40939
+ const resolved = path20.resolve(configPath);
40676
40940
  return process.platform === "win32" || process.platform === "darwin" ? resolved.toLowerCase() : resolved;
40677
40941
  }
40678
40942
  function getTraeSoloMcpConfigPaths() {
40679
40943
  if (process.platform === "win32") {
40680
- const roaming = process.env.APPDATA || path19.join(os4.homedir(), "AppData", "Roaming");
40944
+ const roaming = process.env.APPDATA || path20.join(os4.homedir(), "AppData", "Roaming");
40681
40945
  return [
40682
- path19.join(roaming, "TRAE SOLO", "User", "mcp.json"),
40683
- path19.join(roaming, "TRAE SOLO CN", "User", "mcp.json")
40946
+ path20.join(roaming, "TRAE SOLO", "User", "mcp.json"),
40947
+ path20.join(roaming, "TRAE SOLO CN", "User", "mcp.json")
40684
40948
  ];
40685
40949
  }
40686
- const appSupport = path19.join(os4.homedir(), "Library", "Application Support");
40950
+ const appSupport = path20.join(os4.homedir(), "Library", "Application Support");
40687
40951
  return [
40688
- path19.join(appSupport, "TRAE SOLO CN", "User", "mcp.json"),
40689
- path19.join(appSupport, "TRAE SOLO", "User", "mcp.json")
40952
+ path20.join(appSupport, "TRAE SOLO CN", "User", "mcp.json"),
40953
+ path20.join(appSupport, "TRAE SOLO", "User", "mcp.json")
40690
40954
  ];
40691
40955
  }
40692
40956
  function getTraeUnverifiedMcpConfigPaths() {
40693
40957
  if (process.platform === "win32") {
40694
- const roaming = process.env.APPDATA || path19.join(os4.homedir(), "AppData", "Roaming");
40958
+ const roaming = process.env.APPDATA || path20.join(os4.homedir(), "AppData", "Roaming");
40695
40959
  return [
40696
- path19.join(roaming, "Trae", "User", "mcp.json"),
40697
- path19.join(roaming, "TRAE", "User", "mcp.json"),
40698
- path19.join(roaming, "Trae CN", "User", "mcp.json")
40960
+ path20.join(roaming, "Trae", "User", "mcp.json"),
40961
+ path20.join(roaming, "TRAE", "User", "mcp.json"),
40962
+ path20.join(roaming, "Trae CN", "User", "mcp.json")
40699
40963
  ];
40700
40964
  }
40701
- const appSupport = path19.join(os4.homedir(), "Library", "Application Support");
40965
+ const appSupport = path20.join(os4.homedir(), "Library", "Application Support");
40702
40966
  return [
40703
- path19.join(appSupport, "Trae", "User", "mcp.json"),
40704
- path19.join(appSupport, "TRAE", "User", "mcp.json"),
40705
- path19.join(appSupport, "Trae CN", "User", "mcp.json")
40967
+ path20.join(appSupport, "Trae", "User", "mcp.json"),
40968
+ path20.join(appSupport, "TRAE", "User", "mcp.json"),
40969
+ path20.join(appSupport, "Trae CN", "User", "mcp.json")
40706
40970
  ];
40707
40971
  }
40708
40972
  function getOpenCodeMcpConfigPath() {
40709
- return path19.join(os4.homedir(), ".config", "opencode", "opencode.jsonc");
40973
+ return path20.join(os4.homedir(), ".config", "opencode", "opencode.jsonc");
40710
40974
  }
40711
40975
  function getWorkBuddyHome() {
40712
- return path19.join(os4.homedir(), ".workbuddy");
40713
- }
40714
- function shouldShowWorkBuddyTrustInspection() {
40715
- return fs18.existsSync(getWorkBuddyHome());
40976
+ return path20.join(os4.homedir(), ".workbuddy");
40716
40977
  }
40717
40978
  function getWorkBuddyMcpInstallPaths(options = {}) {
40718
- const primary = path19.join(getWorkBuddyHome(), "mcp.json");
40719
- if (fs18.existsSync(primary) || options.createPrimary) {
40979
+ const primary = path20.join(getWorkBuddyHome(), "mcp.json");
40980
+ if (fs19.existsSync(primary) || options.createPrimary) {
40720
40981
  return [primary];
40721
40982
  }
40722
- const legacy = path19.join(getWorkBuddyHome(), ".mcp.json");
40723
- if (fs18.existsSync(legacy)) {
40983
+ const legacy = path20.join(getWorkBuddyHome(), ".mcp.json");
40984
+ if (fs19.existsSync(legacy)) {
40724
40985
  return [legacy];
40725
40986
  }
40726
40987
  return [];
40727
40988
  }
40728
40989
  function inspectWorkBuddyTrustState(mcpName) {
40729
40990
  const workbuddyHome = getWorkBuddyHome();
40730
- const connectorsDir = path19.join(workbuddyHome, "connectors");
40991
+ const connectorsDir = path20.join(workbuddyHome, "connectors");
40731
40992
  const accounts = [];
40732
40993
  const stateFiles = [];
40733
- if (!fs18.existsSync(connectorsDir)) {
40994
+ if (!fs19.existsSync(connectorsDir)) {
40734
40995
  return {
40735
40996
  status: "not_found",
40736
40997
  mcp_name: mcpName,
@@ -40740,12 +41001,12 @@ function inspectWorkBuddyTrustState(mcpName) {
40740
41001
  accounts
40741
41002
  };
40742
41003
  }
40743
- for (const entry of fs18.readdirSync(connectorsDir, { withFileTypes: true })) {
41004
+ for (const entry of fs19.readdirSync(connectorsDir, { withFileTypes: true })) {
40744
41005
  if (!entry.isDirectory()) {
40745
41006
  continue;
40746
41007
  }
40747
- const statePath = path19.join(connectorsDir, entry.name, "connector-states.json");
40748
- if (!fs18.existsSync(statePath)) {
41008
+ const statePath = path20.join(connectorsDir, entry.name, "connector-states.json");
41009
+ if (!fs19.existsSync(statePath)) {
40749
41010
  continue;
40750
41011
  }
40751
41012
  stateFiles.push(statePath);
@@ -40820,7 +41081,7 @@ function mergeJsonMcpConfig(configPath, options) {
40820
41081
  );
40821
41082
  }
40822
41083
  function mergeOpenCodeMcpConfig(configPath, options) {
40823
- const rawContent = fs18.readFileSync(configPath, "utf8");
41084
+ const rawContent = fs19.readFileSync(configPath, "utf8");
40824
41085
  const rewroteJsonc = normalizeJsonConfigContent(rawContent, { jsonc: true }) !== rawContent;
40825
41086
  const existing = readJsonObject(configPath, { jsonc: true });
40826
41087
  const mcp = asObject(existing.mcp);
@@ -40847,10 +41108,10 @@ function mergeOpenCodeMcpConfig(configPath, options) {
40847
41108
  return { ...write, rewroteJsonc: write.changed && rewroteJsonc };
40848
41109
  }
40849
41110
  function mergeCodexMcpConfig(configPath, options) {
40850
- const existing = fs18.existsSync(configPath) ? fs18.readFileSync(configPath, "utf8") : "";
41111
+ const existing = fs19.existsSync(configPath) ? fs19.readFileSync(configPath, "utf8") : "";
40851
41112
  const sectionPattern = createCodexMcpSectionPattern(options.mcpName);
40852
41113
  const withoutOld = existing.replace(sectionPattern, "").trimEnd();
40853
- const launch = getNpxCliCommand(options.pkg);
41114
+ const launch = options.launcher;
40854
41115
  const envValues = createMcpEnvironmentValues(options.env, options.clientIde);
40855
41116
  const envSection = Object.keys(envValues).length === 0 ? [] : [
40856
41117
  "",
@@ -40921,7 +41182,7 @@ function normalizeCodexMcpTablePath(tablePath, mcpName) {
40921
41182
  return `mcp_servers.${mcpName}${match[1] || ""}`;
40922
41183
  }
40923
41184
  function tryClaudeMcpAdd(options) {
40924
- const npxLaunch = getNpxCliCommand(options.pkg);
41185
+ const npxLaunch = options.launcher;
40925
41186
  const claudeArgs = [
40926
41187
  "mcp",
40927
41188
  "add",
@@ -40944,7 +41205,7 @@ function tryClaudeMcpAdd(options) {
40944
41205
  return { ok: result.status === 0 };
40945
41206
  }
40946
41207
  function createJsonMcpServerConfig(options) {
40947
- const launch = getNpxCliCommand(options.pkg);
41208
+ const launch = options.launcher;
40948
41209
  return {
40949
41210
  command: launch.command,
40950
41211
  args: launch.args,
@@ -40956,7 +41217,7 @@ function createJsonMcpServerConfig(options) {
40956
41217
  function createOpenCodeMcpServerConfig(options) {
40957
41218
  return {
40958
41219
  type: "local",
40959
- command: getOpenCodeNpxCliCommand(options.pkg),
41220
+ command: options.launcher.commandAndArgs,
40960
41221
  ...options.cwd ? { cwd: options.cwd } : {},
40961
41222
  ...createOptionalMcpEnvironment(options.env, "environment", options.clientIde),
40962
41223
  enabled: true
@@ -40981,30 +41242,17 @@ function createMcpEnvironmentValues(env, clientIde) {
40981
41242
  }
40982
41243
  return values;
40983
41244
  }
40984
- function getOpenCodeNpxCliCommand(pkg) {
40985
- const executable = process.platform === "win32" ? "npx.cmd" : "npx";
40986
- return [executable, "-y", "-p", pkg, "taptap-maker"];
40987
- }
40988
41245
  function getCurrentCliCommand() {
40989
41246
  if (process.argv[1]) {
40990
- return { command: process.execPath, args: [process.argv[1]] };
40991
- }
40992
- return { command: process.platform === "win32" ? "taptap-maker.cmd" : "taptap-maker", args: [] };
40993
- }
40994
- function getNpxCliCommand(pkg) {
40995
- return resolveNpxCliCommand(pkg);
40996
- }
40997
- function resolveNpxCliCommand(pkg, platform = process.platform) {
40998
- const npxArgs = ["-y", "-p", pkg, "taptap-maker"];
40999
- if (platform === "win32") {
41000
- const launch = getWindowsCmdLaunchCommand("npx.cmd", npxArgs);
41001
41247
  return {
41002
- command: launch.command,
41003
- args: launch.args,
41004
- commandAndArgs: [launch.command, ...launch.args]
41248
+ kind: "current_cli",
41249
+ command: process.execPath,
41250
+ args: [process.argv[1]],
41251
+ commandAndArgs: [process.execPath, process.argv[1]]
41005
41252
  };
41006
41253
  }
41007
- return { command: "npx", args: npxArgs, commandAndArgs: ["npx", ...npxArgs] };
41254
+ const command = process.platform === "win32" ? "taptap-maker.cmd" : "taptap-maker";
41255
+ return { kind: "current_cli", command, args: [], commandAndArgs: [command] };
41008
41256
  }
41009
41257
  function getWindowsCmdLaunchCommand(command, args) {
41010
41258
  return { command: "cmd.exe", args: ["/d", "/s", "/c", command, ...args] };
@@ -41017,10 +41265,10 @@ function rejectPackageOption(parsed) {
41017
41265
  }
41018
41266
  }
41019
41267
  function readJsonObject(filePath, options = {}) {
41020
- if (!fs18.existsSync(filePath)) {
41268
+ if (!fs19.existsSync(filePath)) {
41021
41269
  return {};
41022
41270
  }
41023
- const raw = fs18.readFileSync(filePath, "utf8");
41271
+ const raw = fs19.readFileSync(filePath, "utf8");
41024
41272
  try {
41025
41273
  const normalized = normalizeJsonConfigContent(raw, options);
41026
41274
  const parsed = JSON.parse(normalized);
@@ -41040,25 +41288,25 @@ function asObject(value) {
41040
41288
  return {};
41041
41289
  }
41042
41290
  function writeConfigWithTapTapBackupIfChanged(filePath, nextContent, validate) {
41043
- const existed = fs18.existsSync(filePath);
41044
- const previousContent = existed ? fs18.readFileSync(filePath, "utf8") : void 0;
41291
+ const existed = fs19.existsSync(filePath);
41292
+ const previousContent = existed ? fs19.readFileSync(filePath, "utf8") : void 0;
41045
41293
  if (previousContent === nextContent) {
41046
41294
  return { changed: false };
41047
41295
  }
41048
41296
  const backupPath = existed ? `${filePath}.taptap-maker.bak.latest` : void 0;
41049
- fs18.mkdirSync(path19.dirname(filePath), { recursive: true });
41297
+ fs19.mkdirSync(path20.dirname(filePath), { recursive: true });
41050
41298
  if (previousContent !== void 0 && backupPath) {
41051
- fs18.writeFileSync(backupPath, previousContent, "utf8");
41299
+ fs19.writeFileSync(backupPath, previousContent, "utf8");
41052
41300
  }
41053
41301
  try {
41054
- fs18.writeFileSync(filePath, nextContent, "utf8");
41055
- validate == null ? void 0 : validate(fs18.readFileSync(filePath, "utf8"));
41302
+ fs19.writeFileSync(filePath, nextContent, "utf8");
41303
+ validate == null ? void 0 : validate(fs19.readFileSync(filePath, "utf8"));
41056
41304
  return { changed: true, backupPath };
41057
41305
  } catch (error2) {
41058
41306
  if (previousContent !== void 0) {
41059
- fs18.writeFileSync(filePath, previousContent, "utf8");
41307
+ fs19.writeFileSync(filePath, previousContent, "utf8");
41060
41308
  } else {
41061
- fs18.rmSync(filePath, { force: true });
41309
+ fs19.rmSync(filePath, { force: true });
41062
41310
  }
41063
41311
  throw error2;
41064
41312
  }
@@ -41205,10 +41453,10 @@ function formatMcpInstallMessage(label, configPath, write) {
41205
41453
  ].filter(Boolean).join("\n");
41206
41454
  }
41207
41455
  function saveInitState(targetDir, state) {
41208
- fs18.mkdirSync(getMakerHome(), { recursive: true });
41209
- const key = crypto3.createHash("sha256").update(path19.resolve(targetDir)).digest("hex").slice(0, 16);
41210
- fs18.writeFileSync(
41211
- path19.join(getMakerHome(), `init-state-${key}.json`),
41456
+ fs19.mkdirSync(getMakerHome(), { recursive: true });
41457
+ const key = crypto3.createHash("sha256").update(path20.resolve(targetDir)).digest("hex").slice(0, 16);
41458
+ fs19.writeFileSync(
41459
+ path20.join(getMakerHome(), `init-state-${key}.json`),
41212
41460
  `${JSON.stringify({ ...state, updated_at: (/* @__PURE__ */ new Date()).toISOString() }, null, 2)}
41213
41461
  `,
41214
41462
  "utf8"
@@ -41356,7 +41604,7 @@ function makerEnvOption(parsed) {
41356
41604
  return env;
41357
41605
  }
41358
41606
  const targetDir = stringOption(parsed, "target_dir");
41359
- return getMakerEnvironment(void 0, targetDir ? path19.resolve(targetDir) : process.cwd());
41607
+ return getMakerEnvironment(void 0, targetDir ? path20.resolve(targetDir) : process.cwd());
41360
41608
  }
41361
41609
  function mcpVerifyModeOption(parsed) {
41362
41610
  const mode = stringOption(parsed, "mode") || "npx";
@@ -41368,7 +41616,7 @@ function mcpVerifyModeOption(parsed) {
41368
41616
  function parseIdeList(value) {
41369
41617
  return value.split(/[\s,]+/).map((item) => item.trim().toLowerCase()).filter(Boolean);
41370
41618
  }
41371
- function uniqueStrings(values) {
41619
+ function uniqueStrings2(values) {
41372
41620
  return Array.from(new Set(values));
41373
41621
  }
41374
41622
  function mask(value) {
@@ -41432,16 +41680,15 @@ function printHelp() {
41432
41680
  " taptap-maker dev-kit update [--target-dir DIR] [--json]",
41433
41681
  " taptap-maker logs watch [--target-dir DIR] [--interval 5s] [--reset] [--json]",
41434
41682
  "",
41435
- "MCP verify defaults to the npx command written into AI client config.",
41436
- "Maker MCP configs and npx verification use @taptap/maker.",
41683
+ "MCP install and verify use the same validated @taptap/maker package launcher.",
41437
41684
  "",
41438
41685
  "MCP install defaults:",
41439
41686
  " Writes Codex, Cursor, Claude, detected Trae/OpenCode/WorkBuddy configs,",
41440
41687
  " unless --ide is specified. It does not create missing Trae config files.",
41441
41688
  "",
41442
41689
  "Windows note:",
41443
- " mcpServers configs wrap npx.cmd with cmd.exe on Windows for spawn compatibility.",
41444
- " OpenCode uses its own mcp schema and writes a command array with npx.cmd.",
41690
+ " MCP configs use an absolute node.exe + npm-cli.js launcher on Windows.",
41691
+ " Missing absolute Node/npm launchers fail without changing client configs.",
41445
41692
  ""
41446
41693
  ].join("\n")
41447
41694
  );
@@ -42858,7 +43105,7 @@ var StreamableHTTPClientTransport = class {
42858
43105
  };
42859
43106
 
42860
43107
  // src/mcp-proxy/proxy.ts
42861
- import * as path21 from "node:path";
43108
+ import * as path22 from "node:path";
42862
43109
  import * as crypto6 from "node:crypto";
42863
43110
 
42864
43111
  // src/mcp-proxy/cookieJar.ts
@@ -43040,8 +43287,8 @@ function createCookieFetch(cookieJar) {
43040
43287
  }
43041
43288
 
43042
43289
  // src/core/utils/logWriter.ts
43043
- import * as fs19 from "node:fs";
43044
- import * as path20 from "node:path";
43290
+ import * as fs20 from "node:fs";
43291
+ import * as path21 from "node:path";
43045
43292
  import * as crypto5 from "node:crypto";
43046
43293
 
43047
43294
  // src/core/types/log.ts
@@ -43082,7 +43329,7 @@ var LogWriter = class {
43082
43329
  return;
43083
43330
  }
43084
43331
  try {
43085
- await fs19.promises.mkdir(this.config.logDir, { recursive: true });
43332
+ await fs20.promises.mkdir(this.config.logDir, { recursive: true });
43086
43333
  await this.cleanupOldLogs();
43087
43334
  this.initialized = true;
43088
43335
  } catch (error2) {
@@ -43105,7 +43352,7 @@ var LogWriter = class {
43105
43352
  */
43106
43353
  getLogFilePath(date5) {
43107
43354
  const d = date5 || this.getCurrentDate();
43108
- return path20.join(this.config.logDir, `${this.config.prefix}-${d}.log`);
43355
+ return path21.join(this.config.logDir, `${this.config.prefix}-${d}.log`);
43109
43356
  }
43110
43357
  /**
43111
43358
  * 获取或创建写入流
@@ -43120,7 +43367,7 @@ var LogWriter = class {
43120
43367
  }
43121
43368
  this.currentDate = date5;
43122
43369
  try {
43123
- this.writeStream = fs19.createWriteStream(this.getLogFilePath(date5), {
43370
+ this.writeStream = fs20.createWriteStream(this.getLogFilePath(date5), {
43124
43371
  flags: "a",
43125
43372
  encoding: "utf8"
43126
43373
  });
@@ -43172,11 +43419,11 @@ var LogWriter = class {
43172
43419
  if (this.shouldWriteToFile(level) && this.initialized && this.config.enabled) {
43173
43420
  try {
43174
43421
  const filePath = this.getLogFilePath();
43175
- const dir = path20.dirname(filePath);
43176
- if (!fs19.existsSync(dir)) {
43177
- fs19.mkdirSync(dir, { recursive: true });
43422
+ const dir = path21.dirname(filePath);
43423
+ if (!fs20.existsSync(dir)) {
43424
+ fs20.mkdirSync(dir, { recursive: true });
43178
43425
  }
43179
- fs19.appendFileSync(filePath, message, "utf8");
43426
+ fs20.appendFileSync(filePath, message, "utf8");
43180
43427
  } catch {
43181
43428
  }
43182
43429
  }
@@ -43187,7 +43434,7 @@ var LogWriter = class {
43187
43434
  async cleanupOldLogs() {
43188
43435
  if (this.config.maxDays <= 0) return;
43189
43436
  try {
43190
- const files = await fs19.promises.readdir(this.config.logDir);
43437
+ const files = await fs20.promises.readdir(this.config.logDir);
43191
43438
  const cutoffDate = /* @__PURE__ */ new Date();
43192
43439
  cutoffDate.setDate(cutoffDate.getDate() - this.config.maxDays);
43193
43440
  const prefix = this.config.prefix;
@@ -43202,7 +43449,7 @@ var LogWriter = class {
43202
43449
  if (!Number.isNaN(year) && !Number.isNaN(month) && !Number.isNaN(day)) {
43203
43450
  const fileDate = new Date(year, month - 1, day);
43204
43451
  if (fileDate < cutoffDate) {
43205
- await fs19.promises.unlink(path20.join(this.config.logDir, file2));
43452
+ await fs20.promises.unlink(path21.join(this.config.logDir, file2));
43206
43453
  process.stderr.write(`[LogWriter] Deleted old log: ${file2}
43207
43454
  `);
43208
43455
  }
@@ -43323,10 +43570,10 @@ var TapTapMCPProxy = class {
43323
43570
  const { user_id, project_id } = this.config.tenant;
43324
43571
  let logDir;
43325
43572
  if (user_id && project_id) {
43326
- logDir = path21.join(logRoot, "proxy", user_id, project_id);
43573
+ logDir = path22.join(logRoot, "proxy", user_id, project_id);
43327
43574
  } else {
43328
43575
  const kidHash = crypto6.createHash("sha256").update(this.config.auth.kid).digest("hex").substring(0, 8);
43329
- logDir = path21.join(logRoot, "proxy", kidHash);
43576
+ logDir = path22.join(logRoot, "proxy", kidHash);
43330
43577
  }
43331
43578
  return new LogWriter({
43332
43579
  logDir,
@@ -44052,11 +44299,12 @@ function printHelp2() {
44052
44299
  " taptap-maker dev-kit update [--target-dir DIR] [--json]",
44053
44300
  " taptap-maker logs watch [--target-dir DIR] [--interval 5s] [--reset] [--json]",
44054
44301
  "",
44055
- "MCP verify defaults to the npx command written into AI client config.",
44056
- "Maker MCP configs and npx verification use @taptap/maker.",
44302
+ "MCP install verifies initialize + tools/list before writing AI client config.",
44303
+ "Maker MCP configs and launcher verification use @taptap/maker.",
44057
44304
  "",
44058
44305
  "Windows note:",
44059
- " Generated MCP configs wrap npx.cmd with cmd.exe on Windows for spawn compatibility.",
44306
+ " Generated MCP configs prefer absolute node.exe + npm-cli.js on Windows.",
44307
+ " Project cwd is always structured; the CLI never generates cd && npx commands.",
44060
44308
  ""
44061
44309
  ].join("\n")
44062
44310
  );