@taptap/maker 0.0.34-beta.6 → 0.0.34-beta.7

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
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  // TapTap Maker MCP - Standalone Bundle
3
- // TapTap Maker MCP version: 0.0.34-beta.6
3
+ // TapTap Maker MCP version: 0.0.34-beta.7
4
4
  import { createRequire } from 'node:module';
5
5
  const require = createRequire(import.meta.url);
6
6
  const __MAKER_BUNDLE_URL__ = import.meta.url;
@@ -30627,7 +30627,7 @@ function createMakerAgentsPolicyBody() {
30627
30627
  " `mcp report --ide <client> --target-dir <project> --context-stdin --consent --json`.",
30628
30628
  "- This preserves the configured package version and the absolute Windows node.exe/npm-cli.js.",
30629
30629
  "- Only with a known exact installed version, fallback to",
30630
- " `npx -y --package @taptap/maker@0.0.34-beta.6 taptap-maker mcp report ...`.",
30630
+ " `npx -y --package @taptap/maker@0.0.34-beta.7 taptap-maker mcp report ...`.",
30631
30631
  "- Never use an unversioned npm package, or assume `taptap-maker`/`npx` is globally available.",
30632
30632
  "- Never include the complete conversation, project source, other MCP server entries, PAT/token",
30633
30633
  " values, or full environment variables. Normalize the user home path to `~`.",
@@ -30738,16 +30738,33 @@ function syncProjectSkills(targetDir, options3) {
30738
30738
  const sourceSkills = fs6.readdirSync(sourceDir, { withFileTypes: true }).filter(
30739
30739
  (entry) => entry.isDirectory() && fs6.existsSync(path7.join(sourceDir, entry.name, "SKILL.md"))
30740
30740
  ).map((entry) => entry.name).sort();
30741
- for (const sourceSkillName of sourceSkills) {
30742
- const skillName = `${options3.prefix || ""}${sourceSkillName}`;
30743
- const skillDir = path7.join(skillsDir, skillName);
30744
- if (pathEntryExists(skillDir)) {
30745
- result.skippedSkills.push(skillName);
30746
- continue;
30741
+ const installedSkillDirs = [];
30742
+ try {
30743
+ for (const sourceSkillName of sourceSkills) {
30744
+ const skillName = `${options3.prefix || ""}${sourceSkillName}`;
30745
+ const skillDir = path7.join(skillsDir, skillName);
30746
+ if (pathEntryExists(skillDir)) {
30747
+ result.skippedSkills.push(skillName);
30748
+ continue;
30749
+ }
30750
+ fs6.mkdirSync(skillsDir, { recursive: true });
30751
+ installSkillContents(path7.join(sourceDir, sourceSkillName), skillDir, platform);
30752
+ installedSkillDirs.push(skillDir);
30753
+ result.installedSkills.push(skillName);
30754
+ }
30755
+ } catch (error2) {
30756
+ const cleanupErrors = [];
30757
+ for (const skillDir of installedSkillDirs.reverse()) {
30758
+ try {
30759
+ fs6.rmSync(skillDir, { recursive: true, force: true });
30760
+ } catch (cleanupError) {
30761
+ cleanupErrors.push(cleanupError);
30762
+ }
30763
+ }
30764
+ if (cleanupErrors.length > 0) {
30765
+ throwWithCleanupFailures(error2, cleanupErrors);
30747
30766
  }
30748
- fs6.mkdirSync(skillsDir, { recursive: true });
30749
- installSkillContents(path7.join(sourceDir, sourceSkillName), skillDir, platform);
30750
- result.installedSkills.push(skillName);
30767
+ throw error2;
30751
30768
  }
30752
30769
  if (result.installedSkills.length > 0) {
30753
30770
  result.status = "installed";
@@ -30761,7 +30778,11 @@ function installSkillContents(sourceDir, targetDir, platform) {
30761
30778
  linkOrCopyEntry(path7.join(sourceDir, entry), path7.join(targetDir, entry), platform);
30762
30779
  }
30763
30780
  } catch (error2) {
30764
- fs6.rmSync(targetDir, { recursive: true, force: true });
30781
+ try {
30782
+ fs6.rmSync(targetDir, { recursive: true, force: true });
30783
+ } catch (cleanupError) {
30784
+ throwWithCleanupFailures(error2, [cleanupError]);
30785
+ }
30765
30786
  throw error2;
30766
30787
  }
30767
30788
  }
@@ -30803,6 +30824,14 @@ function pathEntryExists(value) {
30803
30824
  function formatError2(error2) {
30804
30825
  return error2 instanceof Error ? error2.message : String(error2);
30805
30826
  }
30827
+ function throwWithCleanupFailures(primaryError, cleanupErrors) {
30828
+ const details = cleanupErrors.map(formatError2).join("; ");
30829
+ if (primaryError instanceof Error) {
30830
+ primaryError.message = `${primaryError.message}; cleanup failures: ${details}`;
30831
+ throw primaryError;
30832
+ }
30833
+ throw new Error(`Primary failure: ${formatError2(primaryError)}; cleanup failures: ${details}`);
30834
+ }
30806
30835
  var init_projectSkills = __esm({
30807
30836
  "src/maker/cli/projectSkills.ts"() {
30808
30837
  "use strict";
@@ -31129,11 +31158,25 @@ function readManagedGitignoreEntries(gitignorePath) {
31129
31158
  return entries;
31130
31159
  }
31131
31160
  function installAiDevKitSkills(targetDir, options3 = {}) {
31161
+ let result;
31132
31162
  try {
31133
- return runAiDevKitSkillScript(targetDir, options3);
31134
- } finally {
31135
- syncProjectSkills(targetDir, { client: ".agents" });
31163
+ result = runAiDevKitSkillScript(targetDir, options3);
31164
+ } catch (error2) {
31165
+ try {
31166
+ syncProjectSkills(targetDir, { client: ".agents" });
31167
+ } catch (syncError) {
31168
+ if (error2 instanceof Error) {
31169
+ error2.message = `${error2.message}; .agents synchronization failed: ${formatError3(syncError)}`;
31170
+ throw error2;
31171
+ }
31172
+ throw new Error(
31173
+ `AI dev kit skill installer failed: ${formatError3(error2)}; .agents synchronization failed: ${formatError3(syncError)}`
31174
+ );
31175
+ }
31176
+ throw error2;
31136
31177
  }
31178
+ syncProjectSkills(targetDir, { client: ".agents" });
31179
+ return result;
31137
31180
  }
31138
31181
  function runAiDevKitSkillScript(targetDir, options3) {
31139
31182
  var _a3;
@@ -31312,6 +31355,9 @@ function formatSpawnFailure(result) {
31312
31355
  var _a3;
31313
31356
  return ((_a3 = result.error) == null ? void 0 : _a3.message) || String(result.stderr || "").trim() || String(result.stdout || "").trim() || `exit status ${result.status ?? "unknown"}`;
31314
31357
  }
31358
+ function formatError3(error2) {
31359
+ return error2 instanceof Error ? error2.message : String(error2);
31360
+ }
31315
31361
  function formatDevKitSkillInstallerFailure(options3) {
31316
31362
  return [
31317
31363
  "Failed to install AI dev kit skills",
@@ -32461,12 +32507,14 @@ async function withQrcodeFastForward(cwd, remoteRef, fastForward) {
32461
32507
  const remote = git2(["rev-parse", remoteRef]).trim();
32462
32508
  let baseEntry, remoteEntry, localText;
32463
32509
  try {
32464
- const baseTree = git2(["ls-tree", head, "--", file2]);
32465
- const remoteTree = git2(["ls-tree", remote, "--", file2]);
32466
- if (!/^100644 blob [a-f0-9]+\t/.test(baseTree) || !/^100644 blob [a-f0-9]+\t/.test(remoteTree))
32467
- return await fastForward(remote);
32468
- baseEntry = baseTree.replace(" blob ", " ").replace(" ", " 0 ");
32469
- remoteEntry = remoteTree.replace(" blob ", " ").replace(" ", " 0 ");
32510
+ const treeEntry = /^100644 blob ([a-f0-9]+)\t\.project\/project\.json\n$/;
32511
+ const baseTree = treeEntry.exec(git2(["ls-tree", head, "--", file2]));
32512
+ const remoteTree = treeEntry.exec(git2(["ls-tree", remote, "--", file2]));
32513
+ if (!baseTree || !remoteTree) return await fastForward(remote);
32514
+ baseEntry = `100644 ${baseTree[1]} 0 ${file2}
32515
+ `;
32516
+ remoteEntry = `100644 ${remoteTree[1]} 0 ${file2}
32517
+ `;
32470
32518
  if (baseEntry === remoteEntry || git2(["ls-files", "--stage", "--", file2]) !== baseEntry)
32471
32519
  return await fastForward(remote);
32472
32520
  const filename2 = path13.join(cwd, file2);
@@ -39355,7 +39403,7 @@ var init_tracking = __esm({
39355
39403
  MAKER_MCP_TRACKING_ACTION = "tapmaker_mcp_call";
39356
39404
  MAKER_MCP_TRACKING_SOURCE = "local_mcp";
39357
39405
  MAKER_MCP_TRACKING_TIMEOUT_MS = 1500;
39358
- MAKER_MCP_VERSION = "0.0.34-beta.6".trim() ? "0.0.34-beta.6".trim() : "dev";
39406
+ MAKER_MCP_VERSION = "0.0.34-beta.7".trim() ? "0.0.34-beta.7".trim() : "dev";
39359
39407
  TRACKING_ERROR_MAX_LENGTH = 500;
39360
39408
  }
39361
39409
  });
@@ -42667,7 +42715,7 @@ var init_mcp = __esm({
42667
42715
  init_remoteProxyManager();
42668
42716
  init_proxyAssets();
42669
42717
  init_diagnosticRedaction();
42670
- VERSION = true ? "0.0.34-beta.6" : "dev";
42718
+ VERSION = true ? "0.0.34-beta.7" : "dev";
42671
42719
  DEFAULT_BUILD_TIMEOUT_MS = 10 * 60 * 1e3;
42672
42720
  DEFAULT_PROXY_RETRY_ATTEMPTS = 5;
42673
42721
  DEFAULT_PROXY_RETRY_DELAY_MS = 30 * 1e3;
@@ -42877,6 +42925,74 @@ var init_mcp = __esm({
42877
42925
  // src/maker/preview/configuration.ts
42878
42926
  import fs22 from "node:fs";
42879
42927
  import path23 from "node:path";
42928
+ function hasStandardPreviewConfiguration(project) {
42929
+ return STANDARD_PREVIEW_CONFIGS.every(
42930
+ (name) => fs22.existsSync(path23.join(project, ".project", name + ".json"))
42931
+ );
42932
+ }
42933
+ function configuredServerEntry(root2, project, resources2) {
42934
+ const entry = project["entry@server"] ?? resources2["entry@server"];
42935
+ if (entry === void 0) return void 0;
42936
+ if (typeof entry !== "string" || !entry.trim() || path23.isAbsolute(entry) || path23.win32.isAbsolute(entry) || /^[A-Za-z]:/.test(entry))
42937
+ throw new Error("预览配置中的 entry@server 必须是相对路径。");
42938
+ const normalized = path23.posix.normalize(entry.replaceAll("\\", "/"));
42939
+ if (normalized === "." || normalized.startsWith("../") || normalized.includes("/../"))
42940
+ throw new Error("预览配置中的 entry@server 不能逃逸 scripts 目录。");
42941
+ const scripts = fs22.realpathSync(path23.join(root2, "scripts"));
42942
+ const candidate = path23.join(scripts, normalized);
42943
+ const resolved = fs22.realpathSync(candidate);
42944
+ const relative = path23.relative(scripts, resolved);
42945
+ if (!fs22.statSync(resolved).isFile() || relative.startsWith("..") || path23.isAbsolute(relative))
42946
+ throw new Error(`预览配置中的 entry@server 不存在: ${entry}`);
42947
+ return normalized;
42948
+ }
42949
+ function detectedServerEntry(project) {
42950
+ return ["server_main.lua", "server.lua"].find(
42951
+ (name) => fs22.existsSync(path23.join(project, "scripts", name))
42952
+ );
42953
+ }
42954
+ function networkEnabled(settings) {
42955
+ const runtime = settings["@runtime"];
42956
+ if (!runtime || typeof runtime !== "object") return false;
42957
+ const multiplayer = runtime.multiplayer;
42958
+ if (multiplayer && typeof multiplayer === "object") {
42959
+ if (multiplayer.enabled !== void 0) return Boolean(multiplayer.enabled);
42960
+ if (multiplayer.max_players !== void 0) return Number(multiplayer.max_players) > 0;
42961
+ return Boolean(
42962
+ multiplayer.persistent_world && typeof multiplayer.persistent_world === "object" && multiplayer.persistent_world.enabled
42963
+ );
42964
+ }
42965
+ return Number(runtime.max_players) > 0;
42966
+ }
42967
+ function hasResourceMetadata(directory) {
42968
+ if (!fs22.existsSync(directory)) return false;
42969
+ if (fs22.lstatSync(directory).isSymbolicLink()) return true;
42970
+ for (const item of fs22.readdirSync(directory, { withFileTypes: true })) {
42971
+ if (item.isSymbolicLink() || item.name.endsWith(".meta")) return true;
42972
+ if (item.isDirectory() && hasResourceMetadata(path23.join(directory, item.name))) return true;
42973
+ }
42974
+ return false;
42975
+ }
42976
+ function classifyPreviewProject(project, platform = process.platform) {
42977
+ const standard = hasStandardPreviewConfiguration(project);
42978
+ const projectConfig = readPreviewConfiguration(project, "project") || {};
42979
+ const resourcesConfig = readPreviewConfiguration(project, "resources") || {};
42980
+ const settingsConfig = readPreviewConfiguration(project, "settings") || {};
42981
+ const serverEntry = configuredServerEntry(project, projectConfig, resourcesConfig);
42982
+ const detectedEntry = detectedServerEntry(project);
42983
+ const hasServer = Boolean(serverEntry) || Boolean(detectedEntry);
42984
+ const network = networkEnabled(settingsConfig);
42985
+ const reason = !standard ? "missing_configuration" : network || hasServer ? "network_or_server" : platform === "win32" && fs22.existsSync(path23.join(project, "dist/latest.json")) ? "existing_windows_manifest" : Object.keys(resourcesConfig).some(
42986
+ (key) => !["$schema", "entry", "entry@client", "entry@server"].includes(key)
42987
+ ) || Object.keys(settingsConfig).some((key) => !["$schema", "@runtime"].includes(key)) || hasResourceMetadata(path23.join(project, "scripts")) || hasResourceMetadata(path23.join(project, "assets")) ? "resource_manifest" : void 0;
42988
+ return {
42989
+ kind: hasServer ? "server" : network ? "network" : !standard ? "new_project" : "single_player",
42990
+ network_required: network || hasServer,
42991
+ preparation_required: Boolean(reason),
42992
+ ...reason ? { preparation_reason: reason } : {},
42993
+ ...serverEntry || detectedEntry ? { server_entry: serverEntry || detectedEntry } : {}
42994
+ };
42995
+ }
42880
42996
  function readPreviewConfiguration(project, name) {
42881
42997
  const filename2 = path23.join(project, ".project", name + ".json");
42882
42998
  if (!fs22.existsSync(filename2)) {
@@ -42911,9 +43027,11 @@ function previewEntryName(project = {}, resources2 = {}) {
42911
43027
  }
42912
43028
  return "main.lua";
42913
43029
  }
43030
+ var STANDARD_PREVIEW_CONFIGS;
42914
43031
  var init_configuration = __esm({
42915
43032
  "src/maker/preview/configuration.ts"() {
42916
43033
  "use strict";
43034
+ STANDARD_PREVIEW_CONFIGS = ["project", "resources", "settings"];
42917
43035
  }
42918
43036
  });
42919
43037
 
@@ -45245,7 +45363,7 @@ var require_websocket = __commonJS({
45245
45363
  var http4 = __require("http");
45246
45364
  var net = __require("net");
45247
45365
  var tls = __require("tls");
45248
- var { randomBytes: randomBytes4, createHash: createHash11 } = __require("crypto");
45366
+ var { randomBytes: randomBytes4, createHash: createHash12 } = __require("crypto");
45249
45367
  var { Duplex, Readable: Readable2 } = __require("stream");
45250
45368
  var { URL: URL2 } = __require("url");
45251
45369
  var PerMessageDeflate2 = require_permessage_deflate();
@@ -45913,7 +46031,7 @@ var require_websocket = __commonJS({
45913
46031
  abortHandshake(websocket, socket, "Invalid Upgrade header");
45914
46032
  return;
45915
46033
  }
45916
- const digest = createHash11("sha1").update(key + GUID).digest("base64");
46034
+ const digest = createHash12("sha1").update(key + GUID).digest("base64");
45917
46035
  if (res.headers["sec-websocket-accept"] !== digest) {
45918
46036
  abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
45919
46037
  return;
@@ -46282,7 +46400,7 @@ var require_websocket_server = __commonJS({
46282
46400
  var EventEmitter = __require("events");
46283
46401
  var http4 = __require("http");
46284
46402
  var { Duplex } = __require("stream");
46285
- var { createHash: createHash11 } = __require("crypto");
46403
+ var { createHash: createHash12 } = __require("crypto");
46286
46404
  var extension2 = require_extension();
46287
46405
  var PerMessageDeflate2 = require_permessage_deflate();
46288
46406
  var subprotocol2 = require_subprotocol();
@@ -46589,7 +46707,7 @@ var require_websocket_server = __commonJS({
46589
46707
  );
46590
46708
  }
46591
46709
  if (this._state > RUNNING) return abortHandshake(socket, 503);
46592
- const digest = createHash11("sha1").update(key + GUID).digest("base64");
46710
+ const digest = createHash12("sha1").update(key + GUID).digest("base64");
46593
46711
  const headers = [
46594
46712
  "HTTP/1.1 101 Switching Protocols",
46595
46713
  "Upgrade: websocket",
@@ -54273,7 +54391,7 @@ var consoleIconLicense, consoleIcons;
54273
54391
  var init_webIcons = __esm({
54274
54392
  "src/maker/console/webIcons.ts"() {
54275
54393
  "use strict";
54276
- consoleIconLicense = `Lucide icon-node snapshot: lucide-vue-next v1.0.0
54394
+ consoleIconLicense = `Lucide icon-node snapshot: lucide-vue-next v1.0.0; copy/link: lucide v0.468.0
54277
54395
  ISC License
54278
54396
  Copyright (c) for portions of Lucide are held by Cole Bemis 2013-2026 as part
54279
54397
  of Feather (MIT). All other copyright (c) for Lucide are held by Lucide Contributors 2026.
@@ -54306,6 +54424,14 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
54306
54424
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
54307
54425
  SOFTWARE.`;
54308
54426
  consoleIcons = {
54427
+ copy: [
54428
+ ["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2" }],
54429
+ ["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" }]
54430
+ ],
54431
+ link: [
54432
+ ["path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }],
54433
+ ["path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" }]
54434
+ ],
54309
54435
  qrcode: [
54310
54436
  ["rect", { width: "5", height: "5", x: "3", y: "3", rx: "1" }],
54311
54437
  ["rect", { width: "5", height: "5", x: "16", y: "3", rx: "1" }],
@@ -54462,6 +54588,12 @@ function bindFortuneHover(element) {
54462
54588
  }
54463
54589
  let documentTab = 'docs', documentSearch = '', documentItems = [], documentSelected = '';
54464
54590
  let documentRequest = 0, documentDirectoryRequest = 0;
54591
+ function markdownText(value) {
54592
+ // Decode only entity-shaped fragments; all resulting content still uses textContent.
54593
+ return String(value || '').replace(/&(?:#[0-9]+|#x[0-9a-f]+|[a-z][a-z0-9]+);/gi, entity => {
54594
+ return new DOMParser().parseFromString('<body>' + entity + '</body>','text/html').body.textContent;
54595
+ });
54596
+ }
54465
54597
  function markdownNodes(tokens) {
54466
54598
  const fragment = document.createDocumentFragment();
54467
54599
  for (const token of tokens || []) {
@@ -54471,10 +54603,10 @@ function markdownNodes(tokens) {
54471
54603
  if (token.type === 'heading') { element = node('h' + Math.min(6,Math.max(1,token.depth))); element.append(children()); }
54472
54604
  else if (token.type === 'paragraph' || token.type === 'text') {
54473
54605
  element = node(token.type === 'paragraph' ? 'p' : 'span');
54474
- if (token.tokens) element.append(children()); else element.textContent = token.text || '';
54606
+ if (token.tokens) element.append(children()); else element.textContent = markdownText(token.text);
54475
54607
  } else if (['strong','em','del'].includes(token.type)) { element = node(token.type); element.append(children()); }
54476
54608
  else if (token.type === 'code') { element = node('pre'); element.append(node('code',token.text)); }
54477
- else if (token.type === 'codespan') element = node('code',token.text);
54609
+ else if (token.type === 'codespan') element = node('code',markdownText(token.text));
54478
54610
  else if (token.type === 'blockquote') { element = node('blockquote'); element.append(children()); }
54479
54611
  else if (token.type === 'br' || token.type === 'hr') element = node(token.type);
54480
54612
  else if (token.type === 'list') {
@@ -54511,8 +54643,8 @@ function markdownNodes(tokens) {
54511
54643
  else announce('该链接不在当前文档目录中');
54512
54644
  });
54513
54645
  }
54514
- } else if (token.type === 'image') element = node('span','[图片:' + (token.text || token.href || '') + ']','muted');
54515
- else element = node('span',token.text || token.raw || '');
54646
+ } else if (token.type === 'image') element = node('span','[图片:' + markdownText(token.text || token.href) + ']','muted');
54647
+ else element = node('span',token.type === 'escape' ? markdownText(token.text) : token.text || token.raw || '');
54516
54648
  fragment.append(element);
54517
54649
  }
54518
54650
  return fragment;
@@ -54543,7 +54675,7 @@ async function openDocument(item) {
54543
54675
  header.append(fallback); fallback.focus(); fallback.select();
54544
54676
  notify('无法访问剪贴板,请复制已选中的文档链接');
54545
54677
  }
54546
- }));
54678
+ },{icon:'link'}));
54547
54679
  replace(reader,[header,node('p',item.source + ' · ' + item.relativePath,'muted')]);
54548
54680
  if (item.purpose) {
54549
54681
  const intro = node('section',undefined,'document-intro');
@@ -54593,7 +54725,7 @@ async function renderDocuments() {
54593
54725
  const epoch = viewEpoch;
54594
54726
  const request = ++documentDirectoryRequest;
54595
54727
  const toolbar = node('div',undefined,'document-toolbar');
54596
- const tabs = node('div',undefined,'actions'); tabs.setAttribute('role','tablist');
54728
+ const tabs = node('div',undefined,'actions document-tabs'); tabs.setAttribute('role','tablist');
54597
54729
  [['docs','开发文档'],['project','项目文档'],['skills','Skill']].forEach(([kind,label]) => {
54598
54730
  const tab = button(label,() => {
54599
54731
  documentTab = kind; renderDocumentDirectory();
@@ -54606,7 +54738,7 @@ async function renderDocuments() {
54606
54738
  const search = node('input'); search.id = 'document-search'; search.type = 'search'; search.placeholder = '搜索标题、用途或目录';
54607
54739
  search.setAttribute('aria-label','搜索文档与 Skill'); search.value = documentSearch;
54608
54740
  search.addEventListener('input',() => { documentSearch = search.value; renderDocumentDirectory(); });
54609
- toolbar.append(tabs,search,button('刷新目录',() => void renderDocuments()));
54741
+ toolbar.append(tabs,search,button('刷新目录',() => void renderDocuments(),{icon:'refresh',iconOnly:true,className:'icon-button'}));
54610
54742
  const layout = node('div',undefined,'document-layout');
54611
54743
  const directory = node('aside'); directory.id = 'document-directory'; directory.setAttribute('aria-label','文档目录');
54612
54744
  const reader = node('article'); reader.id = 'document-reader';
@@ -54746,7 +54878,7 @@ function renderConsoleLogs() {
54746
54878
  if (!host) return;
54747
54879
  const view = logView();
54748
54880
  const toolbar = node('div',undefined,'console-log-toolbar');
54749
- const tabs = node('div',undefined,'actions');
54881
+ const tabs = node('div',undefined,'console-log-tabs');
54750
54882
  tabs.setAttribute('role','tablist');
54751
54883
  [['build','构建日志'],['lua','Lua 检查'],['runtime','Runtime 日志'],['qrcode','二维码']].forEach(([id,label]) => {
54752
54884
  const tab = button(label,() => { view.tab = id; renderConsoleLogs(); if (id === 'runtime' && !view.runtime && !view.loading) void loadLogs(); });
@@ -54766,7 +54898,7 @@ function renderConsoleLogs() {
54766
54898
  output.id = 'console-log-output'; output.setAttribute('role','tabpanel'); output.tabIndex = 0;
54767
54899
  const previous = $('console-log-output');
54768
54900
  const top = previous?.scrollTop || 0, left = previous?.scrollLeft || 0;
54769
- replace(host,[node('h2','日志'),toolbar,output]);
54901
+ replace(host,[toolbar,tabs,output]);
54770
54902
  output.scrollTop = top; output.scrollLeft = left;
54771
54903
  }
54772
54904
  let git = null;
@@ -54789,10 +54921,48 @@ const pending = new Set();
54789
54921
  const pendingActions = new Map();
54790
54922
  const pluginSessions = new Map();
54791
54923
  const acceptedTasks = new Map();
54924
+ const pendingReports = new Map();
54925
+ const offeredReports = new Set();
54926
+ function offerIssueReport(task) {
54927
+ if (!task.reportOffer || task.report || offeredReports.has(task.reportOffer.fingerprint)) return;
54928
+ pendingReports.set(task.id,task);
54929
+ if (pendingReports.size > 100) pendingReports.delete(pendingReports.keys().next().value);
54930
+ }
54931
+ function showPendingIssueReport() {
54932
+ if (offline || disposed || consoleDialogOpen()) return;
54933
+ const task = Array.from(pendingReports.values()).find(item => item.projectKey === selected);
54934
+ if (!task) return;
54935
+ pendingReports.delete(task.id);
54936
+ if (offeredReports.has(task.reportOffer.fingerprint)) return;
54937
+ offeredReports.add(task.reportOffer.fingerprint);
54938
+ const dialog = $('confirm');
54939
+ $('confirm-title').textContent = '提交问题反馈?';
54940
+ $('confirm-message').textContent = (task.action.startsWith('preview.') ? '本地预览遇到异常。' : '操作遇到异常。') +
54941
+ '是否提交问题反馈,帮助我们定位修复?将附带脱敏后的错误、日志和环境信息。';
54942
+ $('confirm-accept').textContent = '确认提交';
54943
+ dialog.returnValue = 'cancel';
54944
+ dialog.addEventListener('close',async () => {
54945
+ if (dialog.returnValue !== 'accept') return;
54946
+ try {
54947
+ const updated = await api('/api/tasks/' + encodeURIComponent(task.id) + '/report',{
54948
+ method:'POST',body:{consent:true}
54949
+ });
54950
+ rememberTask(updated);
54951
+ const index = state.tasks.findIndex(item => item.id === updated.id);
54952
+ if (index >= 0) state.tasks[index] = updated;
54953
+ if (updated.projectKey === selected) { updateChrome(); updateBuild(); notify('正在提交问题反馈…','info'); }
54954
+ } catch (error) { notify('问题反馈未提交:' + error.message); }
54955
+ },{once:true});
54956
+ dialog.showModal();
54957
+ }
54792
54958
  const windowDrafts = new Map();
54793
54959
  function rememberTask(task) {
54794
54960
  const previous = acceptedTasks.get(task.id);
54795
54961
  acceptedTasks.set(task.id,task);
54962
+ if (previous?.report?.status === 'running' && task.report?.status !== 'running' && task.projectKey === selected)
54963
+ notify(task.report?.status === 'created' ? '问题反馈已提交,谢谢。' :
54964
+ task.report?.status === 'unknown' ? '反馈提交结果未知,请勿重复提交。' :
54965
+ '反馈未能自动提交,请检查 GitHub CLI 登录状态及网络。',task.report?.status === 'created' ? 'success' : 'error');
54796
54966
  const projectTasks = Array.from(acceptedTasks.values()).reverse()
54797
54967
  .filter(item => item.projectKey === task.projectKey)
54798
54968
  .sort((a,b) => String(b.startedAt).localeCompare(String(a.startedAt)));
@@ -54918,7 +55088,7 @@ function tasksFor(key) {
54918
55088
  acceptedTasks.forEach(t => { if (t.projectKey === key && !tasks.has(t.id)) tasks.set(t.id, t); });
54919
55089
  return Array.from(tasks.values()).sort((a,b) => String(b.startedAt).localeCompare(String(a.startedAt))).slice(0,10);
54920
55090
  }
54921
- function busy(key = selected) { return pending.has(key) || tasksFor(key).some(t => t.status === 'running'); }
55091
+ function busy(key = selected) { return pending.has(key) || tasksFor(key).some(t => t.status === 'running' || t.report?.status === 'running'); }
54922
55092
  function actionBusy(action, key = selected) {
54923
55093
  return pendingActions.get(key) === action ||
54924
55094
  tasksFor(key).some(task => task.action === action && task.status === 'running');
@@ -54985,7 +55155,8 @@ function updateChrome() {
54985
55155
  }
54986
55156
  picker.value = currentProject() ? selected : '';
54987
55157
  picker.disabled = !loaded || offline;
54988
- $('context').textContent = currentProject() ? currentProject().name + ' / ' + text(detail?.git?.branch, '分支未提供') : '本地项目';
55158
+ $('context').textContent = currentProject() ? text(detail?.git?.branch, '分支未提供') : '本地项目';
55159
+ $('context').title = currentProject()?.name || '本地项目';
54989
55160
  $('footer-path').textContent = currentProject()?.path || '';
54990
55161
  document.querySelectorAll('nav [data-page]').forEach(b => {
54991
55162
  b.disabled = !loaded || (b.dataset.page !== 'documents' && !currentProject()?.valid);
@@ -54994,9 +55165,7 @@ function updateChrome() {
54994
55165
  });
54995
55166
  if ($('heading-actions')) replace($('heading-actions'),headingActionButtons());
54996
55167
  if ($('overview-task')) {
54997
- const latest = tasksFor(selected)[0];
54998
- replace($('overview-task'),[node('h2','最近任务'),
54999
- latest ? taskBlock(latest) : node('p','暂无控制台任务','muted')]);
55168
+ replace($('overview-task'),overviewTasks());
55000
55169
  }
55001
55170
  }
55002
55171
  function headingActionButtons() {
@@ -55017,17 +55186,14 @@ function headingActionButtons() {
55017
55186
  const presentation = buildPresentation(task,pendingActions.get(selected) === 'build',offline);
55018
55187
  const build = button(checking ? 'Lua 检查中' : presentation.active ? presentation.label : '构建',
55019
55188
  () => void runProjectAction('build'),
55020
- {className:'primary build-button' + (presentation.active || checking ? ' is-building' : ''),
55189
+ {className:'build-button' + (presentation.active || checking ? ' is-building' : ''),
55021
55190
  icon:presentation.active || checking ? 'refresh' : 'hammer',disabled:offline || busy(),focus:'heading-build'});
55022
55191
  build.setAttribute('aria-busy',String(presentation.active || checking));
55023
55192
  const primary = node('div',undefined,'actions heading-primary');
55024
55193
  primary.append(local,build,button('测试二维码',() => void runProjectAction('qrcode'),{
55025
55194
  icon:'qrcode',loading:qrcodeBusy,disabled:offline || busy(),focus:'heading-qrcode'
55026
55195
  }));
55027
- const secondary = node('div',undefined,'actions heading-secondary');
55028
- secondary.append(luaCheckOption());
55029
- if (!presentation.active && task) secondary.append(node('span',presentation.label,'build-badge ' + presentation.tone));
55030
- return [primary,secondary];
55196
+ return [primary];
55031
55197
  }
55032
55198
  function luaCheckOption() {
55033
55199
  const label = node('label',undefined,'lua-check-option');
@@ -55350,6 +55516,12 @@ async function removeProject(key) {
55350
55516
  } catch (error) { notify(error.message); }
55351
55517
  finally { pending.delete(key); updateChrome(); if (page === 'projects') renderProjects(); }
55352
55518
  }
55519
+ function overviewTasks() {
55520
+ const tasks = tasksFor(selected);
55521
+ const title = node('div',undefined,'section-heading');
55522
+ title.append(node('h2','最近任务'),node('span','保留最近 10 次','muted'));
55523
+ return [title,...(tasks.length ? tasks.map(task => taskBlock(task)) : [node('p','暂无控制台任务','muted')])];
55524
+ }
55353
55525
  function renderOverview() {
55354
55526
  const p = currentProject();
55355
55527
  const title = heading(p.name,p.path,true);
@@ -55361,7 +55533,8 @@ function renderOverview() {
55361
55533
  [['项目版本',config.version],['屏幕方向',orientation],['Git HEAD',detail.git?.head?.slice(0,10)],
55362
55534
  ['本地预览',previewLabel()]].forEach(([name,value]) => {
55363
55535
  const metric = node('div',undefined,'metric');
55364
- metric.append(node('div',name,'muted'),node('div',text(value),'value')); metrics.append(metric);
55536
+ metric.append(node('div',name,'muted'),node('div',text(value),'value' +
55537
+ (name === '本地预览' ? ' ' + previewPresentation(preview,previewError).tone : ''))); metrics.append(metric);
55365
55538
  });
55366
55539
  const runtime = runtimePresentation(preview,previewError);
55367
55540
  const runtimeMetric = node('div',undefined,'metric runtime-metric');
@@ -55407,13 +55580,9 @@ function renderOverview() {
55407
55580
  if (latestBuild?.status === 'failed') {
55408
55581
  health.append(failureBanner('最近构建失败', buildFailureDetails(latestBuild) || buildFailureTitle(latestBuild)));
55409
55582
  }
55410
- const links = node('div',undefined,'actions preview-controls');
55411
- links.append(button('构建与测试',() => navigate('build')),button('查看 Git',() => navigate('git')));
55412
- health.append(links);
55413
55583
  columns.append(configSection,health);
55414
55584
  const recent = node('section',undefined,'task-history'); recent.id = 'overview-task';
55415
- const latest = tasksFor(selected)[0];
55416
- recent.append(node('h2','最近任务'),latest ? taskBlock(latest) : node('p','暂无控制台任务','muted'));
55585
+ recent.append(...overviewTasks());
55417
55586
  const serviceActions = node('div',undefined,'console-service-actions');
55418
55587
  serviceActions.append(button('关闭Maker控制台',() => void shutdownConsole(),{
55419
55588
  className:'console-shutdown',disabled:offline || shutdownPending,focus:'console-shutdown'
@@ -55628,8 +55797,9 @@ function runtimePresentation(status, error = '') {
55628
55797
  }
55629
55798
  return {label:'待检测',detail:'',tone:'muted'};
55630
55799
  }
55631
- function taskStartsOpen(task, open = false) {
55632
- return Boolean(open || task?.action === 'qrcode' || (task?.status === 'failed' && task?.action !== 'lua-lsp.check'));
55800
+ function taskStartsOpen(task, open = false, latest = true) {
55801
+ return Boolean(open || task?.status === 'running' || (latest &&
55802
+ (task?.status === 'unknown' || (task?.status === 'failed' && task?.action !== 'lua-lsp.check'))));
55633
55803
  }
55634
55804
  function taskOutputText(task) {
55635
55805
  const output = text(task?.output,'').trim();
@@ -55645,8 +55815,10 @@ function taskOutputText(task) {
55645
55815
  }
55646
55816
  function taskBlock(task, open = false) {
55647
55817
  const failed = task.status === 'failed';
55818
+ const item = node('article',undefined,'task-item');
55819
+ const shortcuts = node('div',undefined,'actions task-shortcuts');
55648
55820
  const d = node('details',undefined,'task' + (failed ? ' is-failed' : '')); d.dataset.key = task.id;
55649
- d.open = taskStartsOpen(task,open);
55821
+ d.open = taskStartsOpen(task,open,tasksFor(task.projectKey)[0]?.id === task.id);
55650
55822
  const summary = node('summary');
55651
55823
  summary.dataset.focus = 'task-' + task.id;
55652
55824
  summary.append(node('strong', actionLabels[task.action] || task.action),
@@ -55655,9 +55827,19 @@ function taskBlock(task, open = false) {
55655
55827
  node('time',date(task.startedAt)));
55656
55828
  const meta = node('p','项目:' + text(task.projectName) + ' · 任务:' + text(task.id),'task-meta muted');
55657
55829
  d.append(summary,meta);
55830
+ if (task.report) {
55831
+ const labels = {running:'正在提交问题反馈…',created:'问题反馈已提交',unavailable:'反馈未能自动提交,请检查 GitHub CLI 登录状态及网络。',unknown:'反馈提交结果未知,请勿重复提交。'};
55832
+ shortcuts.append(node('span',labels[task.report.status] || '反馈状态未知','muted'));
55833
+ if (task.report.status === 'running') shortcuts.append(node('span',undefined,'loading-spinner'));
55834
+ if (task.report.status === 'created' && /^https:\/\/github\.com\/taptap\/instant-games-open-mcp\/issues\/\d+$/.test(task.report.issue_url || '')) {
55835
+ const link = node('a','查看反馈','preview-link');
55836
+ link.href = task.report.issue_url; link.target = '_blank'; link.rel = 'noopener noreferrer';
55837
+ shortcuts.append(link);
55838
+ }
55839
+ }
55658
55840
  if (task.interaction?.kind === 'select_developer' && task.projectKey === selected &&
55659
55841
  tasksFor(task.projectKey).find(item => item.action === 'qrcode')?.id === task.id) {
55660
- d.append(button('选择开发者并继续',() => void runAction('qrcode',{sourceTaskId:task.id}),{
55842
+ shortcuts.append(button('选择开发者并继续',() => void runAction('qrcode',{sourceTaskId:task.id}),{
55661
55843
  disabled:offline || busy(task.projectKey)
55662
55844
  }));
55663
55845
  }
@@ -55675,11 +55857,11 @@ function taskBlock(task, open = false) {
55675
55857
  const link = node('a','打开 Web 预览','preview-link');
55676
55858
  link.href = previewUrl; link.target = '_blank'; link.rel = 'noopener noreferrer';
55677
55859
  link.referrerPolicy = 'no-referrer';
55678
- d.append(link);
55860
+ shortcuts.append(link);
55679
55861
  }
55680
55862
  if (task.action === 'qrcode' && task.status === 'succeeded') {
55681
55863
  const source = qrcodeImageSource(task);
55682
- if (source) d.append(button('查看二维码',() => showQrcode(task),{icon:'qrcode',disabled:task.projectKey !== selected}));
55864
+ if (source) shortcuts.append(button('查看二维码',() => showQrcode(task),{icon:'qrcode',disabled:task.projectKey !== selected}));
55683
55865
  const content = task.result?.result?.content;
55684
55866
  for (const item of Array.isArray(content) ? content : []) {
55685
55867
  if (item.type === 'image' && ['image/png','image/jpeg','image/webp'].includes(item.mimeType) &&
@@ -55707,7 +55889,8 @@ function taskBlock(task, open = false) {
55707
55889
  const result = node('details'); result.dataset.key = 'result-' + task.id;
55708
55890
  result.append(node('summary','完整结果'),node('pre',text(task.result))); d.append(result);
55709
55891
  }
55710
- return d;
55892
+ item.append(d,shortcuts);
55893
+ return item;
55711
55894
  }
55712
55895
  function windowDimensions(settings, info) {
55713
55896
  const orientation = settings.orientation === 'project' ? info.projectOrientation || 'landscape' : settings.orientation;
@@ -55723,8 +55906,16 @@ function renderWindowSettings() {
55723
55906
  draft = {settings:JSON.parse(JSON.stringify(info.settings)),dirty:false,saving:false};
55724
55907
  windowDrafts.set(key,draft);
55725
55908
  }
55909
+ const disclosure = node('details',undefined,'preview-window-disclosure');
55910
+ disclosure.dataset.key = 'preview-window-' + key;
55911
+ const summary = node('summary',undefined,'preview-window-summary');
55912
+ const effective = preview?.process_alive === true && preview?.preflight?.window || info.effective;
55913
+ summary.append(node('span',(effective.height > effective.width ? '竖屏' : '横屏') + ' · ' +
55914
+ effective.width + ' × ' + effective.height,'muted'),node('span','窗口设置'));
55915
+ if (draft.dirty) summary.append(node('span','未保存','pending'));
55916
+ else if (effective.width !== info.effective.width || effective.height !== info.effective.height)
55917
+ summary.append(node('span','已保存,刷新后生效','pending'));
55726
55918
  const form = node('form',undefined,'preview-window-settings');
55727
- form.append(node('h3','预览窗口设置','preview-window-title'));
55728
55919
  const disabled = offline || busy(key) || draft.saving;
55729
55920
  const selectField = (label, name, options, value, change) => {
55730
55921
  const wrap = node('label',label);
@@ -55787,11 +55978,12 @@ function renderWindowSettings() {
55787
55978
  } catch (error) { if (selectionMatches(key,epoch)) notify(error.message); }
55788
55979
  finally { draft.saving = false; if (selectionMatches(key,epoch)) updateBuild(); }
55789
55980
  });
55790
- return form;
55981
+ disclosure.append(summary,form);
55982
+ return disclosure;
55791
55983
  }
55792
55984
  function renderBuild() {
55793
- const title = heading('构建与测试',currentProject().path,true);
55794
- const columns = node('div',undefined,'columns');
55985
+ const title = heading('构建与测试',currentProject().name,true);
55986
+ const columns = node('div',undefined,'columns build-columns');
55795
55987
  const build = node('section'); build.id = 'build-panel';
55796
55988
  const local = node('section'); local.id = 'preview-panel';
55797
55989
  columns.append(build,local);
@@ -55809,16 +56001,20 @@ function updateBuild() {
55809
56001
  const checkTask = tasks.find(t => t.action === 'lua-lsp.check');
55810
56002
  const lua = luaLspPresentation(state.luaLsp);
55811
56003
  const checkBlock = node('div',undefined,'lua-check-panel');
55812
- checkBlock.append(node('p','Lua LSP · ' + lua.label + (lua.detail ? ' · ' + lua.detail : ''), lua.tone));
56004
+ const checkActions = node('div',undefined,'actions lua-check-actions');
56005
+ checkActions.append(luaCheckOption());
55813
56006
  if (checkTask) {
55814
56007
  const summary = luaCheckSummary(checkTask,checking);
55815
- checkBlock.append(button(summary,() => selectLog('lua'),{className:'link ' + (checkTask.status === 'failed' ? 'bad' : checkTask.status === 'succeeded' ? 'good' : 'pending')}));
55816
- } else checkBlock.append(node('p','尚未检查当前项目','muted'));
55817
- const checkActions = node('div',undefined,'actions preview-controls');
56008
+ checkActions.append(button(summary,() => selectLog('lua'),{className:'link ' + (checkTask.status === 'failed' ? 'bad' : checkTask.status === 'succeeded' ? 'good' : 'pending')}));
56009
+ }
55818
56010
  checkActions.append(button(checking ? '检查中' : 'Lua 检查',() => void runAction('lua-lsp.check'),{
55819
- disabled:offline || busy(),focus:'lua-lsp.check'
56011
+ className:'link',icon:'refresh',disabled:offline || busy(),focus:'lua-lsp.check'
55820
56012
  }));
55821
56013
  checkBlock.append(checkActions);
56014
+ const lspStatus = node('div',undefined,'lsp-status');
56015
+ lspStatus.append(node('span','Lua LSP · ' + lua.label + (lua.detail ? ' · ' + lua.detail : ''), lua.tone),
56016
+ button('检查日志',() => selectLog('lua'),{className:'link'}));
56017
+ checkBlock.append(lspStatus);
55822
56018
  const buildChildren = [node('h2','远端构建'),buildStatus,checkBlock];
55823
56019
  replace($('build-panel'),buildChildren);
55824
56020
  const previewInfo = previewPresentation(preview,previewError);
@@ -55828,13 +56024,10 @@ function updateBuild() {
55828
56024
  preview?.install_state === 'ready' ? 'good' : preview?.install_state === 'missing' ? 'pending' : 'muted'));
55829
56025
  summary.append(node('span',previewLoading ? '检测中…' : previewError ? '检测失败' : previewInfo.stateLabel,
55830
56026
  previewLoading ? 'pending' : previewInfo.tone));
55831
- if (previewInfo.errorCount) summary.append(node('span',previewInfo.errorCount + ' 条日志错误','bad'));
56027
+ if (previewInfo.errorCount) summary.append(button(previewInfo.errorCount + ' 条日志错误',
56028
+ () => void loadLogs(),{className:'link bad'}));
55832
56029
  const localChildren = [node('h2','本地预览'),summary];
55833
- localChildren.push(renderWindowSettings());
55834
56030
  if (previewInfo.error) localChildren.push(node('p',previewInfo.error,'bad'));
55835
- if (previewInfo.errorCount) localChildren.push(button(
55836
- 'Runtime 日志中有 ' + previewInfo.errorCount + ' 条错误 · 查看日志',
55837
- () => void loadLogs(),{className:'link bad'}));
55838
56031
  if (preview?.session_id) {
55839
56032
  const diagnostics = node('details'); diagnostics.dataset.key = 'preview-diagnostics';
55840
56033
  diagnostics.append(node('summary','诊断信息'),fields([['会话 ID',preview.session_id],
@@ -55843,16 +56036,18 @@ function updateBuild() {
55843
56036
  }
55844
56037
  if (preview?.supported === false) localChildren.push(node('p','当前平台不支持本地预览','bad'));
55845
56038
  const actions = node('div',undefined,'actions preview-controls');
55846
- previewActions(preview).forEach(action => actions.append(button(
55847
- actionBusy(action) ? actionLabels[action] + '中' : actionLabels[action],
55848
- () => void runAction(action),{
55849
- loading:actionBusy(action),disabled:offline || busy(),focus:action,
55850
- ...(action === 'preview.refresh' ? {icon:'refresh'} : {})
55851
- })));
56039
+ if (!previewActions(preview).includes('preview.stop'))
56040
+ actions.append(button('停止预览',() => {},{disabled:true}));
56041
+ previewActions(preview).filter(action => action !== 'preview.start').reverse().forEach(action => actions.append(button(
56042
+ actionBusy(action) ? actionLabels[action] + '中' : actionLabels[action],() => void runAction(action),{
56043
+ loading:actionBusy(action),disabled:offline || busy(),focus:action,
56044
+ ...(action === 'preview.refresh' ? {icon:'refresh',iconOnly:true,className:'icon-button'} : {})
56045
+ })));
55852
56046
  actions.append(button(previewLoading ? '检测中' : '检测预览状态',() => void refreshPreview(),{
55853
- icon:'refresh',iconOnly:true,className:'icon-button',loading:previewLoading,focus:'preview-status'}));
55854
- actions.append(button('查看运行日志',() => void loadLogs(),{focus:'preview-logs'}));
56047
+ className:'link',loading:previewLoading,focus:'preview-status'}));
56048
+ actions.append(button('查看运行日志',() => void loadLogs(),{className:'link',focus:'preview-logs'}));
55855
56049
  localChildren.push(actions);
56050
+ localChildren.push(renderWindowSettings());
55856
56051
  replace($('preview-panel'),localChildren);
55857
56052
  renderConsoleLogs();
55858
56053
  const history = [node('h2','任务历史')];
@@ -56000,6 +56195,7 @@ function luaCheckBlocksBuild(task) {
56000
56195
  async function runAction(action, options = {}) {
56001
56196
  const key = selected, epoch = selectionEpoch;
56002
56197
  const project = currentProject();
56198
+ let preflight = false;
56003
56199
  if (!project?.valid || busy(key) || !Object.hasOwn(actionLabels,action)) return;
56004
56200
  if (action === 'build' || action === 'lua-lsp.check') logView().tab = action === 'build' ? 'build' : 'lua';
56005
56201
  pending.add(key); pendingActions.set(key,action); updateChrome(); updateBuild();
@@ -56050,6 +56246,7 @@ async function runAction(action, options = {}) {
56050
56246
  }
56051
56247
  if (action !== 'build' && action !== 'lua-lsp.check') {
56052
56248
  const checkServerChanges = action === 'preview.start' || action === 'preview.refresh';
56249
+ preflight = ['preview.start','preview.refresh','preview.install'].includes(action);
56053
56250
  const status = await api(projectPath(key,checkServerChanges ? '/preview?check_server_changes=1' : '/preview'));
56054
56251
  if (selectionMatches(key,epoch)) preview = status;
56055
56252
  if (!previewActions(status).includes(action)) throw new Error(text(status.error,'预览状态已改变,请重新检测后操作。'));
@@ -56102,6 +56299,21 @@ async function runAction(action, options = {}) {
56102
56299
  }
56103
56300
  } catch (error) {
56104
56301
  if (selectionMatches(key,epoch)) notify(error.message);
56302
+ const reportablePreflight = /timeout|timed out|HTTP 5\d\d|internal.*error|unverifiable|unexpected|connection closed/i
56303
+ .test(String(error?.message || error));
56304
+ if (preflight && reportablePreflight && selectionMatches(key,epoch)) {
56305
+ try {
56306
+ const failed = await api('/api/tasks/failure',{
56307
+ method:'POST',
56308
+ body:{projectKey:key,action,error:String(error?.message || error)}
56309
+ });
56310
+ rememberTask(failed);
56311
+ offerIssueReport(failed);
56312
+ showPendingIssueReport();
56313
+ } catch {
56314
+ // The original preflight error remains visible when the local task record cannot be saved.
56315
+ }
56316
+ }
56105
56317
  } finally {
56106
56318
  pending.delete(key);
56107
56319
  pendingActions.delete(key);
@@ -56118,6 +56330,7 @@ async function pollTask(id,key,epoch) {
56118
56330
  const task = await api('/api/tasks/' + encodeURIComponent(id));
56119
56331
  if (task.projectKey !== key || task.id !== id) throw new Error('任务身份不一致');
56120
56332
  rememberTask(task);
56333
+ if (prior?.status === 'running' && task.status !== 'running') offerIssueReport(task);
56121
56334
  const index = state.tasks.findIndex(t => t.id === id);
56122
56335
  if (index >= 0) state.tasks[index] = task; else state.tasks.push(task);
56123
56336
  if (!selectionMatches(key,epoch)) return task;
@@ -56127,6 +56340,7 @@ async function pollTask(id,key,epoch) {
56127
56340
  await refreshPreview();
56128
56341
  if (selectionMatches(key,epoch)) handleQrcodeCompletion(task);
56129
56342
  }
56343
+ showPendingIssueReport();
56130
56344
  return task;
56131
56345
  } catch (error) { if (selectionMatches(key,epoch)) notify(error.message); }
56132
56346
  }
@@ -56304,13 +56518,16 @@ async function pollState() {
56304
56518
  Object.assign(task,prior);
56305
56519
  } else if (prior) rememberTask(task);
56306
56520
  if (task.projectKey === selected && previousTasks.get(task.id) === 'running' && task.status !== 'running') {
56521
+ offerIssueReport(task);
56307
56522
  announce((actionLabels[task.action] || task.action) + ' · ' + text(task.projectName) + ' · ' + (statusLabels[task.status] || '结果未知'));
56308
56523
  handleQrcodeCompletion(task);
56309
56524
  }
56310
56525
  });
56526
+ showPendingIssueReport();
56311
56527
  $('version').textContent = 'Maker ' + text(state.version) + ' · ' + text(state.distribution,'独立发行') + ' · ' + text(state.platform);
56312
56528
  renderVersionPicker();
56313
- $('connection').textContent = '已连接 · ' + new Date().toLocaleTimeString('zh-CN');
56529
+ $('connection').textContent = '已连接';
56530
+ $('connection').title = '最近连接:' + new Date().toLocaleTimeString('zh-CN');
56314
56531
  $('connection').className = 'good';
56315
56532
  lastStateError = '';
56316
56533
  if (selected && !currentProject()?.valid && (page !== 'projects' || first || priorProjects !== JSON.stringify(state.projects))) {
@@ -56344,6 +56561,19 @@ async function poll() {
56344
56561
  }
56345
56562
  }
56346
56563
  document.addEventListener('DOMContentLoaded',async () => {
56564
+ let makerMarkClicks = 0;
56565
+ let makerMarkTimer;
56566
+ $('maker-mark').addEventListener('click',() => {
56567
+ makerMarkClicks += 1;
56568
+ clearTimeout(makerMarkTimer);
56569
+ if (makerMarkClicks >= 3) {
56570
+ $('maker-mark').classList.add('maker-easter-egg');
56571
+ $('maker-mark').setAttribute('aria-label','Maker 控制台彩蛋已触发');
56572
+ makerMarkClicks = 0;
56573
+ return;
56574
+ }
56575
+ makerMarkTimer = setTimeout(() => { makerMarkClicks = 0; },1000);
56576
+ });
56347
56577
  window.addEventListener('message',event => {
56348
56578
  for (const session of pluginSessions.values()) {
56349
56579
  if (!pluginMessageMatches(event,session)) continue;
@@ -56422,7 +56652,7 @@ var init_webStyles = __esm({
56422
56652
  "src/maker/console/webStyles.ts"() {
56423
56653
  "use strict";
56424
56654
  consoleStyles = String.raw`
56425
- :root{color-scheme:dark;--bg:#202224;--top:#282b2d;--border:#414647;--text:#f2f4ef;--muted:#acb4af;--yellow:#f5d747;--accent:#f5d747;--green:#70d9b4;--red:#ff9c94;--soft:#303b36;--code:#191c1d}
56655
+ :root{color-scheme:dark;--bg:#1b1e1f;--top:#232728;--border:#363b3c;--text:#ecefee;--muted:#9ca6a4;--yellow:#f5dc56;--accent:#f5dc56;--green:#78d4ad;--red:#f08b85;--soft:#303b36;--code:#16191a}
56426
56656
  :root[data-theme="light"]{color-scheme:light;--bg:#fff;--top:#f3f5f4;--border:#dce2de;--text:#252e29;--muted:#64716a;--accent:#76600b;--green:#176c50;--red:#b3352c;--soft:#edf4ef;--code:#f5f7f6}
56427
56657
  *{box-sizing:border-box}
56428
56658
  body{margin:0;background:var(--bg);color:var(--text);font:14px/1.6 "PingFang SC","Microsoft YaHei",sans-serif;letter-spacing:0}
@@ -56431,11 +56661,12 @@ button{display:inline-flex;align-items:center;justify-content:center;gap:7px;min
56431
56661
  button:hover:not(:disabled){border-color:var(--muted);background:var(--soft)}
56432
56662
  button:disabled{opacity:.5;cursor:not-allowed}
56433
56663
  button.primary{background:var(--yellow);border-color:var(--yellow);color:#252820;font-weight:600}
56434
- button.preview-button{color:var(--yellow);font-weight:700}
56435
- .build-button{min-width:116px}
56664
+ button.preview-button{color:var(--accent);font-weight:700;border-color:#756b38;background:#302e22}
56665
+ :root[data-theme="light"] button.preview-button{background:#fcf6d7;border-color:#bcab57}
56666
+ .build-button{min-width:88px}
56436
56667
  button.is-building:disabled{opacity:1;cursor:wait}
56437
56668
  .build-badge{font-size:12px;white-space:nowrap}
56438
- .build-status{padding:14px 0;margin-bottom:14px;border-block:1px solid var(--border);min-height:60px}
56669
+ .build-status{padding:0;margin-bottom:16px;min-height:32px}
56439
56670
  .build-status-title{display:flex;align-items:center;gap:8px}
56440
56671
  .build-stage{font-size:13px;overflow-wrap:anywhere}
56441
56672
  .build-progress{height:6px;width:100%;overflow:hidden;background:var(--border);margin-top:12px}
@@ -56452,27 +56683,29 @@ button.is-building:disabled{opacity:1;cursor:wait}
56452
56683
  .build-progress.determinate span{transition:width .25s ease}
56453
56684
  }
56454
56685
  button.danger{color:var(--red)}
56455
- .console-service-actions{display:flex;justify-content:flex-end;margin-top:24px;padding-top:16px;border-top:1px solid var(--border)}
56456
- button.console-shutdown{background:#702c32;color:#fff;border-color:#702c32}
56686
+ .console-service-actions{display:flex;justify-content:flex-end;margin-top:24px;padding-top:16px}
56687
+ button.console-shutdown{background:#332525;color:#d3908e;border-color:#65413f;font-size:12px}
56457
56688
  button.console-shutdown:hover:not(:disabled){background:#87353d;border-color:#87353d}
56458
56689
  #maker-version-picker{font-size:12px;font-weight:400;max-width:240px;min-width:100px;padding:5px 8px}
56459
56690
  .brand{flex-wrap:wrap}
56460
- .footer-start{display:flex;align-items:center;gap:12px;flex-wrap:nowrap;min-width:0}
56691
+ .footer-start{display:flex;align-items:center;gap:18px;flex-wrap:wrap;min-width:0}
56461
56692
  #fortune-corner{position:relative;flex:none}
56462
- button#fortune-toggle{border:0;background:none;color:#f5e6a3;font-size:12px;font-weight:600;padding:0;min-height:0;line-height:1.4;white-space:nowrap}
56693
+ button#fortune-toggle{border:0;background:none;color:#b5aa78;font-size:11px;font-weight:400;padding:0;min-height:0;line-height:1.4;white-space:nowrap}
56463
56694
  :root[data-theme="light"] button#fortune-toggle{color:#c4a017}
56464
56695
  button#fortune-toggle:hover,button#fortune-toggle[aria-expanded="true"]{color:var(--yellow);background:none;border-color:transparent}
56465
56696
  #fortune-panel{position:fixed;z-index:30;overflow:hidden;border:0;border-radius:6px;background:transparent;box-shadow:0 8px 28px #0005}
56466
- #fortune-panel.fortune-preload{opacity:0;pointer-events:none;left:0;top:0;width:1px;height:1px}
56467
56697
  #fortune-panel[hidden]{display:none!important}
56698
+ #fortune-panel.fortune-preload{opacity:0;pointer-events:none;left:0;top:0;width:1px;height:1px}
56468
56699
  #fortune-panel iframe{display:block;width:100%;height:100%;border:0}
56469
56700
  .document-toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:12px;margin-bottom:18px}
56470
56701
  .document-toolbar input{flex:1;min-width:160px;max-width:360px}
56471
- .document-toolbar [aria-selected="true"]{color:var(--accent);border-bottom:2px solid var(--accent)}
56472
- .document-layout{display:grid;grid-template-columns:260px minmax(0,1fr);border-top:1px solid var(--border);min-height:480px}
56473
- #document-directory{padding:12px 18px 20px 0;border-right:1px solid var(--border);max-height:75vh;overflow:auto}
56702
+ .document-tabs{border:1px solid var(--border);border-radius:5px;padding:3px;gap:3px}
56703
+ .document-tabs button{border:0;background:transparent;color:var(--muted);font-size:13px;min-height:30px;padding:4px 12px}
56704
+ .document-toolbar [aria-selected="true"]{color:var(--accent);background:var(--soft)}
56705
+ .document-layout{display:grid;grid-template-columns:235px minmax(0,1fr);border-top:1px solid var(--border);height:calc(100dvh - 260px);min-height:460px}
56706
+ #document-directory{padding:12px 18px 20px 0;border-right:1px solid var(--border);overflow:auto}
56474
56707
  #document-directory h3{font-size:12px;color:var(--muted);margin:18px 0 8px}
56475
- button.document-entry{display:block;width:100%;padding:7px 10px;overflow-wrap:anywhere;border-radius:0;font-size:13px}
56708
+ button.document-entry{display:block;width:100%;padding:7px 10px;overflow-wrap:anywhere;border-radius:4px;font-size:13px}
56476
56709
  button.document-entry[aria-current]{color:var(--accent);background:var(--soft);border-left:2px solid var(--accent)}
56477
56710
  button.document-entry.document-featured{color:var(--accent);font-weight:700}
56478
56711
  .document-intro{border-bottom:1px solid var(--border);padding-bottom:16px;margin-bottom:20px}
@@ -56482,7 +56715,7 @@ button.document-entry.document-featured{color:var(--accent);font-weight:700}
56482
56715
  .document-reader-header h2{font-size:22px;margin:0;min-width:0;flex:1}
56483
56716
  .document-reader-header button{flex-shrink:0}
56484
56717
  .document-reader-header input{width:100%}
56485
- #document-reader{min-width:0;padding:22px 28px;max-height:75vh;overflow:auto;overflow-wrap:anywhere}
56718
+ #document-reader{min-width:0;padding:22px 32px;overflow:auto;overflow-wrap:anywhere}
56486
56719
  #document-reader>h2{font-size:22px;margin-top:0}
56487
56720
  .markdown-content{line-height:1.85;max-width:920px}
56488
56721
  .markdown-content h1{font-size:24px}.markdown-content h2{font-size:20px}.markdown-content h3{font-size:17px}
@@ -56491,27 +56724,33 @@ button.document-entry.document-featured{color:var(--accent);font-weight:700}
56491
56724
  .markdown-content a{color:var(--green);text-decoration:underline}
56492
56725
  .doc-table{overflow:auto}.doc-table table{border-collapse:collapse;width:100%}
56493
56726
  .doc-table th,.doc-table td{border:1px solid var(--border);padding:8px;text-align:left}
56494
- @media(max-width:700px){.document-layout{grid-template-columns:minmax(0,1fr)}#document-directory{max-height:220px;border-right:0;border-bottom:1px solid var(--border);padding-right:0}#document-reader{padding:18px 0;max-height:none}}
56727
+ @media(max-width:700px){.document-layout{grid-template-columns:minmax(0,1fr);height:auto}#document-directory{max-height:220px;border-right:0;border-bottom:1px solid var(--border);padding-right:0}#document-reader{padding:18px 0;max-height:none}}
56495
56728
  button.icon-button{width:36px;flex-shrink:0;padding:8px}
56496
56729
  button.link{background:none;border:0;padding:0;justify-content:flex-start;color:var(--text);text-align:left;min-width:0}
56497
56730
  :focus-visible{outline:2px solid var(--accent);outline-offset:3px}
56498
56731
  .icon{width:16px;height:16px;flex:none}
56499
56732
  input,select{border:1px solid var(--border);border-radius:4px;padding:7px 10px;background:var(--bg);color:var(--text)}
56500
- input[type="checkbox"]{accent-color:var(--yellow);width:18px;height:18px}
56501
- .top{display:flex;justify-content:space-between;gap:20px;align-items:center;padding:18px 28px;background:var(--top);flex-wrap:wrap}
56733
+ input[type="checkbox"]{accent-color:var(--yellow);width:14px;height:14px}
56734
+ .top{display:flex;justify-content:space-between;gap:20px;align-items:center;padding:18px 32px;background:var(--top);flex-wrap:wrap}
56502
56735
  .brand{font-size:18px;font-weight:600;display:flex;gap:10px;align-items:center}
56503
- .mark{width:28px;height:28px;display:grid;place-items:center;color:#252820;background:var(--yellow);border-radius:4px}
56736
+ .mark{width:28px;height:28px;display:grid;place-items:center;color:#252820;background:var(--yellow);border:0;border-radius:4px;padding:0;font:inherit;font-weight:800;cursor:pointer;transition:transform .2s ease,background .2s ease}
56737
+ .mark:active{transform:scale(.94)}
56738
+ .mark.maker-easter-egg{color:var(--yellow);background:transparent;border-radius:0;position:relative;overflow:visible;font-family:"Arial Rounded MT Bold","Trebuchet MS",sans-serif;font-size:25px;font-weight:900;letter-spacing:0;line-height:1;animation:maker-mark-reveal 1.5s ease both}
56739
+ @keyframes maker-mark-reveal{0%{transform:scale(.9);opacity:.35}55%{transform:scale(1.08)}100%{transform:scale(1);opacity:1}}
56740
+ @media(prefers-reduced-motion:reduce){.mark,.mark.maker-easter-egg{animation:none;transition:none}}
56504
56741
  .toolbar,.actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
56505
- .toolbar select{max-width:380px;width:300px}
56742
+ .toolbar select{max-width:380px;width:235px}
56506
56743
  .theme{display:flex;gap:7px;align-items:center;font-size:12px;color:var(--muted);white-space:nowrap}
56507
- nav{padding:0 28px;display:flex;gap:26px;border-bottom:1px solid var(--border);background:var(--top)}
56744
+ .navigation{display:flex;align-items:center;gap:24px;padding:0 32px;border-bottom:1px solid var(--border);background:var(--top)}
56745
+ nav{display:flex;gap:26px;min-width:0;flex:1;background:var(--top)}
56508
56746
  nav button{background:none;border:0;border-bottom:2px solid transparent;border-radius:0;padding:10px 0;color:var(--muted)}
56509
56747
  nav button[aria-current="page"]{color:var(--accent);border-bottom-color:var(--yellow)}
56510
- .context,footer{padding:10px 28px;display:flex;gap:12px;justify-content:space-between;flex-wrap:wrap;font-size:12px;color:var(--muted)}
56511
- .context{border-bottom:1px solid var(--border)}
56748
+ .context,footer{padding:10px 32px;display:flex;gap:18px;justify-content:space-between;flex-wrap:wrap;font-size:12px;color:var(--muted)}
56749
+ .navigation .context{padding:0;justify-content:flex-end;font-size:12px;flex-shrink:0;max-width:40%}
56750
+ #connection.good:before{content:"";display:inline-block;width:6px;height:6px;border-radius:50%;background:var(--green);margin-right:7px}
56512
56751
  .context span{overflow-wrap:anywhere;min-width:0}
56513
- main{padding:26px 28px;max-width:1600px;margin:0 auto;min-height:65vh}
56514
- h1{font-size:24px;font-weight:500;margin:0;overflow-wrap:anywhere}
56752
+ main{padding:28px 32px;max-width:1480px;margin:0 auto;min-height:calc(100dvh - 180px)}
56753
+ h1{font-size:23px;font-weight:600;margin:0;overflow-wrap:anywhere}
56515
56754
  h2{font-size:16px;font-weight:600;margin:0 0 14px}
56516
56755
  h3{font-size:14px;font-weight:600;margin:0 0 6px}
56517
56756
  p{margin:8px 0}
@@ -56519,7 +56758,6 @@ p{margin:8px 0}
56519
56758
  .heading p{margin:2px 0 0}
56520
56759
  #heading-actions{display:flex;flex-direction:column;align-items:flex-end;gap:10px;max-width:100%}
56521
56760
  .heading-primary,.heading-secondary{justify-content:flex-end;max-width:100%}
56522
- .heading-secondary{font-size:12px;gap:14px}
56523
56761
  .qrcode-image{display:block;width:240px;max-width:100%;height:auto;margin:14px 0}
56524
56762
  #qrcode-result{width:496px;max-height:calc(100dvh - 32px);overflow:auto}
56525
56763
  .qrcode-scan-area{width:min(400px,100%,55dvh);aspect-ratio:1;margin:16px auto;background:#fff;display:grid;place-items:center;padding:12px}
@@ -56541,13 +56779,19 @@ p{margin:8px 0}
56541
56779
  .failure-detail{margin:8px 0 0;max-height:280px}
56542
56780
  .metrics{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));border-block:1px solid var(--border);margin-bottom:26px}
56543
56781
  .lua-check-option{display:inline-flex;align-items:center;gap:8px;color:var(--muted);white-space:nowrap}
56544
- .lua-check-panel{margin-top:16px;padding-top:14px;border-top:1px solid var(--border)}
56545
- .metric{padding:14px 12px 14px 0;min-width:0}
56546
- .metric .value{font-size:19px;font-weight:500;overflow-wrap:anywhere;margin-top:3px}
56782
+ .lua-check-panel{font-size:12px}
56783
+ .lua-check-actions{gap:12px;min-height:36px}
56784
+ .lua-check-actions>button:last-child{margin-left:auto;color:var(--muted)}
56785
+ .lsp-status{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-top:12px;min-height:36px}
56786
+ .lsp-status>button{color:var(--muted)}
56787
+ .metric{padding:20px 12px 20px 0;min-width:0}
56788
+ .metric .value{font-size:18px;font-weight:600;overflow-wrap:anywhere;margin-top:6px}
56547
56789
  .metric .muted{font-size:12px}
56548
56790
  .runtime-detail{margin-top:3px;overflow-wrap:anywhere}
56549
56791
  .runtime-metric button{margin-top:8px}
56550
56792
  .columns{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:36px}
56793
+ .build-columns{padding:22px 0;border-block:1px solid var(--border)}
56794
+ .build-columns>section+section{padding-left:36px;border-left:1px solid var(--border)}
56551
56795
  section{min-width:0}
56552
56796
  dl{margin:0}
56553
56797
  .row{display:flex;justify-content:space-between;gap:16px;padding:9px 0;border-bottom:1px solid var(--border);overflow-wrap:anywhere}
@@ -56558,19 +56802,27 @@ pre{white-space:pre-wrap;tab-size:2;margin:10px 0 0;background:var(--code);paddi
56558
56802
  .feedback p{margin:0;white-space:pre-wrap}
56559
56803
  .feedback[data-tone="warning"]{border-left-color:var(--yellow)}
56560
56804
  .feedback[data-tone="success"]{border-left-color:var(--green)}
56561
- .console-logs{width:100%;min-width:0;margin-top:24px;border-top:1px solid var(--border);padding-top:16px}
56805
+ .console-logs{width:100%;min-width:0;margin-top:24px}
56562
56806
  .console-log-toolbar{display:flex;flex-wrap:wrap;gap:12px;align-items:center;justify-content:space-between;margin-bottom:10px}
56563
- .console-log-toolbar [aria-selected="true"]{color:var(--accent);border-bottom:2px solid var(--accent)}
56564
- .console-logs .console-log-output{height:360px;max-height:60vh;width:100%;max-width:100%;overflow:auto;white-space:pre;overflow-wrap:normal;word-break:normal;margin:0}
56807
+ .console-log-toolbar h2{margin:0}
56808
+ .console-log-tabs{display:flex;gap:22px;padding:0 16px;background:var(--top);border:1px solid var(--border);border-radius:4px 4px 0 0;overflow:auto}
56809
+ .console-log-tabs button{border:0;border-bottom:2px solid transparent;background:none;border-radius:0;font-size:12px;color:var(--muted);padding:10px 0;flex-shrink:0}
56810
+ .console-log-tabs [aria-selected="true"]{color:var(--accent);border-bottom-color:var(--accent)}
56811
+ .console-logs .console-log-output{height:360px;max-height:60vh;width:100%;max-width:100%;overflow:auto;white-space:pre;overflow-wrap:normal;word-break:normal;margin:0;border-top:0;border-radius:0 0 4px 4px;line-height:1.9}
56565
56812
  .console-logs .console-log-output.wrap{white-space:pre-wrap;overflow-wrap:anywhere}
56566
56813
  .console-log-output .log-line{color:var(--text)}
56567
56814
  .console-log-output .log-error{color:var(--red)}
56568
56815
  .console-log-output .log-warning{color:var(--yellow)}
56569
56816
  button.link.bad{color:var(--red)}button.link.good{color:var(--green)}button.link.pending{color:var(--accent)}
56570
- .preview-status-summary{display:flex;flex-wrap:wrap;align-items:center;gap:8px 20px;padding:12px 0;border-top:1px solid var(--border);border-bottom:1px solid var(--border)}
56571
- .preview-status-summary span{font-weight:600}
56572
- .preview-window-settings{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin:20px 0;padding:0 0 20px;border-bottom:1px solid var(--border)}
56573
- .preview-window-title{grid-column:1/-1;margin:0 0 4px;font-size:17px;padding-left:10px;border-left:3px solid var(--accent)}
56817
+ .preview-status-summary{display:flex;flex-wrap:wrap;align-items:center;gap:8px 16px;min-height:32px;font-size:13px}
56818
+ .preview-status-summary button{margin-left:auto}
56819
+ .preview-window-disclosure{margin-top:12px;font-size:12px}
56820
+ .preview-window-summary{display:flex;align-items:center;gap:10px;min-height:36px;flex-wrap:wrap;list-style:none}
56821
+ .preview-window-summary::-webkit-details-marker{display:none}
56822
+ .preview-window-summary>span:nth-child(2){margin-left:auto}
56823
+ .preview-window-summary:after{content:"⌄";color:var(--muted)}
56824
+ .preview-window-disclosure[open]>.preview-window-summary:after{content:"⌃"}
56825
+ .preview-window-settings{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin:12px 0 0;padding:14px 0 0;border-top:1px solid var(--border)}
56574
56826
  .preview-window-settings label{display:flex;flex-direction:column;gap:6px;min-width:0}
56575
56827
  .preview-window-settings input,.preview-window-settings select{width:100%;min-width:0;box-sizing:border-box}
56576
56828
  .preview-window-footer{grid-column:1/-1;display:flex;flex-wrap:wrap;gap:10px;align-items:center;justify-content:space-between}
@@ -56585,13 +56837,23 @@ button.link.bad{color:var(--red)}button.link.good{color:var(--green)}button.link
56585
56837
  .entry label{grid-column:1/-1}
56586
56838
  .task-history{margin-top:28px;border-top:1px solid var(--border);padding-top:20px}
56587
56839
  .build-detail,.preview-log-detail{margin-top:28px;border-top:1px solid var(--border);padding-top:20px;width:100%}
56588
- .task{padding:12px 0;border-bottom:1px solid var(--border)}
56840
+ .task-item{display:flex;align-items:flex-start;gap:16px;border-bottom:1px solid var(--border);padding:13px 0}
56841
+ .task{flex:1;min-width:0}
56842
+ .task-shortcuts{flex-shrink:0;max-width:40%;justify-content:flex-end}
56843
+ .task-shortcuts:empty{display:none}
56844
+ .section-heading{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:14px}
56845
+ .section-heading h2{margin:0}.section-heading span{font-size:12px}
56589
56846
  summary{cursor:pointer;overflow-wrap:anywhere}
56590
- .task summary{display:flex;align-items:baseline;gap:12px;flex-wrap:wrap}
56847
+ .task summary{display:flex;align-items:baseline;gap:12px;flex-wrap:wrap;min-height:36px;padding:6px 0;font-size:13px}
56848
+ .task summary:before{content:"›";color:var(--muted)}
56849
+ .task[open]>summary:before{content:"⌄"}
56591
56850
  .task summary time{margin-left:auto;font-size:12px}
56592
56851
  .task .task-meta{font-size:12px;margin-top:8px}
56593
56852
  .status-line{min-height:48px;margin:0 0 15px;padding:12px 0;border-block:1px solid var(--border);overflow-wrap:anywhere}
56594
56853
  .preview-controls{margin-top:14px}
56854
+ #preview-panel>.preview-controls{margin-top:12px;min-height:36px}
56855
+ #preview-panel>.preview-controls>.link:last-child{margin-left:auto;color:var(--muted);font-size:12px}
56856
+ #preview-panel>details:not(.preview-window-disclosure){margin-top:8px;font-size:12px;color:var(--muted)}
56595
56857
  .git-scroll{overflow:auto}
56596
56858
  .git-history{position:relative;min-width:420px}
56597
56859
  .git-graph{position:absolute;inset:0 auto auto 0;pointer-events:none}
@@ -56603,7 +56865,8 @@ summary{cursor:pointer;overflow-wrap:anywhere}
56603
56865
  .git-meta{display:flex;gap:14px;flex-wrap:wrap;margin-bottom:16px}
56604
56866
  .git-detail{margin-top:24px;border-top:1px solid var(--border);padding-top:20px}
56605
56867
  .file-list{padding-left:22px;overflow-wrap:anywhere}
56606
- footer{border-top:1px solid var(--border);font-size:11px;align-items:center}
56868
+ footer{border-top:1px solid var(--border);font-size:11px;align-items:center;gap:12px}
56869
+ #footer-path{overflow-wrap:anywhere;min-width:0}
56607
56870
  dialog{background:var(--bg);color:var(--text);border:1px solid var(--border);border-radius:6px;padding:24px;width:440px;max-width:calc(100% - 32px)}
56608
56871
  dialog::backdrop{background:#0009}
56609
56872
  dialog h2{font-size:18px}dialog .actions{justify-content:flex-end;margin-top:22px}
@@ -56616,13 +56879,18 @@ nav{overflow-x:auto;white-space:nowrap}
56616
56879
  .plugin-frame{display:block;width:100%;height:calc(100dvh - 205px);min-height:520px;border:0;background:var(--bg)}
56617
56880
  [hidden]{display:none!important}
56618
56881
  @media(max-width:720px){
56619
- .top,main{padding:18px 16px}nav{padding-inline:16px;gap:24px}.context,footer{padding-inline:16px}
56882
+ .top,main{padding:18px 16px}.navigation{padding-inline:16px;gap:0;flex-wrap:wrap}nav{gap:24px;width:100%;flex:auto}.context,footer{padding-inline:16px}
56883
+ .navigation .context{max-width:none;width:100%;padding:8px 0;justify-content:space-between}
56620
56884
  .toolbar{width:100%}.toolbar select{flex:1;min-width:0;width:auto}.theme{margin-left:auto}
56621
56885
  .columns{grid-template-columns:1fr;gap:28px}.metrics{grid-template-columns:repeat(2,minmax(0,1fr))}
56886
+ .build-columns>section+section{padding-left:0;border-left:0;padding-top:20px;border-top:1px solid var(--border)}
56622
56887
  .feedback{margin-inline:16px}button{min-height:42px}button.icon-button{width:42px}
56623
56888
  .project-row{gap:10px}.project-row .actions{justify-content:flex-end}.entry{grid-template-columns:1fr}.entry input{font-size:16px}
56624
56889
  .git-row{grid-template-columns:64px minmax(0,1fr);gap:8px;padding-block:8px}.git-row time{grid-column:2;text-align:left;font-size:11px}
56625
56890
  .task summary time{margin-left:0;width:100%}h1{font-size:22px}
56891
+ .task-item{flex-wrap:wrap;gap:6px}.task-shortcuts{max-width:100%}
56892
+ .console-log-tabs{gap:18px;padding-inline:12px}
56893
+ .document-tabs button{min-height:36px}
56626
56894
  .plugin-status{padding:10px 16px}.plugin-frame{height:calc(100dvh - 235px);min-height:480px}
56627
56895
  }
56628
56896
  @media(prefers-reduced-motion:no-preference){button{transition:background .12s,border-color .12s}}
@@ -56643,7 +56911,7 @@ function getConsoleHtml() {
56643
56911
  <title>Maker 本地控制台</title><style>${consoleStyles}</style></head>
56644
56912
  <body>
56645
56913
  <header class="top">
56646
- <div class="brand"><span class="mark" aria-hidden="true">M</span>Maker 控制台
56914
+ <div class="brand"><button class="mark" id="maker-mark" type="button" aria-label="Maker 控制台品牌标记">M</button>Maker 控制台
56647
56915
  <select id="maker-version-picker" aria-label="Maker MCP 版本" disabled><option>版本加载中</option></select>
56648
56916
  </div>
56649
56917
  <div class="toolbar">
@@ -56652,6 +56920,7 @@ function getConsoleHtml() {
56652
56920
  <label class="theme">深色<input id="theme" type="checkbox" role="switch" checked aria-label="深色模式"></label>
56653
56921
  </div>
56654
56922
  </header>
56923
+ <div class="navigation">
56655
56924
  <nav aria-label="主导航">
56656
56925
  <button data-page="overview">项目</button>
56657
56926
  <button data-page="build">构建与测试</button>
@@ -56660,6 +56929,7 @@ function getConsoleHtml() {
56660
56929
  <span id="plugin-tabs" class="plugin-tabs"></span>
56661
56930
  </nav>
56662
56931
  <div class="context"><span id="context">正在连接本地服务</span><span id="connection" role="status">连接中</span></div>
56932
+ </div>
56663
56933
  <div id="feedback" class="feedback" role="alert" hidden><p id="feedback-text"></p><button id="dismiss">关闭</button></div>
56664
56934
  <main id="view" aria-busy="true"><p class="empty">正在读取本地项目</p></main>
56665
56935
  <section id="plugin-views" aria-label="插件工作区" hidden></section>
@@ -65421,7 +65691,7 @@ init_config();
65421
65691
  import { spawnSync as spawnSync8 } from "node:child_process";
65422
65692
  import crypto5 from "node:crypto";
65423
65693
  import fs51 from "node:fs";
65424
- import os12 from "node:os";
65694
+ import os13 from "node:os";
65425
65695
  import path53 from "node:path";
65426
65696
  import readline from "node:readline/promises";
65427
65697
  import { stdin as input, stdout as output } from "node:process";
@@ -65480,7 +65750,7 @@ async function pollCliLoginResult(code, options3) {
65480
65750
  let lastPollError;
65481
65751
  for (; ; ) {
65482
65752
  if (Date.now() >= deadline) {
65483
- const suffix = lastPollError ? ` Last polling error: ${formatError3(lastPollError)}` : "";
65753
+ const suffix = lastPollError ? ` Last polling error: ${formatError4(lastPollError)}` : "";
65484
65754
  throw new Error(
65485
65755
  `Maker CLI login timed out. Run \`taptap-maker login\` and try again.${suffix}`
65486
65756
  );
@@ -65566,7 +65836,7 @@ function delay(ms) {
65566
65836
  setTimeout(resolve, ms);
65567
65837
  });
65568
65838
  }
65569
- function formatError3(error2) {
65839
+ function formatError4(error2) {
65570
65840
  return error2 instanceof Error ? error2.message : String(error2);
65571
65841
  }
65572
65842
 
@@ -65582,21 +65852,22 @@ init_runtimeLogs();
65582
65852
 
65583
65853
  // src/maker/cli/preview.ts
65584
65854
  init_protocol2();
65585
- import fs36 from "node:fs";
65586
- import path37 from "node:path";
65855
+ import fs35 from "node:fs";
65856
+ import path36 from "node:path";
65587
65857
  import { randomBytes as randomBytes3, randomUUID as randomUUID6 } from "node:crypto";
65588
65858
 
65589
65859
  // src/maker/preview/installation.ts
65590
65860
  init_python();
65591
65861
  init_protocol2();
65592
- import fs33 from "node:fs";
65593
- import path34 from "node:path";
65862
+ import fs32 from "node:fs";
65863
+ import path33 from "node:path";
65594
65864
  import { createHash as createHash5, randomUUID as randomUUID5 } from "node:crypto";
65595
65865
 
65596
65866
  // src/maker/preview/runtime.ts
65597
65867
  init_protocol2();
65598
- import fs31 from "node:fs";
65599
- import path32 from "node:path";
65868
+ import fs30 from "node:fs";
65869
+ import path31 from "node:path";
65870
+ import os5 from "node:os";
65600
65871
  import { spawn as spawn6 } from "node:child_process";
65601
65872
  import { StringDecoder } from "node:string_decoder";
65602
65873
 
@@ -65791,6 +66062,22 @@ function inside(root2, relative) {
65791
66062
  throw new Error("Prepared manifest path escapes its output directory.");
65792
66063
  return filename2;
65793
66064
  }
66065
+ function copyTree(source, target, signal) {
66066
+ if (signal == null ? void 0 : signal.aborted) throw new Error("CANCELLED");
66067
+ const stat = fs26.lstatSync(source);
66068
+ if (stat.isSymbolicLink())
66069
+ throw new Error(`Local prepare does not support symbolic links: ${source}`);
66070
+ if (stat.isDirectory()) {
66071
+ fs26.mkdirSync(target, { recursive: true, mode: 448 });
66072
+ for (const name of fs26.readdirSync(source)) {
66073
+ copyTree(path27.join(source, name), path27.join(target, name), signal);
66074
+ }
66075
+ return;
66076
+ }
66077
+ if (!stat.isFile()) throw new Error(`Local prepare does not support special files: ${source}`);
66078
+ fs26.mkdirSync(path27.dirname(target), { recursive: true, mode: 448 });
66079
+ fs26.copyFileSync(source, target);
66080
+ }
65794
66081
  function validateProjectVersion(source) {
65795
66082
  const filename2 = path27.join(source, ".project", "project.json");
65796
66083
  if (!fs26.existsSync(filename2))
@@ -65873,8 +66160,7 @@ async function prepareProjectCopy(project, directory, signal) {
65873
66160
  fs26.mkdirSync(source, { recursive: true, mode: 448 });
65874
66161
  for (const name of ["scripts", "assets", ".project"]) {
65875
66162
  const original = path27.join(project, name);
65876
- if (fs26.existsSync(original))
65877
- fs26.cpSync(original, path27.join(source, name), { recursive: true, dereference: true });
66163
+ if (fs26.existsSync(original)) copyTree(original, path27.join(source, name), signal);
65878
66164
  }
65879
66165
  const configDirectory = path27.join(source, ".project");
65880
66166
  fs26.mkdirSync(configDirectory, { recursive: true });
@@ -65917,7 +66203,7 @@ async function prepareProjectCopy(project, directory, signal) {
65917
66203
  const args = [builder, "--project", source, "--force-enhanced-refs", "--no-7z", "--no-compress"];
65918
66204
  const cache = path27.join(previewDirectory(project), "public-index-cache");
65919
66205
  const roundCache = path27.join(source, ".build", "manifest_cache");
65920
- if (fs26.existsSync(cache)) fs26.cpSync(cache, roundCache, { recursive: true });
66206
+ if (fs26.existsSync(cache)) copyTree(cache, roundCache, signal);
65921
66207
  const log = path27.join(directory, "prepare.log");
65922
66208
  try {
65923
66209
  const output2 = await promisify(execFile)(python.python, args, {
@@ -65935,7 +66221,7 @@ async function prepareProjectCopy(project, directory, signal) {
65935
66221
  throw new Error("Public source index download failed.");
65936
66222
  if (output2.stdout.includes("[ERROR]")) throw new Error("ProjectBuilder reported an error.");
65937
66223
  const result = validatePreparedPreview(source);
65938
- if (fs26.existsSync(roundCache)) fs26.cpSync(roundCache, cache, { recursive: true });
66224
+ if (fs26.existsSync(roundCache)) copyTree(roundCache, cache, signal);
65939
66225
  return {
65940
66226
  ok: true,
65941
66227
  source_directory: source,
@@ -65962,6 +66248,9 @@ function previewPreparationDirectory(project) {
65962
66248
  return path27.join(previewDirectory(project), "preparations", randomUUID4());
65963
66249
  }
65964
66250
 
66251
+ // src/maker/preview/runtime.ts
66252
+ init_configuration();
66253
+
65965
66254
  // src/maker/preview/assets.ts
65966
66255
  import fs27 from "node:fs";
65967
66256
  import path28 from "node:path";
@@ -66233,17 +66522,27 @@ var previewWire = {
66233
66522
  };
66234
66523
 
66235
66524
  // src/maker/preview/network.ts
66236
- function previewNetworkProject(source) {
66525
+ function previewNetworkConfigured(source) {
66237
66526
  var _a3;
66238
66527
  const settings = readPreviewConfiguration(source, "settings");
66239
66528
  const runtime = settings == null ? void 0 : settings["@runtime"];
66240
66529
  const multiplayer = runtime == null ? void 0 : runtime.multiplayer;
66241
- const enabled = multiplayer ? multiplayer.enabled ?? multiplayer.max_players > 0 : (runtime == null ? void 0 : runtime.max_players) > 0;
66242
- if (!enabled) return void 0;
66530
+ return Boolean(
66531
+ multiplayer ? multiplayer.enabled !== void 0 ? multiplayer.enabled : multiplayer.max_players !== void 0 ? multiplayer.max_players > 0 : Boolean((_a3 = multiplayer.persistent_world) == null ? void 0 : _a3.enabled) : (runtime == null ? void 0 : runtime.max_players) > 0
66532
+ );
66533
+ }
66534
+ function previewNetworkProject(source) {
66535
+ var _a3;
66536
+ if (!previewNetworkConfigured(source)) return void 0;
66243
66537
  const project = readPreviewConfiguration(source, "project");
66244
66538
  const latestPath = path30.join(source, "dist", "latest.json");
66245
66539
  const latest = fs29.existsSync(latestPath) ? JSON.parse(fs29.readFileSync(latestPath, "utf8")) : void 0;
66246
- if (typeof (project == null ? void 0 : project.project_id) !== "string" || !project.project_id.trim() || ((_a3 = project.author) == null ? void 0 : _a3.id) === "local-preview" || typeof (latest == null ? void 0 : latest.version) !== "string" || !latest.version)
66540
+ if (typeof (project == null ? void 0 : project.project_id) !== "string" || !project.project_id.trim() || ((_a3 = project.author) == null ? void 0 : _a3.id) === "local-preview")
66541
+ throw new Error("联网预览缺少游戏配置,请先提交构建并生成一次测试二维码,再启动本地预览。");
66542
+ if (!latest) {
66543
+ throw new Error("联网预览缺少本地构建产物,请先完成本地准备并生成 latest.json。");
66544
+ }
66545
+ if (typeof latest.version !== "string" || !/^[a-z0-9][a-z0-9._+-]{0,127}$/i.test(latest.version))
66247
66546
  throw new Error("联网预览缺少游戏配置,请先提交构建并生成一次测试二维码,再启动本地预览。");
66248
66547
  return { projectId: project.project_id, version: latest.version };
66249
66548
  }
@@ -66255,9 +66554,13 @@ function previewNetworkArgs(server) {
66255
66554
  "-directConnectParams=" + Buffer.from(JSON.stringify(server)).toString("base64")
66256
66555
  ];
66257
66556
  }
66258
- async function preparePreviewServer(source, projectPath, signal) {
66557
+ async function preparePreviewServer(source, projectPath, signal, networkRequired = false) {
66259
66558
  const project = previewNetworkProject(source);
66260
- if (!project) return void 0;
66559
+ if (!project) {
66560
+ if (networkRequired)
66561
+ throw new Error("项目已识别为联机/server 项目,但准备副本未保留有效联机配置。");
66562
+ return void 0;
66563
+ }
66261
66564
  if (signal == null ? void 0 : signal.aborted) throw new Error("CANCELLED");
66262
66565
  if (getMakerEnvironment(void 0, projectPath) !== "production")
66263
66566
  throw new Error("当前环境暂不支持联网本地预览;请使用网页预览。");
@@ -66378,46 +66681,14 @@ function requestPreviewServer(project, auth2, signal, options3 = {}) {
66378
66681
  });
66379
66682
  }
66380
66683
 
66381
- // src/maker/preview/sourceAlias.ts
66382
- import fs30 from "node:fs";
66383
- import os5 from "node:os";
66384
- import path31 from "node:path";
66385
- function createPreviewSourceAlias(source, platform = process.platform, temporaryDirectory = os5.tmpdir()) {
66386
- if (platform !== "win32") return { source, close: () => {
66387
- } };
66388
- const target = fs30.realpathSync(source);
66389
- const directory = fs30.mkdtempSync(path31.join(temporaryDirectory, "maker-preview-"));
66390
- const alias = path31.join(directory, "source");
66391
- try {
66392
- if (alias.length > 180)
66393
- throw new Error("Windows preview needs a shorter TEMP directory (Runtime path limit).");
66394
- fs30.symlinkSync(target, alias, "junction");
66395
- } catch (error2) {
66396
- fs30.rmdirSync(directory);
66397
- throw error2;
66398
- }
66399
- let closed = false;
66400
- return {
66401
- source: alias,
66402
- close: () => {
66403
- if (closed) return;
66404
- if (!fs30.lstatSync(alias).isSymbolicLink() || fs30.realpathSync(alias) !== target)
66405
- throw new Error("Preview source alias changed; refusing cleanup.");
66406
- fs30.unlinkSync(alias);
66407
- fs30.rmdirSync(directory);
66408
- closed = true;
66409
- }
66410
- };
66411
- }
66412
-
66413
66684
  // src/maker/preview/runtime.ts
66414
66685
  var PREVIEW_TIMEOUT_MS = 3e4;
66415
66686
  var RUNTIME_STARTUP_SETTLE_MS = 3e3;
66416
66687
  async function probeRuntime(executable, signal) {
66417
66688
  if (signal == null ? void 0 : signal.aborted) throw new Error("CANCELLED");
66418
- if (!path32.isAbsolute(executable) || !fs31.statSync(executable).isFile())
66689
+ if (!path31.isAbsolute(executable) || !fs30.statSync(executable).isFile())
66419
66690
  throw new Error("Runtime must be an absolute executable file.");
66420
- fs31.accessSync(executable, process.platform === "win32" ? fs31.constants.R_OK : fs31.constants.X_OK);
66691
+ fs30.accessSync(executable, process.platform === "win32" ? fs30.constants.R_OK : fs30.constants.X_OK);
66421
66692
  return {
66422
66693
  protocol_version: 0,
66423
66694
  runtime_version: "unknown",
@@ -66432,7 +66703,7 @@ async function preflightPreview(_executable, project, signal) {
66432
66703
  entry: projectEntry(project),
66433
66704
  window: previewWindow(project),
66434
66705
  source_mode: false,
66435
- preparation_required: true,
66706
+ ...classifyPreviewProject(project),
66436
66707
  dependencies_verified: false,
66437
66708
  warning: "Local client preview only. Cloud/server features and resource completeness are not verified."
66438
66709
  };
@@ -66449,6 +66720,7 @@ var PreviewRuntime = class {
66449
66720
  this.stopping = false;
66450
66721
  this.abort = new AbortController();
66451
66722
  this.closed = Promise.resolve();
66723
+ this.mode = "local_manifest";
66452
66724
  this.errors = [];
66453
66725
  this.artifacts = [];
66454
66726
  this.logs = new PreviewLogs(directory);
@@ -66467,55 +66739,62 @@ var PreviewRuntime = class {
66467
66739
  return false;
66468
66740
  }
66469
66741
  get launchMode() {
66470
- return process.platform === "darwin" ? "loopback_manifest" : "local_manifest";
66742
+ return this.mode;
66471
66743
  }
66472
- async start(entry, storage, window2 = previewWindow(this.identity.project_realpath)) {
66744
+ async start(entry, _storage, window2 = previewWindow(this.identity.project_realpath)) {
66473
66745
  var _a3, _b;
66474
66746
  requireManifestPreviewPlatform();
66475
- this.preparation = await preparePreviewProject(
66476
- this.identity.project_realpath,
66477
- this.directory,
66478
- this.abort.signal
66479
- );
66747
+ const project = this.identity.project_realpath;
66748
+ const classification = classifyPreviewProject(project);
66749
+ const requiresPreparation = classification.preparation_required;
66750
+ if (requiresPreparation)
66751
+ this.preparation = await preparePreviewProject(project, this.directory, this.abort.signal);
66480
66752
  if (this.stopping) throw new Error("CANCELLED");
66481
- const source = String(this.preparation.source_directory);
66482
- entry = String(this.preparation.entry);
66753
+ const source = requiresPreparation ? String(this.preparation.source_directory) : project;
66754
+ if (requiresPreparation) entry = String(this.preparation.entry);
66483
66755
  const server = await preparePreviewServer(
66484
66756
  source,
66485
- this.identity.project_realpath,
66486
- this.abort.signal
66757
+ project,
66758
+ this.abort.signal,
66759
+ classification.network_required
66487
66760
  );
66488
- if (server) this.logs.append("已获取线上测试服连接信息,本地客户端将通过 WebSocket 直连。");
66761
+ if (server) {
66762
+ this.logs.append("已获取线上测试服连接信息,本地客户端将通过 WebSocket 直连。");
66763
+ }
66489
66764
  if (this.stopping) throw new Error("CANCELLED");
66490
66765
  let cacheRoot;
66491
- if (this.launchMode === "loopback_manifest") {
66766
+ if (requiresPreparation) {
66492
66767
  this.assets = await startPreviewAssetServer(source, this.abort.signal);
66493
- cacheRoot = path32.join(storage, "runtime-cache");
66768
+ this.mode = "loopback_manifest";
66494
66769
  try {
66495
- fs31.mkdirSync(cacheRoot, { recursive: true, mode: 448 });
66496
- this.assetCache = path32.join(
66497
- fs31.realpathSync(cacheRoot),
66770
+ cacheRoot = process.platform === "win32" ? this.temporaryCache = fs30.realpathSync(
66771
+ fs30.mkdtempSync(path31.join(os5.tmpdir(), "maker-cache-"))
66772
+ ) : path31.join(_storage, "runtime-cache");
66773
+ fs30.mkdirSync(cacheRoot, { recursive: true, mode: 448 });
66774
+ this.assetCache = path31.join(
66775
+ fs30.realpathSync(cacheRoot),
66498
66776
  this.assets.url.slice("http://".length).replace(":", "_")
66499
66777
  );
66500
66778
  } catch (error2) {
66501
66779
  await this.assets.close();
66780
+ this.assets = void 0;
66781
+ this.clearAssetCache();
66502
66782
  throw error2;
66503
66783
  }
66504
66784
  }
66505
66785
  if (this.stopping) {
66506
66786
  await ((_a3 = this.assets) == null ? void 0 : _a3.close());
66787
+ this.clearAssetCache();
66507
66788
  throw new Error("CANCELLED");
66508
66789
  }
66509
66790
  let child;
66510
66791
  try {
66511
- this.sourceAlias = createPreviewSourceAlias(source);
66512
- const runtimeSource = this.sourceAlias.source;
66513
66792
  this.launching();
66793
+ const runtimeArgs = this.assets ? ["-game_url=" + this.assets.url, "-game_path=" + cacheRoot] : [entry, "-tapcode_dir=" + source];
66514
66794
  child = spawn6(
66515
66795
  this.executable,
66516
66796
  [
66517
- ...this.assets ? ["-game_url=" + this.assets.url] : [entry, "-tapcode_dir=" + runtimeSource],
66518
- ...cacheRoot ? ["-game_path=" + cacheRoot] : [],
66797
+ ...runtimeArgs,
66519
66798
  "-skip_login",
66520
66799
  ...server ? previewNetworkArgs(server) : [],
66521
66800
  "-p=Res",
@@ -66523,11 +66802,11 @@ var PreviewRuntime = class {
66523
66802
  "-width=" + window2.width,
66524
66803
  "-height=" + window2.height
66525
66804
  ],
66526
- { cwd: runtimeSource, stdio: ["pipe", "pipe", "pipe"], windowsHide: false }
66805
+ { cwd: source, stdio: ["pipe", "pipe", "pipe"], windowsHide: false }
66527
66806
  );
66528
66807
  } catch (error2) {
66529
66808
  await ((_b = this.assets) == null ? void 0 : _b.close());
66530
- this.clearSourceAlias();
66809
+ this.clearAssetCache();
66531
66810
  throw error2;
66532
66811
  }
66533
66812
  this.child = child;
@@ -66537,11 +66816,10 @@ var PreviewRuntime = class {
66537
66816
  var _a4;
66538
66817
  try {
66539
66818
  await ((_a4 = this.assets) == null ? void 0 : _a4.close());
66819
+ this.clearAssetCache();
66540
66820
  } catch (error2) {
66541
66821
  this.recordError(String(error2));
66542
66822
  }
66543
- this.clearAssetCache();
66544
- this.clearSourceAlias();
66545
66823
  try {
66546
66824
  this.changed(this.stopping || child.exitCode === 0 ? "stopped" : "failed");
66547
66825
  } catch (error2) {
@@ -66613,26 +66891,31 @@ var PreviewRuntime = class {
66613
66891
  if (this.errors.length > 100) this.errors.shift();
66614
66892
  }
66615
66893
  clearAssetCache() {
66894
+ if (this.temporaryCache) {
66895
+ try {
66896
+ if (fs30.existsSync(this.temporaryCache)) {
66897
+ if (fs30.lstatSync(this.temporaryCache).isSymbolicLink() || fs30.realpathSync(this.temporaryCache) !== this.temporaryCache)
66898
+ throw new Error("Preview cache ownership changed.");
66899
+ fs30.rmSync(this.temporaryCache, { recursive: true, force: true });
66900
+ }
66901
+ this.temporaryCache = void 0;
66902
+ this.assetCache = void 0;
66903
+ } catch {
66904
+ this.recordError("Could not remove this round of local preview download cache.");
66905
+ }
66906
+ return;
66907
+ }
66616
66908
  if (!this.assetCache) return;
66617
66909
  try {
66618
- const parent = path32.dirname(this.assetCache);
66619
- if (fs31.existsSync(parent) && fs31.realpathSync(parent) === parent) {
66620
- fs31.rmSync(this.assetCache, { recursive: true, force: true });
66621
- if (!fs31.readdirSync(parent).length) fs31.rmdirSync(parent);
66910
+ const parent = path31.dirname(this.assetCache);
66911
+ if (fs30.existsSync(parent) && fs30.realpathSync(parent) === parent) {
66912
+ fs30.rmSync(this.assetCache, { recursive: true, force: true });
66913
+ if (!fs30.readdirSync(parent).length) fs30.rmdirSync(parent);
66622
66914
  }
66623
66915
  } catch {
66624
66916
  this.recordError("Could not remove this round of local preview download cache.");
66625
66917
  }
66626
66918
  }
66627
- clearSourceAlias() {
66628
- var _a3;
66629
- try {
66630
- (_a3 = this.sourceAlias) == null ? void 0 : _a3.close();
66631
- this.sourceAlias = void 0;
66632
- } catch (error2) {
66633
- this.recordError(String(error2));
66634
- }
66635
- }
66636
66919
  consume(stream) {
66637
66920
  const decoder = new StringDecoder("utf8");
66638
66921
  let buffer = "";
@@ -66667,11 +66950,12 @@ var PreviewRuntime = class {
66667
66950
  };
66668
66951
  }
66669
66952
  async stop() {
66670
- var _a3, _b;
66953
+ var _a3;
66671
66954
  this.stopping = true;
66672
66955
  this.abort.abort();
66673
66956
  if (!this.processAlive) {
66674
66957
  await ((_a3 = this.assets) == null ? void 0 : _a3.close());
66958
+ this.clearAssetCache();
66675
66959
  return;
66676
66960
  }
66677
66961
  const child = this.child;
@@ -66693,14 +66977,13 @@ var PreviewRuntime = class {
66693
66977
  } finally {
66694
66978
  clearTimeout(force);
66695
66979
  clearTimeout(deadline);
66696
- await ((_b = this.assets) == null ? void 0 : _b.close());
66697
66980
  }
66698
66981
  }
66699
66982
  };
66700
66983
 
66701
66984
  // src/maker/preview/runtimeResources.ts
66702
- import fs32 from "node:fs";
66703
- import path33 from "node:path";
66985
+ import fs31 from "node:fs";
66986
+ import path32 from "node:path";
66704
66987
  var FALLBACK_FONT = "MiSans-Regular.ttf";
66705
66988
  function defaultFontCandidates(platform) {
66706
66989
  if (platform === "darwin") {
@@ -66712,44 +66995,44 @@ function defaultFontCandidates(platform) {
66712
66995
  if (platform === "win32") {
66713
66996
  const windows = process.env.WINDIR || process.env.SystemRoot || "C:\\Windows";
66714
66997
  return [
66715
- path33.join(windows, "Fonts", "Deng.ttf"),
66716
- path33.join(windows, "Fonts", "Dengb.ttf"),
66717
- path33.join(windows, "Fonts", "msyh.ttc")
66998
+ path32.join(windows, "Fonts", "Deng.ttf"),
66999
+ path32.join(windows, "Fonts", "Dengb.ttf"),
67000
+ path32.join(windows, "Fonts", "msyh.ttc")
66718
67001
  ];
66719
67002
  }
66720
67003
  return [];
66721
67004
  }
66722
67005
  function existingFile(filename2) {
66723
67006
  try {
66724
- return fs32.statSync(filename2).isFile();
67007
+ return fs31.statSync(filename2).isFile();
66725
67008
  } catch {
66726
67009
  return false;
66727
67010
  }
66728
67011
  }
66729
67012
  function ensurePreviewRuntimeResources(executable, options3 = {}) {
66730
- const runtimeRoot = path33.dirname(fs32.realpathSync(executable));
66731
- const fonts = path33.join(runtimeRoot, "Res", "Fonts");
66732
- const legacyFonts = path33.join(runtimeRoot, "Data", "Fonts");
67013
+ const runtimeRoot = path32.dirname(fs31.realpathSync(executable));
67014
+ const fonts = path32.join(runtimeRoot, "Res", "Fonts");
67015
+ const legacyFonts = path32.join(runtimeRoot, "Data", "Fonts");
66733
67016
  for (const directory of [
66734
- path33.join(runtimeRoot, "Data", "LuaScripts"),
67017
+ path32.join(runtimeRoot, "Data", "LuaScripts"),
66735
67018
  legacyFonts,
66736
67019
  fonts,
66737
- path33.join(runtimeRoot, "CoreData")
67020
+ path32.join(runtimeRoot, "CoreData")
66738
67021
  ]) {
66739
- fs32.mkdirSync(directory, { recursive: true });
67022
+ fs31.mkdirSync(directory, { recursive: true });
66740
67023
  }
66741
- const target = path33.join(fonts, FALLBACK_FONT);
66742
- if (fs32.existsSync(target)) return { fallbackFont: "existing", warnings: [] };
67024
+ const target = path32.join(fonts, FALLBACK_FONT);
67025
+ if (fs31.existsSync(target)) return { fallbackFont: "existing", warnings: [] };
66743
67026
  const platform = options3.platform || process.platform;
66744
67027
  const candidates = [
66745
- path33.join(legacyFonts, FALLBACK_FONT),
67028
+ path32.join(legacyFonts, FALLBACK_FONT),
66746
67029
  ...options3.fontCandidates || defaultFontCandidates(platform)
66747
67030
  ];
66748
67031
  const copyErrors = [];
66749
67032
  for (const candidate of candidates) {
66750
67033
  if (!existingFile(candidate)) continue;
66751
67034
  try {
66752
- fs32.copyFileSync(candidate, target, fs32.constants.COPYFILE_EXCL);
67035
+ fs31.copyFileSync(candidate, target, fs31.constants.COPYFILE_EXCL);
66753
67036
  return { fallbackFont: "copied", fallbackFontSource: candidate, warnings: [] };
66754
67037
  } catch (error2) {
66755
67038
  if (error2.code === "EEXIST") {
@@ -66983,10 +67266,10 @@ function processPresence(pid) {
66983
67266
 
66984
67267
  // src/maker/preview/installation.ts
66985
67268
  function readInstallation(filename2) {
66986
- if (!fs33.existsSync(filename2)) return void 0;
67269
+ if (!fs32.existsSync(filename2)) return void 0;
66987
67270
  try {
66988
- const value = JSON.parse(fs33.readFileSync(filename2, "utf8"));
66989
- if (value.install_state !== "ready" || !value.executable || !path34.isAbsolute(value.executable) || !fs33.statSync(value.executable).isFile()) {
67271
+ const value = JSON.parse(fs32.readFileSync(filename2, "utf8"));
67272
+ if (value.install_state !== "ready" || !value.executable || !path33.isAbsolute(value.executable) || !fs32.statSync(value.executable).isFile()) {
66990
67273
  return void 0;
66991
67274
  }
66992
67275
  return value;
@@ -66995,27 +67278,27 @@ function readInstallation(filename2) {
66995
67278
  }
66996
67279
  }
66997
67280
  function isInside(directory, filename2) {
66998
- const relative = path34.relative(directory, filename2);
66999
- return relative !== "" && !relative.startsWith(".." + path34.sep) && !path34.isAbsolute(relative);
67281
+ const relative = path33.relative(directory, filename2);
67282
+ return relative !== "" && !relative.startsWith(".." + path33.sep) && !path33.isAbsolute(relative);
67000
67283
  }
67001
67284
  function legacyPreviewInstallation(project) {
67002
67285
  var _a3;
67003
- const root2 = path34.dirname(previewDirectory(project));
67004
- if (!fs33.existsSync(root2)) return void 0;
67005
- const entries = fs33.readdirSync(root2, { withFileTypes: true }).filter((entry) => entry.isDirectory() && /^[a-f0-9]{64}$/.test(entry.name));
67286
+ const root2 = path33.dirname(previewDirectory(project));
67287
+ if (!fs32.existsSync(root2)) return void 0;
67288
+ const entries = fs32.readdirSync(root2, { withFileTypes: true }).filter((entry) => entry.isDirectory() && /^[a-f0-9]{64}$/.test(entry.name));
67006
67289
  const candidates = [];
67007
67290
  for (const entry of entries) {
67008
- const directory = path34.join(root2, entry.name);
67009
- const filename2 = path34.join(directory, "installation.json");
67291
+ const directory = path33.join(root2, entry.name);
67292
+ const filename2 = path33.join(directory, "installation.json");
67010
67293
  const installation = readInstallation(filename2);
67011
67294
  if (!(installation == null ? void 0 : installation.executable)) continue;
67012
67295
  try {
67013
- const executable = fs33.realpathSync(installation.executable);
67014
- const managedDirectory = fs33.realpathSync(directory);
67296
+ const executable = fs32.realpathSync(installation.executable);
67297
+ const managedDirectory = fs32.realpathSync(directory);
67015
67298
  if (!isInside(managedDirectory, executable)) continue;
67016
67299
  candidates.push({
67017
67300
  installation: { ...installation, executable },
67018
- modified: Date.parse(installation.installed_at || "") || fs33.statSync(filename2).mtimeMs
67301
+ modified: Date.parse(installation.installed_at || "") || fs32.statSync(filename2).mtimeMs
67019
67302
  });
67020
67303
  } catch {
67021
67304
  }
@@ -67024,7 +67307,7 @@ function legacyPreviewInstallation(project) {
67024
67307
  return (_a3 = candidates[0]) == null ? void 0 : _a3.installation;
67025
67308
  }
67026
67309
  function previewInstallation(project) {
67027
- const filename2 = path34.join(runtimeDirectory(), "installation.json");
67310
+ const filename2 = path33.join(runtimeDirectory(), "installation.json");
67028
67311
  const current = readInstallation(filename2);
67029
67312
  if (current) return current;
67030
67313
  const legacy = legacyPreviewInstallation(project);
@@ -67043,31 +67326,31 @@ function previewInstallation(project) {
67043
67326
  }
67044
67327
  }
67045
67328
  async function withFileLock(directory, name, busyMessage, action) {
67046
- fs33.mkdirSync(directory, { recursive: true, mode: 448 });
67047
- const filename2 = path34.join(directory, name);
67329
+ fs32.mkdirSync(directory, { recursive: true, mode: 448 });
67330
+ const filename2 = path33.join(directory, name);
67048
67331
  let descriptor;
67049
67332
  try {
67050
- descriptor = fs33.openSync(filename2, "wx", 384);
67333
+ descriptor = fs32.openSync(filename2, "wx", 384);
67051
67334
  } catch {
67052
67335
  throw new Error(
67053
67336
  busyMessage + " If an interrupted command left a lock, verify it exited before removing " + filename2
67054
67337
  );
67055
67338
  }
67056
67339
  try {
67057
- fs33.writeFileSync(
67340
+ fs32.writeFileSync(
67058
67341
  descriptor,
67059
67342
  JSON.stringify({ pid: process.pid, created_at: (/* @__PURE__ */ new Date()).toISOString() })
67060
67343
  );
67061
67344
  return await action();
67062
67345
  } finally {
67063
- fs33.closeSync(descriptor);
67064
- fs33.unlinkSync(filename2);
67346
+ fs32.closeSync(descriptor);
67347
+ fs32.unlinkSync(filename2);
67065
67348
  }
67066
67349
  }
67067
67350
  async function withPreviewLock(project, action) {
67068
67351
  const directory = previewDirectory(project);
67069
- fs33.mkdirSync(directory, { recursive: true, mode: 448 });
67070
- const filename2 = path34.join(fs33.realpathSync(directory), "operation.lock");
67352
+ fs32.mkdirSync(directory, { recursive: true, mode: 448 });
67353
+ const filename2 = path33.join(fs32.realpathSync(directory), "operation.lock");
67071
67354
  const busy = () => new Error("Another preview operation is in progress. Please retry after it finishes.");
67072
67355
  const release = await claimRecoveryMutex(filename2, busy);
67073
67356
  const identity = JSON.stringify({
@@ -67077,8 +67360,8 @@ async function withPreviewLock(project, action) {
67077
67360
  });
67078
67361
  let owned = false;
67079
67362
  try {
67080
- if (fs33.existsSync(filename2)) {
67081
- const previous = fs33.readFileSync(filename2, "utf8");
67363
+ if (fs32.existsSync(filename2)) {
67364
+ const previous = fs32.readFileSync(filename2, "utf8");
67082
67365
  let pid;
67083
67366
  try {
67084
67367
  pid = JSON.parse(previous).pid;
@@ -67088,9 +67371,9 @@ async function withPreviewLock(project, action) {
67088
67371
  throw new Error(
67089
67372
  "Preview operation ownership is still active or unverified. Confirm the previous command has exited before removing only: " + filename2
67090
67373
  );
67091
- fs33.unlinkSync(filename2);
67374
+ fs32.unlinkSync(filename2);
67092
67375
  }
67093
- fs33.writeFileSync(filename2, identity, { flag: "wx", mode: 384 });
67376
+ fs32.writeFileSync(filename2, identity, { flag: "wx", mode: 384 });
67094
67377
  owned = true;
67095
67378
  return await action();
67096
67379
  } finally {
@@ -67103,7 +67386,7 @@ async function withPreviewLock(project, action) {
67103
67386
  }
67104
67387
  function removeOwnedPreviewLock(filename2, identity) {
67105
67388
  try {
67106
- if (fs33.readFileSync(filename2, "utf8") === identity) fs33.unlinkSync(filename2);
67389
+ if (fs32.readFileSync(filename2, "utf8") === identity) fs32.unlinkSync(filename2);
67107
67390
  } catch (error2) {
67108
67391
  if (error2.code !== "ENOENT") throw error2;
67109
67392
  }
@@ -67117,17 +67400,17 @@ async function withRuntimeInstallLock(action) {
67117
67400
  );
67118
67401
  }
67119
67402
  function activePreviewRuntimeDirectories(project) {
67120
- const root2 = path34.dirname(previewDirectory(project));
67121
- if (!fs33.existsSync(root2)) return [];
67403
+ const root2 = path33.dirname(previewDirectory(project));
67404
+ if (!fs32.existsSync(root2)) return [];
67122
67405
  const protectedDirectories = [];
67123
- for (const entry of fs33.readdirSync(root2, { withFileTypes: true })) {
67406
+ for (const entry of fs32.readdirSync(root2, { withFileTypes: true })) {
67124
67407
  if (!entry.isDirectory() || !/^[a-f0-9]{64}$/.test(entry.name)) continue;
67125
- const filename2 = path34.join(root2, entry.name, "session.json");
67126
- if (!fs33.existsSync(filename2)) continue;
67408
+ const filename2 = path33.join(root2, entry.name, "session.json");
67409
+ if (!fs32.existsSync(filename2)) continue;
67127
67410
  try {
67128
- const record2 = JSON.parse(fs33.readFileSync(filename2, "utf8"));
67129
- if (record2.state !== "stopped" && record2.executable && path34.isAbsolute(record2.executable)) {
67130
- protectedDirectories.push(path34.dirname(record2.executable));
67411
+ const record2 = JSON.parse(fs32.readFileSync(filename2, "utf8"));
67412
+ if (record2.state !== "stopped" && record2.executable && path33.isAbsolute(record2.executable)) {
67413
+ protectedDirectories.push(path33.dirname(record2.executable));
67131
67414
  }
67132
67415
  } catch {
67133
67416
  }
@@ -67153,12 +67436,12 @@ async function installPreviewRuntime(project, signal, update = false) {
67153
67436
  }
67154
67437
  }
67155
67438
  const directory = runtimeDirectory();
67156
- const unresolved = fs33.existsSync(directory) && fs33.readdirSync(directory, { withFileTypes: true }).find(
67157
- (entry) => entry.isDirectory() && entry.name.startsWith("runtime-") && fs33.existsSync(path34.join(directory, entry.name, UNVERIFIED_CLEANUP_MARKER))
67439
+ const unresolved = fs32.existsSync(directory) && fs32.readdirSync(directory, { withFileTypes: true }).find(
67440
+ (entry) => entry.isDirectory() && entry.name.startsWith("runtime-") && fs32.existsSync(path33.join(directory, entry.name, UNVERIFIED_CLEANUP_MARKER))
67158
67441
  );
67159
67442
  if (unresolved) {
67160
67443
  throw new Error(
67161
- "The previous installer cleanup is unverified. Confirm its processes have exited before removing only the marked directory: " + path34.join(directory, unresolved.name)
67444
+ "The previous installer cleanup is unverified. Confirm its processes have exited before removing only the marked directory: " + path33.join(directory, unresolved.name)
67162
67445
  );
67163
67446
  }
67164
67447
  const python = checkMakerPythonEnvironment();
@@ -67167,10 +67450,10 @@ async function installPreviewRuntime(project, signal, update = false) {
67167
67450
  "Runtime installation needs Python and curl. Run taptap-maker python setup with host approval, then retry."
67168
67451
  );
67169
67452
  }
67170
- const staging = path34.join(directory, "runtime-" + randomUUID5());
67171
- fs33.mkdirSync(staging, { recursive: true, mode: 448 });
67172
- const installer = path34.join(staging, "install-urhox-runtime.py");
67173
- fs33.writeFileSync(installer, PREVIEW_INSTALLER_SOURCE, { mode: 384 });
67453
+ const staging = path33.join(directory, "runtime-" + randomUUID5());
67454
+ fs32.mkdirSync(staging, { recursive: true, mode: 448 });
67455
+ const installer = path33.join(staging, "install-urhox-runtime.py");
67456
+ fs32.writeFileSync(installer, PREVIEW_INSTALLER_SOURCE, { mode: 384 });
67174
67457
  const platform = process.platform === "win32" ? "win32" : "darwin";
67175
67458
  try {
67176
67459
  await runPreviewInstaller(
@@ -67183,14 +67466,14 @@ async function installPreviewRuntime(project, signal, update = false) {
67183
67466
  signal
67184
67467
  }
67185
67468
  );
67186
- const executable = fs33.realpathSync(
67187
- path34.join(staging, platform === "win32" ? "UrhoXRuntime.exe" : "UrhoXRuntime")
67469
+ const executable = fs32.realpathSync(
67470
+ path33.join(staging, platform === "win32" ? "UrhoXRuntime.exe" : "UrhoXRuntime")
67188
67471
  );
67189
67472
  const resources2 = ensurePreviewRuntimeResources(executable);
67190
67473
  const runtime = await probeRuntime(executable, signal);
67191
- const archive = path34.join(staging, "UrhoXRuntime.zip");
67474
+ const archive = path33.join(staging, "UrhoXRuntime.zip");
67192
67475
  const hash2 = createHash5("sha256");
67193
- for await (const chunk of fs33.createReadStream(archive)) hash2.update(chunk);
67476
+ for await (const chunk of fs32.createReadStream(archive)) hash2.update(chunk);
67194
67477
  const installation = {
67195
67478
  install_state: "ready",
67196
67479
  executable,
@@ -67200,19 +67483,19 @@ async function installPreviewRuntime(project, signal, update = false) {
67200
67483
  warnings: resources2.warnings
67201
67484
  };
67202
67485
  const protectedDirectories = [staging, ...activePreviewRuntimeDirectories(project)];
67203
- if (previous.executable) protectedDirectories.push(path34.dirname(previous.executable));
67486
+ if (previous.executable) protectedDirectories.push(path33.dirname(previous.executable));
67204
67487
  installation.warnings = [
67205
67488
  ...installation.warnings || [],
67206
67489
  ...trimPreviewCache(directory, "runtime-", 2, protectedDirectories)
67207
67490
  ];
67208
- writePrivateJson(path34.join(directory, "installation.json"), installation);
67491
+ writePrivateJson(path33.join(directory, "installation.json"), installation);
67209
67492
  return installation;
67210
67493
  } catch (error2) {
67211
67494
  const cleanupUnverified = error2.cleanupVerified === false;
67212
- if (!cleanupUnverified) fs33.rmSync(staging, { recursive: true, force: true });
67495
+ if (!cleanupUnverified) fs32.rmSync(staging, { recursive: true, force: true });
67213
67496
  else
67214
- fs33.writeFileSync(
67215
- path34.join(staging, UNVERIFIED_CLEANUP_MARKER),
67497
+ fs32.writeFileSync(
67498
+ path33.join(staging, UNVERIFIED_CLEANUP_MARKER),
67216
67499
  "Installer process ownership must be verified before cleanup.\n",
67217
67500
  { mode: 384 }
67218
67501
  );
@@ -67224,12 +67507,16 @@ async function installPreviewRuntime(project, signal, update = false) {
67224
67507
 
67225
67508
  // src/maker/preview/session.ts
67226
67509
  init_protocol2();
67227
- import fs34 from "node:fs";
67228
- import path35 from "node:path";
67510
+ import fs33 from "node:fs";
67511
+ import path34 from "node:path";
67229
67512
  import http2 from "node:http";
67230
67513
  import os6 from "node:os";
67231
67514
  import { timingSafeEqual } from "node:crypto";
67232
67515
  init_diagnosticRedaction();
67516
+ function previewErrorMessage(error2) {
67517
+ const message = error2 instanceof Error ? error2.message : "Unexpected preview error.";
67518
+ return String(sanitizeDiagnosticValue(message));
67519
+ }
67233
67520
  var PreviewSession = class {
67234
67521
  constructor(record2, save = true) {
67235
67522
  this.record = record2;
@@ -67252,10 +67539,22 @@ var PreviewSession = class {
67252
67539
  if ((current == null ? void 0 : current.session_id) !== this.record.session_id || current.supervisor_id !== this.record.supervisor_id)
67253
67540
  return;
67254
67541
  writePrivateJson(
67255
- path35.join(previewDirectory(this.record.project_realpath), "session.json"),
67542
+ path34.join(previewDirectory(this.record.project_realpath), "session.json"),
67256
67543
  this.record
67257
67544
  );
67258
- writePrivateJson(path35.join(previewRoundDirectory(this.record), "result.json"), this.status());
67545
+ writePrivateJson(path34.join(previewRoundDirectory(this.record), "result.json"), this.status());
67546
+ }
67547
+ }
67548
+ setTerminalState(state) {
67549
+ var _a3;
67550
+ try {
67551
+ this.setState(state);
67552
+ return true;
67553
+ } catch (error2) {
67554
+ const message = previewErrorMessage(error2);
67555
+ if (!((_a3 = this.failure) == null ? void 0 : _a3.includes(message)))
67556
+ this.failure = [this.failure, "Preview state persistence failed: " + message].filter(Boolean).join("; ");
67557
+ return false;
67259
67558
  }
67260
67559
  }
67261
67560
  status() {
@@ -67275,7 +67574,7 @@ var PreviewSession = class {
67275
67574
  executable: this.record.executable,
67276
67575
  runtime_version: this.record.runtime.runtime_version,
67277
67576
  capabilities: this.record.runtime.capabilities,
67278
- launch_mode: ((_c = this.runtime) == null ? void 0 : _c.launchMode) ?? (process.platform === "darwin" ? "loopback_manifest" : "local_manifest"),
67577
+ launch_mode: ((_c = this.runtime) == null ? void 0 : _c.launchMode) ?? "local_manifest",
67279
67578
  preparation: (_d = this.runtime) == null ? void 0 : _d.preparation,
67280
67579
  ready: false,
67281
67580
  screenshots_supported: false,
@@ -67332,8 +67631,8 @@ var PreviewSession = class {
67332
67631
  async launch(reload) {
67333
67632
  var _a3;
67334
67633
  this.failure = void 0;
67335
- this.setState(reload ? "reloading" : "starting");
67336
67634
  try {
67635
+ this.setState(reload ? "reloading" : "starting");
67337
67636
  if (reload) {
67338
67637
  await ((_a3 = this.runtime) == null ? void 0 : _a3.stop());
67339
67638
  this.runtime = void 0;
@@ -67359,7 +67658,8 @@ var PreviewSession = class {
67359
67658
  (state) => {
67360
67659
  if (this.runtime !== runtime || this.stopping) return;
67361
67660
  if (state === "stopped" && this.record.state === "reloading") return;
67362
- this.setState(state);
67661
+ if (state === "running") this.setState(state);
67662
+ else this.setTerminalState(state);
67363
67663
  },
67364
67664
  void 0,
67365
67665
  (pid) => {
@@ -67370,7 +67670,7 @@ var PreviewSession = class {
67370
67670
  this.runtime = runtime;
67371
67671
  await runtime.start(
67372
67672
  String(this.preflight.entry),
67373
- path35.join(previewDirectory(this.record.project_realpath), "storage"),
67673
+ path34.join(previewDirectory(this.record.project_realpath), "storage"),
67374
67674
  this.preflight.window
67375
67675
  );
67376
67676
  if (this.stopping) throw new Error("CANCELLED");
@@ -67379,8 +67679,8 @@ var PreviewSession = class {
67379
67679
  ...reload ? { warning: "Preview restarted; in-memory game state was lost." } : {}
67380
67680
  };
67381
67681
  } catch (error2) {
67382
- this.failure = String(sanitizeDiagnosticValue(String(error2)));
67383
- this.setState(this.stopping ? "stopped" : "failed");
67682
+ this.failure = previewErrorMessage(error2);
67683
+ this.setTerminalState(this.stopping ? "stopped" : "failed");
67384
67684
  return {
67385
67685
  ...this.status(),
67386
67686
  ok: false,
@@ -67389,7 +67689,7 @@ var PreviewSession = class {
67389
67689
  } finally {
67390
67690
  try {
67391
67691
  trimPreviewEvidence(
67392
- path35.join(previewDirectory(this.record.project_realpath), "sessions"),
67692
+ path34.join(previewDirectory(this.record.project_realpath), "sessions"),
67393
67693
  this.record.session_id,
67394
67694
  this.record.reload_id
67395
67695
  );
@@ -67407,14 +67707,14 @@ var PreviewSession = class {
67407
67707
  await ((_a3 = this.runtime) == null ? void 0 : _a3.stop());
67408
67708
  await this.operation;
67409
67709
  } catch (error2) {
67410
- this.failure = String(sanitizeDiagnosticValue(String(error2)));
67411
- this.setState("failed");
67710
+ this.failure = previewErrorMessage(error2);
67711
+ this.setTerminalState("failed");
67412
67712
  return { ...this.status(), ok: false, result: "TIMEOUT" };
67413
67713
  } finally {
67414
67714
  this.pendingStops--;
67415
67715
  }
67416
- this.setState("stopped");
67417
- return { ...this.status(), ok: true };
67716
+ const persisted = this.setTerminalState("stopped");
67717
+ return { ...this.status(), ok: persisted };
67418
67718
  }
67419
67719
  async handle(action, options3 = {}, signal) {
67420
67720
  var _a3, _b, _c, _d;
@@ -67538,32 +67838,33 @@ async function runPreviewSupervisor(project, sessionId) {
67538
67838
  const shutdown = async (retireFailure = false) => {
67539
67839
  if (shuttingDown || retireFailure && !session.canRetireFailure) return;
67540
67840
  shuttingDown = true;
67541
- if (!retireFailure) {
67542
- const result = await session.stop();
67543
- if (!result.ok) {
67544
- shuttingDown = false;
67545
- return;
67841
+ try {
67842
+ if (!retireFailure) {
67843
+ const result = await session.stop();
67844
+ if (!result.ok && (result.state !== "stopped" || result.process_alive !== false)) return;
67546
67845
  }
67547
- }
67548
- clearInterval(idleTimer);
67549
- clearTimeout(closeTimer);
67550
- await new Promise((resolve) => {
67551
- server.close(() => resolve());
67552
- server.closeIdleConnections();
67553
- });
67554
- process.removeListener("SIGINT", onSignal);
67555
- process.removeListener("SIGTERM", onSignal);
67556
- if (retireFailure && session.canRetireFailure) {
67557
- try {
67558
- const current = readPreviewRecord(project);
67559
- if ((current == null ? void 0 : current.session_id) === record2.session_id && current.supervisor_id === record2.supervisor_id && current.reload_id === record2.reload_id) {
67560
- writePrivateJson(path35.join(previewRoundDirectory(record2), "result.json"), {
67561
- ...session.status(),
67562
- supervisor_retired: true
67563
- });
67846
+ clearInterval(idleTimer);
67847
+ clearTimeout(closeTimer);
67848
+ await new Promise((resolve) => {
67849
+ server.close(() => resolve());
67850
+ server.closeIdleConnections();
67851
+ });
67852
+ process.removeListener("SIGINT", onSignal);
67853
+ process.removeListener("SIGTERM", onSignal);
67854
+ if (retireFailure && session.canRetireFailure) {
67855
+ try {
67856
+ const current = readPreviewRecord(project);
67857
+ if ((current == null ? void 0 : current.session_id) === record2.session_id && current.supervisor_id === record2.supervisor_id && current.reload_id === record2.reload_id) {
67858
+ writePrivateJson(path34.join(previewRoundDirectory(record2), "result.json"), {
67859
+ ...session.status(),
67860
+ supervisor_retired: true
67861
+ });
67862
+ }
67863
+ } catch {
67564
67864
  }
67565
- } catch {
67566
67865
  }
67866
+ } finally {
67867
+ shuttingDown = false;
67567
67868
  }
67568
67869
  };
67569
67870
  const onSignal = () => {
@@ -67610,7 +67911,7 @@ async function runPreviewSupervisor(project, sessionId) {
67610
67911
  JSON.stringify({
67611
67912
  ...session.status(),
67612
67913
  ok: false,
67613
- error: String(sanitizeDiagnosticValue(String(error2)))
67914
+ error: previewErrorMessage(error2)
67614
67915
  })
67615
67916
  );
67616
67917
  }
@@ -67634,7 +67935,7 @@ async function runPreviewSupervisor(project, sessionId) {
67634
67935
  record2.supervisor_pid = process.pid;
67635
67936
  record2.runtime_pid = 0;
67636
67937
  record2.runtime_launch_pending = false;
67637
- writePrivateJson(path35.join(previewDirectory(project), "session.json"), record2);
67938
+ writePrivateJson(path34.join(previewDirectory(project), "session.json"), record2);
67638
67939
  const idleTimer = setInterval(() => {
67639
67940
  if (record2.state === "stopped") void shutdown();
67640
67941
  else if (session.canRetireFailure) void shutdown(true);
@@ -67668,10 +67969,10 @@ async function previewStatus(project) {
67668
67969
  };
67669
67970
  } catch {
67670
67971
  const stopped = record2.state === "stopped";
67671
- const filename2 = path35.join(previewRoundDirectory(record2), "result.json");
67972
+ const filename2 = path34.join(previewRoundDirectory(record2), "result.json");
67672
67973
  let evidence = {};
67673
- if (fs34.existsSync(filename2)) {
67674
- const saved = JSON.parse(fs34.readFileSync(filename2, "utf8"));
67974
+ if (fs33.existsSync(filename2)) {
67975
+ const saved = JSON.parse(fs33.readFileSync(filename2, "utf8"));
67675
67976
  if (samePreviewIdentity(saved, record2)) {
67676
67977
  evidence = { ...saved };
67677
67978
  delete evidence.token;
@@ -67726,8 +68027,8 @@ init_diagnosticRedaction();
67726
68027
 
67727
68028
  // src/maker/system/backgroundProcess.ts
67728
68029
  import { spawn as spawn8 } from "node:child_process";
67729
- import fs35 from "node:fs";
67730
- import path36 from "node:path";
68030
+ import fs34 from "node:fs";
68031
+ import path35 from "node:path";
67731
68032
  var WINDOWS_ENV_KEYS = /* @__PURE__ */ new Set([
67732
68033
  "APPDATA",
67733
68034
  "COMSPEC",
@@ -67762,9 +68063,9 @@ var WINDOWS_ENV_KEYS = /* @__PURE__ */ new Set([
67762
68063
  "WINDIR"
67763
68064
  ]);
67764
68065
  function openBackgroundProcessLog(filename2) {
67765
- fs35.mkdirSync(path36.dirname(filename2), { recursive: true, mode: 448 });
67766
- const oversized = fs35.existsSync(filename2) && fs35.statSync(filename2).size > 1024 * 1024;
67767
- return fs35.openSync(filename2, oversized ? "w" : "a", 384);
68066
+ fs34.mkdirSync(path35.dirname(filename2), { recursive: true, mode: 448 });
68067
+ const oversized = fs34.existsSync(filename2) && fs34.statSync(filename2).size > 1024 * 1024;
68068
+ return fs34.openSync(filename2, oversized ? "w" : "a", 384);
67768
68069
  }
67769
68070
  function selectWindowsBackgroundEnvironment(env) {
67770
68071
  return Object.fromEntries(
@@ -67806,7 +68107,7 @@ async function launchBackgroundProcess(options3) {
67806
68107
  var _a3, _b, _c;
67807
68108
  if ((_a3 = options3.signal) == null ? void 0 : _a3.aborted) throw new Error("CANCELLED: background launch.");
67808
68109
  if ((options3.platform ?? process.platform) !== "win32") return directLaunch(options3);
67809
- fs35.closeSync(openBackgroundProcessLog(options3.logFile));
68110
+ fs34.closeSync(openBackgroundProcessLog(options3.logFile));
67810
68111
  const scripts = buildWindowsBackgroundLaunchScripts(options3);
67811
68112
  const broker = spawn8(
67812
68113
  "powershell.exe",
@@ -67879,7 +68180,7 @@ function directLaunch(options3) {
67879
68180
  env: options3.env
67880
68181
  });
67881
68182
  } finally {
67882
- fs35.closeSync(stderr);
68183
+ fs34.closeSync(stderr);
67883
68184
  }
67884
68185
  let launchFailure;
67885
68186
  child.once("error", (error2) => {
@@ -67983,7 +68284,7 @@ async function runPreviewCli(action, options3) {
67983
68284
  );
67984
68285
  } else {
67985
68286
  if (action === "stop") {
67986
- writePrivateJson(path37.join(previewDirectory(project), "stop.json"), {
68287
+ writePrivateJson(path36.join(previewDirectory(project), "stop.json"), {
67987
68288
  request_id: randomUUID6()
67988
68289
  });
67989
68290
  }
@@ -68062,8 +68363,8 @@ async function runPreviewCli(action, options3) {
68062
68363
  process.exitCode = 1;
68063
68364
  }
68064
68365
  async function startPreview(project, options3, signal) {
68065
- const stopFile = path37.join(previewDirectory(project), "stop.json");
68066
- const readStop = () => fs36.existsSync(stopFile) ? fs36.readFileSync(stopFile, "utf8") : "";
68366
+ const stopFile = path36.join(previewDirectory(project), "stop.json");
68367
+ const readStop = () => fs35.existsSync(stopFile) ? fs35.readFileSync(stopFile, "utf8") : "";
68067
68368
  const stopGeneration = readStop();
68068
68369
  const checkCancelled = () => {
68069
68370
  if (signal.aborted || readStop() !== stopGeneration)
@@ -68097,9 +68398,9 @@ async function startPreview(project, options3, signal) {
68097
68398
  install_state: "missing",
68098
68399
  error: "Runtime is missing. With host approval, run taptap-maker preview install --target-dir <PROJECT_ABSOLUTE_PATH>, then retry start."
68099
68400
  };
68100
- if (!path37.isAbsolute(configured))
68401
+ if (!path36.isAbsolute(configured))
68101
68402
  throw new Error("--runtime must be an absolute executable path.");
68102
- const executable = fs36.realpathSync(configured);
68403
+ const executable = fs35.realpathSync(configured);
68103
68404
  const resourceWarnings = externalRuntime ? [] : ensurePreviewRuntimeResources(executable).warnings;
68104
68405
  const runtime = await probeRuntime(executable, signal);
68105
68406
  checkCancelled();
@@ -68119,14 +68420,14 @@ async function startPreview(project, options3, signal) {
68119
68420
  state: "starting",
68120
68421
  runtime
68121
68422
  };
68122
- writePrivateJson(path37.join(previewDirectory(project), "session.json"), record2);
68423
+ writePrivateJson(path36.join(previewDirectory(project), "session.json"), record2);
68123
68424
  const launch = await launchPreviewSupervisorProcess({
68124
68425
  execPath: process.execPath,
68125
68426
  execArgv: process.execArgv,
68126
68427
  entry: process.argv[1],
68127
68428
  project,
68128
68429
  sessionId: record2.session_id,
68129
- cwd: path37.dirname(executable),
68430
+ cwd: path36.dirname(executable),
68130
68431
  logFile: previewSupervisorLogPath(project),
68131
68432
  env: process.env,
68132
68433
  signal
@@ -68171,7 +68472,7 @@ async function startPreview(project, options3, signal) {
68171
68472
  } else {
68172
68473
  if (launch.stopUnpublished()) {
68173
68474
  record2.state = "stopped";
68174
- writePrivateJson(path37.join(previewDirectory(project), "session.json"), record2);
68475
+ writePrivateJson(path36.join(previewDirectory(project), "session.json"), record2);
68175
68476
  } else {
68176
68477
  throw new Error(
68177
68478
  String(error2) + "; supervisor exit is unverified. Inspect " + previewSupervisorLogPath(project)
@@ -68186,7 +68487,7 @@ async function startPreview(project, options3, signal) {
68186
68487
  import fs44 from "node:fs";
68187
68488
  import path46 from "node:path";
68188
68489
  import { spawn as spawn11 } from "node:child_process";
68189
- import { createHash as createHash8, randomUUID as randomUUID8 } from "node:crypto";
68490
+ import { createHash as createHash9, randomUUID as randomUUID8 } from "node:crypto";
68190
68491
  init_storage();
68191
68492
  init_projectRegistry();
68192
68493
  init_privateJson();
@@ -68197,8 +68498,8 @@ init_projectSettings();
68197
68498
  init_qrcodePreflight();
68198
68499
  init_qrcodeInteraction();
68199
68500
  init_git();
68200
- import fs37 from "node:fs";
68201
- import path38 from "node:path";
68501
+ import fs36 from "node:fs";
68502
+ import path37 from "node:path";
68202
68503
  import { execFile as execFile2 } from "node:child_process";
68203
68504
  import { promisify as promisify2 } from "node:util";
68204
68505
 
@@ -68222,17 +68523,17 @@ var ConsoleError = class extends Error {
68222
68523
  // src/maker/console/projects.ts
68223
68524
  var exec = promisify2(execFile2);
68224
68525
  function objectFile2(filename2) {
68225
- const stat = fs37.statSync(filename2);
68526
+ const stat = fs36.statSync(filename2);
68226
68527
  if (!stat.isFile() || stat.size > 2 * 1024 * 1024)
68227
68528
  throw new ConsoleError("Project configuration exceeds the supported size.");
68228
- const data = JSON.parse(fs37.readFileSync(filename2, "utf8"));
68529
+ const data = JSON.parse(fs36.readFileSync(filename2, "utf8"));
68229
68530
  if (!data || typeof data !== "object" || Array.isArray(data))
68230
68531
  throw new ConsoleError("Invalid project configuration.");
68231
68532
  return data;
68232
68533
  }
68233
68534
  function optionalConfig(root2, file3) {
68234
68535
  try {
68235
- return objectFile2(path38.join(root2, ".project", file3));
68536
+ return objectFile2(path37.join(root2, ".project", file3));
68236
68537
  } catch {
68237
68538
  return {};
68238
68539
  }
@@ -68275,7 +68576,7 @@ var ConsoleProjects = class {
68275
68576
  const error2 = entry.error;
68276
68577
  const config2 = error2 ? {} : optionalConfig(entry.path, "project.json");
68277
68578
  const title = (_b = text((_a3 = config2.taptap_publish) == null ? void 0 : _a3.title)) == null ? void 0 : _b.trim();
68278
- const name = title && title !== "<game title, required>" ? title : path38.basename(entry.path) + (error2 ? "" : "(未发布)");
68579
+ const name = title && title !== "<game title, required>" ? title : path37.basename(entry.path) + (error2 ? "" : "(未发布)");
68279
68580
  return {
68280
68581
  key: entry.key,
68281
68582
  projectid: entry.binding,
@@ -68311,7 +68612,7 @@ var ConsoleProjects = class {
68311
68612
  const entry = config2["entry@server"] || resources2["entry@server"];
68312
68613
  const normalized = typeof entry === "string" ? entry.replace(/\\/g, "/").replace(/^\.\//, "") : "";
68313
68614
  const entries = normalized ? [normalized, "scripts/" + normalized, "assets/" + normalized] : [];
68314
- const directories = entries.map((file3) => path38.posix.dirname(file3)).filter((dir) => ![".", "scripts", "assets"].includes(dir));
68615
+ const directories = entries.map((file3) => path37.posix.dirname(file3)).filter((dir) => ![".", "scripts", "assets"].includes(dir));
68315
68616
  const raw = (await inspectGit(["status", "--porcelain=v1", "-z", "--untracked-files=all"])).split("\0");
68316
68617
  const files = /* @__PURE__ */ new Set();
68317
68618
  for (let i = 0; i < raw.length && raw[i]; i++) {
@@ -68328,7 +68629,7 @@ var ConsoleProjects = class {
68328
68629
  const meta3 = source + ".meta";
68329
68630
  const current = (() => {
68330
68631
  try {
68331
- return objectFile2(path38.join(project.path, meta3));
68632
+ return objectFile2(path37.join(project.path, meta3));
68332
68633
  } catch {
68333
68634
  return {};
68334
68635
  }
@@ -68498,10 +68799,12 @@ function createConsoleExecutor(options3) {
68498
68799
  signal,
68499
68800
  confirmedOrientation,
68500
68801
  publication,
68501
- confirmedBuild
68802
+ confirmedBuild,
68803
+ reportContext
68502
68804
  }) => {
68503
- if (![...CONSOLE_ACTIONS, "preview.status", "preview.logs"].includes(action))
68805
+ if (![...CONSOLE_ACTIONS, "preview.status", "preview.logs", "issue.report"].includes(action))
68504
68806
  throw new Error("Unsupported console CLI action.");
68807
+ if (action === "issue.report" && !reportContext) throw new Error("Report context is required.");
68505
68808
  if (signal == null ? void 0 : signal.aborted) return { ok: false, error: "Console query cancelled before launch." };
68506
68809
  if (action === "lua-lsp.check") {
68507
68810
  const result = await checkMakerLuaLspProject(project);
@@ -68512,7 +68815,7 @@ function createConsoleExecutor(options3) {
68512
68815
  ...!result.ok ? { error: result.error || result.summary } : {}
68513
68816
  });
68514
68817
  }
68515
- const command = action === "build" || action === "qrcode" ? [action] : ["preview", action.slice("preview.".length)];
68818
+ const command = action === "issue.report" ? ["mcp", "report", "--context-stdin", "--consent"] : action === "build" || action === "qrcode" ? [action] : ["preview", action.slice("preview.".length)];
68516
68819
  if (action === "qrcode" && confirmedOrientation)
68517
68820
  command.push("--confirmed-screen-orientation", confirmedOrientation);
68518
68821
  if (action === "qrcode") {
@@ -68556,9 +68859,14 @@ function createConsoleExecutor(options3) {
68556
68859
  detached: ownsProcessGroup,
68557
68860
  windowsHide: true,
68558
68861
  shell: false,
68559
- stdio: ["ignore", "pipe", "pipe", "ipc"],
68862
+ stdio: [action === "issue.report" ? "pipe" : "ignore", "pipe", "pipe", "ipc"],
68560
68863
  env: { ...process.env, GIT_TERMINAL_PROMPT: "0" }
68561
68864
  });
68865
+ if (action === "issue.report") {
68866
+ child.stdin.on("error", () => {
68867
+ });
68868
+ child.stdin.end(JSON.stringify(reportContext));
68869
+ }
68562
68870
  const childStdout = child.stdout;
68563
68871
  const childStderr = child.stderr;
68564
68872
  let stdout = "";
@@ -68598,7 +68906,7 @@ function createConsoleExecutor(options3) {
68598
68906
  timedOut = true;
68599
68907
  terminate();
68600
68908
  },
68601
- action === "build" || action === "qrcode" ? 65 * 60 * 1e3 : action === "preview.status" || action === "preview.logs" ? 3e4 : 7 * 60 * 1e3
68909
+ action === "build" || action === "qrcode" ? 65 * 60 * 1e3 : action === "preview.status" || action === "preview.logs" || action === "issue.report" ? 3e4 : 7 * 60 * 1e3
68602
68910
  );
68603
68911
  const cleanup = () => {
68604
68912
  finished = true;
@@ -68673,6 +68981,17 @@ function createConsoleExecutor(options3) {
68673
68981
  }
68674
68982
  try {
68675
68983
  const result = JSON.parse(stdout);
68984
+ if (action === "issue.report") {
68985
+ const created = code === 0 && (result == null ? void 0 : result.status) === "created" && typeof result.issue_url === "string" && /^https:\/\/github\.com\/taptap\/instant-games-open-mcp\/issues\/\d+$/.test(
68986
+ result.issue_url
68987
+ );
68988
+ resolve({
68989
+ ok: created,
68990
+ status: created ? "created" : "unavailable",
68991
+ ...created ? { issue_url: result.issue_url } : {}
68992
+ });
68993
+ return;
68994
+ }
68676
68995
  if (!result || typeof result !== "object" || typeof result.ok !== "boolean")
68677
68996
  throw new Error("Missing CLI result status.");
68678
68997
  resolve(
@@ -68708,7 +69027,7 @@ function launchConsoleServerProcess(options3) {
68708
69027
 
68709
69028
  // src/maker/console/server.ts
68710
69029
  import http3 from "node:http";
68711
- import { createHash as createHash7 } from "node:crypto";
69030
+ import { createHash as createHash8 } from "node:crypto";
68712
69031
 
68713
69032
  // src/maker/console/tasks.ts
68714
69033
  init_privateJson();
@@ -68718,6 +69037,107 @@ init_qrcodeInteraction();
68718
69037
  import fs38 from "node:fs";
68719
69038
  import path39 from "node:path";
68720
69039
  import { randomUUID as randomUUID7 } from "node:crypto";
69040
+
69041
+ // src/maker/console/issueReport.ts
69042
+ init_protocol2();
69043
+ init_diagnosticRedaction();
69044
+ import fs37 from "node:fs";
69045
+ import os7 from "node:os";
69046
+ import path38 from "node:path";
69047
+ import { createHash as createHash6 } from "node:crypto";
69048
+ function consoleReportOffer(task) {
69049
+ if (!["failed", "unknown"].includes(task.status)) return;
69050
+ if (task.action === "lua-lsp.check" || task.interaction || task.recovery) return;
69051
+ const error2 = task.error || "";
69052
+ if (/找不到本地预览入口|Runtime is missing|taptap-maker login|PAT.*(?:expired|invalid)|HTTP 40[13]|cancelled|canceled|用户取消|Please commit your changes|CONFLICT|Need to call maker_build_current_directory|Invalid.*config|配置.*(?:损坏|缺失)|requires a bound Maker project/i.test(
69053
+ error2
69054
+ ))
69055
+ return;
69056
+ const preview = ["preview.start", "preview.refresh", "preview.install"].includes(task.action);
69057
+ if (!preview && !/timeout|timed out|HTTP 5\d\d|internal.*error|unverifiable|verifiable JSON|unexpected|connection closed/i.test(
69058
+ error2
69059
+ ))
69060
+ return;
69061
+ const category = preview ? "runtime" : task.action === "build" || task.action === "qrcode" ? "build" : "console";
69062
+ const stable = error2.replace(/[a-f0-9]{8}-[a-f0-9-]{27,}/gi, "<id>").replace(/[a-f0-9]{64}/gi, "<hash>").replace(/\b\d+\b/g, "<n>");
69063
+ return {
69064
+ category,
69065
+ fingerprint: createHash6("sha256").update(task.projectKey + ":" + task.action + ":" + stable).digest("hex")
69066
+ };
69067
+ }
69068
+ function logTail(root2, relative) {
69069
+ let fd;
69070
+ try {
69071
+ if (fs37.lstatSync(root2).isSymbolicLink()) return "[日志不可用]";
69072
+ const file3 = path38.join(fs37.realpathSync(root2), relative);
69073
+ if (fs37.realpathSync(file3) !== file3 || !fs37.lstatSync(file3).isFile()) return "[日志不可用]";
69074
+ fd = fs37.openSync(file3, fs37.constants.O_RDONLY | (fs37.constants.O_NOFOLLOW || 0));
69075
+ const stat = fs37.fstatSync(fd);
69076
+ if (!stat.isFile()) return "[日志不可用]";
69077
+ const offset = Math.max(0, stat.size - 6e3);
69078
+ const buffer = Buffer.alloc(Math.min(stat.size, 6e3));
69079
+ fs37.readSync(fd, buffer, 0, buffer.length, offset);
69080
+ let text2 = buffer.toString("utf8");
69081
+ if (offset) text2 = text2.includes("\n") ? text2.slice(text2.indexOf("\n") + 1) : "";
69082
+ return (offset ? "[日志仅含尾部]\n" : "") + String(sanitizeDiagnosticValue(text2));
69083
+ } catch {
69084
+ return "[日志不存在或无法读取]";
69085
+ } finally {
69086
+ if (fd !== void 0) fs37.closeSync(fd);
69087
+ }
69088
+ }
69089
+ function consoleReportContext(task, project) {
69090
+ var _a3;
69091
+ const offer = consoleReportOffer(task);
69092
+ const directory = previewDirectory(project);
69093
+ let preview = { status: "unavailable" };
69094
+ const logs = {};
69095
+ if (task.action.startsWith("preview.")) {
69096
+ try {
69097
+ const record2 = readPreviewRecord(project);
69098
+ const result = task.result;
69099
+ const sameSession = (result == null ? void 0 : result.session_id) ? result.session_id === (record2 == null ? void 0 : record2.session_id) && (result.reload_id === void 0 || result.reload_id === (record2 == null ? void 0 : record2.reload_id)) : record2 && Date.parse(record2.started_at) >= Date.parse(task.startedAt) && Date.parse(record2.started_at) <= Date.parse(task.finishedAt || (/* @__PURE__ */ new Date()).toISOString());
69100
+ if (record2 && sameSession) {
69101
+ logs.supervisor = logTail(directory, "supervisor.log");
69102
+ preview = {
69103
+ state: record2.state,
69104
+ session_id: record2.session_id,
69105
+ reload_id: record2.reload_id,
69106
+ supervisor_pid: record2.supervisor_pid,
69107
+ runtime_pid: record2.runtime_pid,
69108
+ runtime_launch_pending: record2.runtime_launch_pending,
69109
+ runtime: record2.runtime,
69110
+ executable: record2.executable
69111
+ };
69112
+ const round = path38.join("sessions", record2.session_id, String(record2.reload_id));
69113
+ logs.prepare = logTail(directory, path38.join(round, "prepare.log"));
69114
+ logs.runtime = logTail(directory, path38.join(round, "runtime.log"));
69115
+ }
69116
+ if (!record2) logs.supervisor = logTail(directory, "supervisor.log");
69117
+ } catch {
69118
+ }
69119
+ }
69120
+ return {
69121
+ source: "console",
69122
+ category: (offer == null ? void 0 : offer.category) || "console",
69123
+ summary: `${process.platform} ${task.action} 失败:${(task.error || "执行结果未知").split("\n")[0].slice(0, 160)}`,
69124
+ failed_operation: task.action,
69125
+ error_message: (_a3 = task.error) == null ? void 0 : _a3.slice(0, 3e3),
69126
+ reproduction_steps: ["在 Maker 控制台选择项目", `执行 ${task.action}`, "出现异常或结果未知"],
69127
+ error_data: {
69128
+ task_id: task.id,
69129
+ started_at: task.startedAt,
69130
+ finished_at: task.finishedAt,
69131
+ status: task.status,
69132
+ os_release: os7.release(),
69133
+ preview,
69134
+ logs,
69135
+ output: task.output.slice(-2e3)
69136
+ }
69137
+ };
69138
+ }
69139
+
69140
+ // src/maker/console/tasks.ts
68721
69141
  var ConsoleTasks = class {
68722
69142
  constructor(projects, execute, historyFile, onSettled = () => {
68723
69143
  }) {
@@ -68727,6 +69147,7 @@ var ConsoleTasks = class {
68727
69147
  this.onSettled = onSettled;
68728
69148
  this.tasks = /* @__PURE__ */ new Map();
68729
69149
  this.running = /* @__PURE__ */ new Set();
69150
+ var _a3;
68730
69151
  if (historyFile && fs38.existsSync(historyFile)) {
68731
69152
  if (fs38.statSync(historyFile).size > 40 * 1024 * 1024)
68732
69153
  throw new ConsoleError("Console task history exceeds the supported size.");
@@ -68735,6 +69156,7 @@ var ConsoleTasks = class {
68735
69156
  throw new ConsoleError("Invalid console task history.");
68736
69157
  for (const task of data) {
68737
69158
  if (!task.id || !CONSOLE_ACTIONS.includes(task.action)) continue;
69159
+ if (((_a3 = task.report) == null ? void 0 : _a3.status) === "running") task.report = { status: "unknown" };
68738
69160
  if (task.status === "running") {
68739
69161
  task.status = "unknown";
68740
69162
  task.error = "Console restarted before the operation result was recorded. Check the result before retrying.";
@@ -68747,14 +69169,21 @@ var ConsoleTasks = class {
68747
69169
  }
68748
69170
  }
68749
69171
  pruneHistory() {
69172
+ var _a3;
68750
69173
  const counts = /* @__PURE__ */ new Map();
68751
69174
  for (const task of Array.from(this.tasks.values()).reverse()) {
68752
69175
  const count = (counts.get(task.projectKey) || 0) + 1;
68753
69176
  counts.set(task.projectKey, count);
68754
- if (count > 10 && task.status !== "running") this.tasks.delete(task.id);
69177
+ if (count > 10 && task.status !== "running" && ((_a3 = task.report) == null ? void 0 : _a3.status) !== "running")
69178
+ this.tasks.delete(task.id);
68755
69179
  }
68756
69180
  while (this.tasks.size > 100) {
68757
- const old = Array.from(this.tasks.values()).find((task) => task.status !== "running");
69181
+ const old = Array.from(this.tasks.values()).find(
69182
+ (task) => {
69183
+ var _a4;
69184
+ return task.status !== "running" && ((_a4 = task.report) == null ? void 0 : _a4.status) !== "running";
69185
+ }
69186
+ );
68758
69187
  if (!old) break;
68759
69188
  this.tasks.delete(old.id);
68760
69189
  }
@@ -68766,12 +69195,13 @@ var ConsoleTasks = class {
68766
69195
  const result = task.result;
68767
69196
  const interaction = task.action === "qrcode" && ["failed", "unknown"].includes(task.status) ? parseQrcodeInteraction(result == null ? void 0 : result.error) || parseQrcodeInteraction(task.error) : void 0;
68768
69197
  const recovery = task.action === "qrcode" && ["failed", "unknown"].includes(task.status) ? parseQrcodeRecovery(result == null ? void 0 : result.error) || parseQrcodeRecovery(task.error) : void 0;
68769
- return {
69198
+ const described = {
68770
69199
  ...task,
68771
69200
  interaction,
68772
69201
  recovery,
68773
69202
  ...interaction || recovery ? { status: "unknown" } : {}
68774
69203
  };
69204
+ return { ...described, reportOffer: consoleReportOffer(described) };
68775
69205
  }
68776
69206
  get(id) {
68777
69207
  const task = this.tasks.get(id);
@@ -68779,7 +69209,86 @@ var ConsoleTasks = class {
68779
69209
  return this.describe(task);
68780
69210
  }
68781
69211
  busy(key) {
68782
- return this.list().some((task) => task.projectKey === key && task.status === "running");
69212
+ return this.list().some(
69213
+ (task) => {
69214
+ var _a3;
69215
+ return task.projectKey === key && (task.status === "running" || ((_a3 = task.report) == null ? void 0 : _a3.status) === "running");
69216
+ }
69217
+ );
69218
+ }
69219
+ get active() {
69220
+ return this.running.size > 0;
69221
+ }
69222
+ report(id, consent) {
69223
+ if (consent !== true) throw new ConsoleError("Explicit report consent is required.");
69224
+ const described = this.get(id);
69225
+ if (!described.reportOffer)
69226
+ throw new ConsoleError("This task is not eligible for issue reporting.");
69227
+ const task = this.tasks.get(id);
69228
+ if (task.report) return this.describe(task);
69229
+ const project = this.projects.resolve(task.projectKey);
69230
+ if (task.projectPath !== project.path || task.projectid !== project.projectid)
69231
+ throw new ConsoleError("Project binding changed since this operation.");
69232
+ if (this.running.size >= 4) throw new ConsoleError("Too many active operations.", 409);
69233
+ task.report = { status: "running" };
69234
+ try {
69235
+ this.persist();
69236
+ } catch (error2) {
69237
+ delete task.report;
69238
+ throw error2;
69239
+ }
69240
+ const operation = Promise.resolve().then(async () => {
69241
+ try {
69242
+ const result = await this.execute({
69243
+ action: "issue.report",
69244
+ project: project.path,
69245
+ reportContext: consoleReportContext(described, project.path),
69246
+ onOutput: () => {
69247
+ }
69248
+ });
69249
+ const created = result.ok && result.status === "created" && typeof result.issue_url === "string" && /^https:\/\/github\.com\/taptap\/instant-games-open-mcp\/issues\/\d+$/.test(
69250
+ result.issue_url
69251
+ );
69252
+ task.report = created ? { status: "created", issue_url: result.issue_url } : { status: result.unknown ? "unknown" : "unavailable" };
69253
+ } catch {
69254
+ task.report = { status: "unknown" };
69255
+ } finally {
69256
+ this.onSettled();
69257
+ try {
69258
+ this.persist();
69259
+ } catch {
69260
+ }
69261
+ }
69262
+ });
69263
+ this.running.add(operation);
69264
+ void operation.finally(() => this.running.delete(operation)).catch(() => {
69265
+ });
69266
+ return this.describe(task);
69267
+ }
69268
+ recordFailure(key, action, error2) {
69269
+ if (!CONSOLE_ACTIONS.includes(action)) throw new ConsoleError("Unsupported console action.");
69270
+ const project = this.projects.resolve(key);
69271
+ const task = {
69272
+ id: randomUUID7(),
69273
+ projectKey: key,
69274
+ projectName: project.name,
69275
+ projectPath: project.path,
69276
+ projectid: project.projectid,
69277
+ action,
69278
+ status: "failed",
69279
+ startedAt: (/* @__PURE__ */ new Date()).toISOString(),
69280
+ finishedAt: (/* @__PURE__ */ new Date()).toISOString(),
69281
+ output: "",
69282
+ error: String(sanitizeDiagnosticValue(error2)).slice(0, 8192)
69283
+ };
69284
+ this.tasks.set(task.id, task);
69285
+ try {
69286
+ this.persist();
69287
+ } catch (error3) {
69288
+ this.tasks.delete(task.id);
69289
+ throw error3;
69290
+ }
69291
+ return this.describe(task);
68783
69292
  }
68784
69293
  start(key, action, confirmedOrientation, publication, confirmedBuild, sourceTaskId) {
68785
69294
  var _a3;
@@ -68869,7 +69378,9 @@ var ConsoleTasks = class {
68869
69378
  } catch (error2) {
68870
69379
  task.status = "failed";
68871
69380
  task.error = String(
68872
- sanitizeDiagnosticValue(error2 instanceof Error ? error2.message : String(error2))
69381
+ sanitizeDiagnosticValue(
69382
+ error2 instanceof Error ? error2.message : "Unexpected console task error."
69383
+ )
68873
69384
  ).slice(0, 8192);
68874
69385
  } finally {
68875
69386
  task.finishedAt = (/* @__PURE__ */ new Date()).toISOString();
@@ -68894,7 +69405,10 @@ var ConsoleTasks = class {
68894
69405
  if (this.historyFile) {
68895
69406
  fs38.mkdirSync(path39.dirname(this.historyFile), { recursive: true, mode: 448 });
68896
69407
  while (Buffer.byteLength(JSON.stringify(Array.from(this.tasks.values()))) > 40 * 1024 * 1024) {
68897
- const oldest = this.list().reverse().find((task) => task.status !== "running");
69408
+ const oldest = this.list().reverse().find((task) => {
69409
+ var _a3;
69410
+ return task.status !== "running" && ((_a3 = task.report) == null ? void 0 : _a3.status) !== "running";
69411
+ });
68898
69412
  if (!oldest) throw new ConsoleError("Active console history exceeds the supported size.");
68899
69413
  this.tasks.delete(oldest.id);
68900
69414
  }
@@ -69536,7 +70050,7 @@ var ConsoleUpdates = class {
69536
70050
  // src/maker/console/documents.ts
69537
70051
  import fs42 from "node:fs";
69538
70052
  import path43 from "node:path";
69539
- import { createHash as createHash6 } from "node:crypto";
70053
+ import { createHash as createHash7 } from "node:crypto";
69540
70054
 
69541
70055
  // node_modules/marked/lib/marked.esm.js
69542
70056
  function _getDefaults() {
@@ -71682,7 +72196,7 @@ var ConsoleDocuments = class {
71682
72196
  const heading = (_b = (_a3 = content.match(/^#\s+(.+)$/m)) == null ? void 0 : _a3[1]) == null ? void 0 : _b.trim();
71683
72197
  const fallback = path43.basename(filename2).toLowerCase() === "skill.md" ? path43.basename(path43.dirname(filename2)) : path43.basename(filename2, path43.extname(filename2));
71684
72198
  entries.push({
71685
- id: createHash6("sha256").update(source + ":" + relativePath).digest("hex"),
72199
+ id: createHash7("sha256").update(source + ":" + relativePath).digest("hex"),
71686
72200
  title: (heading || fallback).slice(0, 160),
71687
72201
  kind,
71688
72202
  category,
@@ -71961,8 +72475,8 @@ async function startConsoleServer(options3) {
71961
72475
  readers.delete(pending);
71962
72476
  }
71963
72477
  }
71964
- const scriptHashes = [...options3.html.matchAll(/<script>([\s\S]*?)<\/script>/g)].map(
71965
- (match) => `'sha256-${createHash7("sha256").update(match[1]).digest("base64")}'`
72478
+ const scriptHashes = [...options3.html.matchAll(/<script>([\s\S]*?)<\/script>/gi)].map(
72479
+ (match) => `'sha256-${createHash8("sha256").update(match[1]).digest("base64")}'`
71966
72480
  );
71967
72481
  const server = http3.createServer(async (request2, response) => {
71968
72482
  const json2 = (status, value) => {
@@ -72098,14 +72612,30 @@ async function startConsoleServer(options3) {
72098
72612
  json2(202, task2);
72099
72613
  return;
72100
72614
  }
72615
+ if (request2.method === "POST" && url2.pathname === "/api/tasks/failure") {
72616
+ const body = await bodyForMutation();
72617
+ if (typeof body.projectKey !== "string" || typeof body.action !== "string" || typeof body.error !== "string")
72618
+ throw new ConsoleError("Project, action, and error are required.");
72619
+ const task2 = tasks.recordFailure(body.projectKey, body.action, body.error);
72620
+ touch();
72621
+ json2(202, task2);
72622
+ return;
72623
+ }
72101
72624
  if (request2.method === "POST" && url2.pathname === "/api/shutdown") {
72102
72625
  await bodyForMutation();
72103
- if (selectingFolder || updates.job.status === "running" || tasks.list().some((task2) => task2.status === "running"))
72626
+ if (selectingFolder || updates.job.status === "running" || tasks.active)
72104
72627
  throw new ConsoleError("Wait for active tasks before stopping the console.", 409);
72105
72628
  json2(200, { ok: true });
72106
72629
  setImmediate(() => void close());
72107
72630
  return;
72108
72631
  }
72632
+ const report = url2.pathname.match(/^\/api\/tasks\/([a-f0-9-]+)\/report$/);
72633
+ if (request2.method === "POST" && report) {
72634
+ const body = await bodyForMutation();
72635
+ json2(202, tasks.report(report[1], body.consent));
72636
+ touch();
72637
+ return;
72638
+ }
72109
72639
  const task = url2.pathname.match(/^\/api\/tasks\/([a-f0-9-]+)$/);
72110
72640
  if (request2.method === "GET" && task) {
72111
72641
  json2(200, tasks.get(task[1]));
@@ -72176,7 +72706,9 @@ async function startConsoleServer(options3) {
72176
72706
  } catch (error2) {
72177
72707
  if (!response.headersSent)
72178
72708
  json2(error2 instanceof ConsoleError ? error2.status : 400, {
72179
- error: sanitizeDiagnosticValue(error2 instanceof Error ? error2.message : String(error2))
72709
+ error: sanitizeDiagnosticValue(
72710
+ error2 instanceof Error ? error2.message : "Unexpected console error."
72711
+ )
72180
72712
  });
72181
72713
  }
72182
72714
  });
@@ -72200,7 +72732,7 @@ async function startConsoleServer(options3) {
72200
72732
  origin = `http://127.0.0.1:${address.port}`;
72201
72733
  const idleTimer = setInterval(
72202
72734
  () => {
72203
- if (now() - lastActivity >= idleMs && !selectingFolder && updates.job.status !== "running" && !tasks.list().some((task) => task.status === "running") && !plugins.active)
72735
+ if (now() - lastActivity >= idleMs && !selectingFolder && updates.job.status !== "running" && !tasks.active && !plugins.active)
72204
72736
  void close();
72205
72737
  },
72206
72738
  Math.min(3e4, idleMs)
@@ -72260,7 +72792,7 @@ async function readBody(request2) {
72260
72792
  }
72261
72793
 
72262
72794
  // src/maker/console/cli.ts
72263
- var VERSION3 = false ? "dev" : "0.0.34-beta.6";
72795
+ var VERSION3 = false ? "dev" : "0.0.34-beta.7";
72264
72796
  var CONSOLE_PROTOCOL_VERSION = 2;
72265
72797
  function home() {
72266
72798
  return path46.join(getMakerHome(), "console");
@@ -72269,7 +72801,7 @@ function sessionPath() {
72269
72801
  return path46.join(home(), "session.json");
72270
72802
  }
72271
72803
  function createConsoleLauncherIdentity(version2, developmentSource) {
72272
- return createHash8("sha256").update(
72804
+ return createHash9("sha256").update(
72273
72805
  JSON.stringify({
72274
72806
  protocol: CONSOLE_PROTOCOL_VERSION,
72275
72807
  version: version2,
@@ -72868,14 +73400,14 @@ init_identify();
72868
73400
  init_pluginDistribution();
72869
73401
  import { spawnSync as spawnSync7 } from "node:child_process";
72870
73402
  import fs46 from "node:fs";
72871
- import os8 from "node:os";
73403
+ import os9 from "node:os";
72872
73404
  import path48 from "node:path";
72873
73405
  import { fileURLToPath as fileURLToPath4 } from "node:url";
72874
73406
 
72875
73407
  // src/maker/cli/dshMcpConfig.ts
72876
73408
  var import_yaml = __toESM(require_dist2());
72877
73409
  import fs45 from "node:fs";
72878
- import os7 from "node:os";
73410
+ import os8 from "node:os";
72879
73411
  import path47 from "node:path";
72880
73412
  var DSH_MCP_PLUGIN_NAME = "@deepseek-ai/dsh-mcp-client";
72881
73413
  var DSH_MAKER_PLUGIN_ID = "mcp-taptap-maker";
@@ -72884,10 +73416,10 @@ function getDshHome(options3 = {}) {
72884
73416
  var _a3;
72885
73417
  const configured = (_a3 = (options3.environment || process.env).DSH_HOME) == null ? void 0 : _a3.trim();
72886
73418
  if (configured) {
72887
- const expanded = configured === "~" ? options3.homeDir || os7.homedir() : configured.startsWith("~/") || configured.startsWith("~\\") ? path47.join(options3.homeDir || os7.homedir(), configured.slice(2)) : configured;
73419
+ const expanded = configured === "~" ? options3.homeDir || os8.homedir() : configured.startsWith("~/") || configured.startsWith("~\\") ? path47.join(options3.homeDir || os8.homedir(), configured.slice(2)) : configured;
72888
73420
  return path47.resolve(expanded);
72889
73421
  }
72890
- return path47.join(options3.homeDir || os7.homedir(), ".dsh");
73422
+ return path47.join(options3.homeDir || os8.homedir(), ".dsh");
72891
73423
  }
72892
73424
  function createDshMakerPluginConfig(options3) {
72893
73425
  return {
@@ -73112,6 +73644,12 @@ function deepEqual(left, right) {
73112
73644
  var MAKER_MCP_NAME = "taptap-maker";
73113
73645
  var GITHUB_REPOSITORY = "taptap/instant-games-open-mcp";
73114
73646
  var GITHUB_NEW_ISSUE_URL = `https://github.com/${GITHUB_REPOSITORY}/issues/new`;
73647
+ var MAKER_ISSUE_CATEGORIES = {
73648
+ mcp: "Maker MCP",
73649
+ console: "控制台",
73650
+ runtime: "UrhoX Runtime",
73651
+ build: "构建"
73652
+ };
73115
73653
  function parseMakerMcpReportContext(input2) {
73116
73654
  const trimmed = input2.trim();
73117
73655
  if (!trimmed) {
@@ -73220,16 +73758,17 @@ function buildMakerMcpIssue(options3) {
73220
73758
  options3.homeDir
73221
73759
  );
73222
73760
  const summary = stripControlCharacters(sanitizePublicText(context.summary, options3.homeDir)).replace(/\s+/gu, " ").trim() || "Maker MCP problem report";
73223
- const title = `[Maker MCP] ${summary}`.slice(0, 120);
73761
+ const category = context.category && Object.prototype.hasOwnProperty.call(MAKER_ISSUE_CATEGORIES, context.category) ? MAKER_ISSUE_CATEGORIES[context.category] : MAKER_ISSUE_CATEGORIES.mcp;
73762
+ const title = `[${category}] ${summary}`.slice(0, 120);
73224
73763
  const body = [
73225
73764
  "<!-- maker-mcp-auto-report -->",
73226
- "> 由 TapTap Maker AI 故障上报流程自动生成;凭证和用户主目录已经脱敏。",
73765
+ context.source === "console" ? "> 由 TapTap Maker 控制台故障上报流程自动生成;凭证和用户主目录已经脱敏。" : "> 由 TapTap Maker AI 故障上报流程自动生成;凭证和用户主目录已经脱敏。",
73227
73766
  "",
73228
73767
  "## 问题摘要",
73229
73768
  "",
73230
73769
  summary,
73231
73770
  "",
73232
- "## AI 会话与错误上下文",
73771
+ context.source === "console" ? "## 控制台操作与错误上下文" : "## AI 会话与错误上下文",
73233
73772
  "",
73234
73773
  fencedJson(context, 24e3),
73235
73774
  "",
@@ -73247,7 +73786,7 @@ function buildMakerMcpIssue(options3) {
73247
73786
  async function collectMakerMcpIssueDiagnostics(options3) {
73248
73787
  var _a3, _b;
73249
73788
  const platform = options3.platform || process.platform;
73250
- const homeDir = options3.homeDir || os8.homedir();
73789
+ const homeDir = options3.homeDir || os9.homedir();
73251
73790
  const processCwd = path48.resolve(options3.processCwd || process.cwd());
73252
73791
  const targetDir = path48.resolve(options3.targetDir);
73253
73792
  const identify = identifyMakerProject({ cwd: targetDir });
@@ -73740,6 +74279,9 @@ function pickMakerMcpReportContext(parsed) {
73740
74279
  const context = {
73741
74280
  summary: typeof parsed.summary === "string" && parsed.summary.trim() ? parsed.summary.trim() : "Maker MCP problem report"
73742
74281
  };
74282
+ if (typeof parsed.category === "string" && Object.prototype.hasOwnProperty.call(MAKER_ISSUE_CATEGORIES, parsed.category))
74283
+ context.category = parsed.category;
74284
+ if (parsed.source === "console") context.source = "console";
73743
74285
  for (const key of [
73744
74286
  "error_message",
73745
74287
  "failed_operation",
@@ -73806,7 +74348,7 @@ function stripControlCharacters(value) {
73806
74348
  // src/maker/cli/pluginMigration.ts
73807
74349
  init_storage();
73808
74350
  import fs48 from "node:fs";
73809
- import os9 from "node:os";
74351
+ import os10 from "node:os";
73810
74352
  import path50 from "node:path";
73811
74353
  import crypto3 from "node:crypto";
73812
74354
 
@@ -74043,7 +74585,7 @@ function writeConfigWithTapTapBackupIfChanged(filePath, nextContent, validate2)
74043
74585
 
74044
74586
  // src/maker/cli/pluginMigration.ts
74045
74587
  function inspectCodexLegacyMakerMcp(options3 = {}) {
74046
- const configPath = options3.configPath ?? path50.join(os9.homedir(), ".codex", "config.toml");
74588
+ const configPath = options3.configPath ?? path50.join(os10.homedir(), ".codex", "config.toml");
74047
74589
  if (!fs48.existsSync(configPath)) {
74048
74590
  return createInspection(configPath, "not_found", 0);
74049
74591
  }
@@ -74062,7 +74604,7 @@ function inspectCodexLegacyMakerMcp(options3 = {}) {
74062
74604
  };
74063
74605
  }
74064
74606
  function migrateCodexLegacyMakerMcp(options3 = {}) {
74065
- const configPath = options3.configPath ?? path50.join(os9.homedir(), ".codex", "config.toml");
74607
+ const configPath = options3.configPath ?? path50.join(os10.homedir(), ".codex", "config.toml");
74066
74608
  const makerHome = options3.makerHome ?? getMakerHome();
74067
74609
  const statePath = getCodexPluginMigrationStatePath(makerHome);
74068
74610
  const inspection = inspectCodexLegacyMakerMcp({ configPath });
@@ -74121,7 +74663,7 @@ function migrateCodexLegacyMakerMcp(options3 = {}) {
74121
74663
  };
74122
74664
  }
74123
74665
  function restoreCodexLegacyMakerMcp(options3 = {}) {
74124
- const configPath = options3.configPath ?? path50.join(os9.homedir(), ".codex", "config.toml");
74666
+ const configPath = options3.configPath ?? path50.join(os10.homedir(), ".codex", "config.toml");
74125
74667
  const makerHome = options3.makerHome ?? getMakerHome();
74126
74668
  const statePath = getCodexPluginMigrationStatePath(makerHome);
74127
74669
  const inspection = inspectCodexLegacyMakerMcp({ configPath });
@@ -74438,8 +74980,8 @@ function restoreWorkBuddyLegacyMakerMcp(options3 = {}) {
74438
74980
  }
74439
74981
  function getWorkBuddyConfigPaths(configPaths) {
74440
74982
  return configPaths ?? [
74441
- path50.join(os9.homedir(), ".workbuddy", "mcp.json"),
74442
- path50.join(os9.homedir(), ".workbuddy", ".mcp.json")
74983
+ path50.join(os10.homedir(), ".workbuddy", "mcp.json"),
74984
+ path50.join(os10.homedir(), ".workbuddy", ".mcp.json")
74443
74985
  ];
74444
74986
  }
74445
74987
  function findWorkBuddyMakerRegistrations(configPaths) {
@@ -74518,7 +75060,7 @@ function isRecord5(value) {
74518
75060
  var import_yaml2 = __toESM(require_dist2());
74519
75061
  init_storage();
74520
75062
  import fs49 from "node:fs";
74521
- import os10 from "node:os";
75063
+ import os11 from "node:os";
74522
75064
  import path51 from "node:path";
74523
75065
  import crypto4 from "node:crypto";
74524
75066
  var DSH_MAKER_MCP_NAME = "taptap-maker";
@@ -74637,7 +75179,7 @@ function restoreDshLegacyMakerMcp(options3 = {}) {
74637
75179
  }
74638
75180
  function findDshMakerRegistrations(dshHome) {
74639
75181
  const resolvedDshHome = dshHome || getDshHome();
74640
- const configPaths = listDshMcpConfigPaths({ homeDir: os10.homedir(), dshHome: resolvedDshHome });
75182
+ const configPaths = listDshMcpConfigPaths({ homeDir: os11.homedir(), dshHome: resolvedDshHome });
74641
75183
  const registrations = [];
74642
75184
  for (const configPath of configPaths) {
74643
75185
  if (!fs49.existsSync(configPath)) {
@@ -74777,7 +75319,7 @@ init_fetchTimeout();
74777
75319
  init_identify();
74778
75320
  init_storage();
74779
75321
  import fs50 from "node:fs";
74780
- import os11 from "node:os";
75322
+ import os12 from "node:os";
74781
75323
  import path52 from "node:path";
74782
75324
  import { randomUUID as randomUUID9 } from "node:crypto";
74783
75325
  import { Readable, Transform } from "node:stream";
@@ -74801,7 +75343,7 @@ async function pullMakerUserSkills(options3 = {}) {
74801
75343
  throw new Error("Maker authentication not found. Run `taptap-maker login` and try again.");
74802
75344
  }
74803
75345
  const sourceDir = path52.join(project.projectRoot, ".installer", "skills");
74804
- const tempDir = fs50.mkdtempSync(path52.join(os11.tmpdir(), "taptap-maker-user-skills-"));
75346
+ const tempDir = fs50.mkdtempSync(path52.join(os12.tmpdir(), "taptap-maker-user-skills-"));
74805
75347
  const archivePath = path52.join(tempDir, "user-skills.zip");
74806
75348
  const stagingDir = path52.join(tempDir, "skills");
74807
75349
  try {
@@ -75000,10 +75542,10 @@ function installUserSkills(projectRoot, stagingDir, skillNames) {
75000
75542
  if (rollbackErrors.length > 0) {
75001
75543
  preserveTransaction = true;
75002
75544
  throw new Error(
75003
- `Failed to install Maker user Skills: ${formatError4(error2)}; rollback incomplete, backups were preserved at ${transactionDir}: ${rollbackErrors.join("; ")}`
75545
+ `Failed to install Maker user Skills: ${formatError5(error2)}; rollback incomplete, backups were preserved at ${transactionDir}: ${rollbackErrors.join("; ")}`
75004
75546
  );
75005
75547
  }
75006
- throw new Error(`Failed to install Maker user Skills: ${formatError4(error2)}`);
75548
+ throw new Error(`Failed to install Maker user Skills: ${formatError5(error2)}`);
75007
75549
  } finally {
75008
75550
  if (!preserveTransaction) {
75009
75551
  fs50.rmSync(transactionDir, { recursive: true, force: true });
@@ -75045,10 +75587,10 @@ function installUserSkillsForClients(projectRoot, skillNames) {
75045
75587
  if (rollbackErrors.length > 0) {
75046
75588
  preserveTransaction = true;
75047
75589
  throw new Error(
75048
- `Failed to install Maker user Skills for AI clients: ${formatError4(error2)}; rollback incomplete, backups were preserved at ${transactionDir}: ` + rollbackErrors.join("; ")
75590
+ `Failed to install Maker user Skills for AI clients: ${formatError5(error2)}; rollback incomplete, backups were preserved at ${transactionDir}: ` + rollbackErrors.join("; ")
75049
75591
  );
75050
75592
  }
75051
- throw new Error(`Failed to install Maker user Skills for AI clients: ${formatError4(error2)}`);
75593
+ throw new Error(`Failed to install Maker user Skills for AI clients: ${formatError5(error2)}`);
75052
75594
  } finally {
75053
75595
  if (!preserveTransaction) {
75054
75596
  fs50.rmSync(transactionDir, { recursive: true, force: true });
@@ -75065,7 +75607,7 @@ function rollbackSkillChanges(changes) {
75065
75607
  fs50.renameSync(item.backup, item.target);
75066
75608
  }
75067
75609
  } catch (error2) {
75068
- errors.push(`${item.target}: ${formatError4(error2)}`);
75610
+ errors.push(`${item.target}: ${formatError5(error2)}`);
75069
75611
  }
75070
75612
  }
75071
75613
  return errors;
@@ -75080,7 +75622,7 @@ function linkOrCopySkill(source, target) {
75080
75622
  fs50.cpSync(source, target, { recursive: true });
75081
75623
  } catch (copyError) {
75082
75624
  throw new Error(
75083
- `Failed to link ${source}: ${formatError4(linkError)}; copy fallback: ${formatError4(copyError)}`
75625
+ `Failed to link ${source}: ${formatError5(linkError)}; copy fallback: ${formatError5(copyError)}`
75084
75626
  );
75085
75627
  }
75086
75628
  }
@@ -75123,7 +75665,7 @@ function pathExists(value) {
75123
75665
  return false;
75124
75666
  }
75125
75667
  }
75126
- function formatError4(error2) {
75668
+ function formatError5(error2) {
75127
75669
  return error2 instanceof Error ? error2.message : String(error2);
75128
75670
  }
75129
75671
  function hasControlCharacter(value) {
@@ -75134,7 +75676,7 @@ function hasControlCharacter(value) {
75134
75676
  }
75135
75677
 
75136
75678
  // src/maker/cli/commands.ts
75137
- var VERSION4 = true ? "0.0.34-beta.6" : "dev";
75679
+ var VERSION4 = true ? "0.0.34-beta.7" : "dev";
75138
75680
  var DEFAULT_MCP_NAME = "taptap-maker";
75139
75681
  var MAKER_NPM_PACKAGE = "@taptap/maker";
75140
75682
  var TWO_PART_COMMANDS = /* @__PURE__ */ new Set([
@@ -76151,17 +76693,18 @@ async function runMcpReport(parsed, ctx) {
76151
76693
  );
76152
76694
  return;
76153
76695
  }
76154
- const reportRuntime = resolveMakerMcpReportRuntime({
76696
+ const reportRuntime = context.source === "console" ? void 0 : resolveMakerMcpReportRuntime({
76155
76697
  distribution: process.env.TAPTAP_MAKER_DISTRIBUTION,
76156
76698
  bundleUrl: typeof __MAKER_BUNDLE_URL__ !== "undefined" ? __MAKER_BUNDLE_URL__ : void 0
76157
76699
  });
76158
76700
  const diagnostics = await collectMakerMcpIssueDiagnostics({
76159
- ide: stringOption(parsed, "ide") || (reportRuntime == null ? void 0 : reportRuntime.client),
76701
+ ide: context.source === "console" ? void 0 : stringOption(parsed, "ide") || (reportRuntime == null ? void 0 : reportRuntime.client),
76160
76702
  targetDir,
76161
76703
  makerVersion: VERSION4,
76162
76704
  configSource: reportRuntime == null ? void 0 : reportRuntime.config_source,
76163
- distribution: reportRuntime == null ? void 0 : reportRuntime.distribution,
76705
+ distribution: process.env.TAPTAP_MAKER_DISTRIBUTION || (reportRuntime == null ? void 0 : reportRuntime.distribution),
76164
76706
  verify: async () => {
76707
+ if (context.source === "console") return { status: "not_applicable" };
76165
76708
  if (reportRuntime) {
76166
76709
  const verification = await verifyMakerMcpLauncher(reportRuntime.launcher, {
76167
76710
  cwd: reportRuntime.cwd,
@@ -76201,7 +76744,7 @@ async function runMcpReport(parsed, ctx) {
76201
76744
  const issue3 = buildMakerMcpIssue({
76202
76745
  context,
76203
76746
  diagnostics,
76204
- homeDir: os12.homedir()
76747
+ homeDir: os13.homedir()
76205
76748
  });
76206
76749
  const submission = booleanOption(parsed, "consent") ? submitMakerMcpIssue(issue3) : {
76207
76750
  status: "consent_required",
@@ -76766,12 +77309,12 @@ function installMcpConfig(ide, options3) {
76766
77309
  }
76767
77310
  function installMcpConfigUnsafe(ide, options3) {
76768
77311
  if (ide === "codex") {
76769
- const configPath = path53.join(os12.homedir(), ".codex", "config.toml");
77312
+ const configPath = path53.join(os13.homedir(), ".codex", "config.toml");
76770
77313
  const write = mergeCodexMcpConfig(configPath, withClientIde(options3, "codex"));
76771
77314
  return [createMcpInstallResult(ide, "Codex", configPath, write)];
76772
77315
  }
76773
77316
  if (ide === "cursor") {
76774
- const configPath = path53.join(os12.homedir(), ".cursor", "mcp.json");
77317
+ const configPath = path53.join(os13.homedir(), ".cursor", "mcp.json");
76775
77318
  const write = mergeJsonMcpConfig(configPath, withClientIde(options3, "cursor"));
76776
77319
  return [createMcpInstallResult(ide, "Cursor", configPath, write)];
76777
77320
  }
@@ -76788,7 +77331,7 @@ function installMcpConfigUnsafe(ide, options3) {
76788
77331
  }
76789
77332
  ];
76790
77333
  }
76791
- const configPath = path53.join(os12.homedir(), ".claude.json");
77334
+ const configPath = path53.join(os13.homedir(), ".claude.json");
76792
77335
  const write = mergeJsonMcpConfig(configPath, claudeOptions);
76793
77336
  return [createMcpInstallResult(ide, "Claude fallback", configPath, write)];
76794
77337
  }
@@ -76929,13 +77472,13 @@ function normalizeConfigPathKey(configPath) {
76929
77472
  }
76930
77473
  function getTraeSoloMcpConfigPaths() {
76931
77474
  if (process.platform === "win32") {
76932
- const roaming = process.env.APPDATA || path53.join(os12.homedir(), "AppData", "Roaming");
77475
+ const roaming = process.env.APPDATA || path53.join(os13.homedir(), "AppData", "Roaming");
76933
77476
  return [
76934
77477
  path53.join(roaming, "TRAE SOLO", "User", "mcp.json"),
76935
77478
  path53.join(roaming, "TRAE SOLO CN", "User", "mcp.json")
76936
77479
  ];
76937
77480
  }
76938
- const appSupport = path53.join(os12.homedir(), "Library", "Application Support");
77481
+ const appSupport = path53.join(os13.homedir(), "Library", "Application Support");
76939
77482
  return [
76940
77483
  path53.join(appSupport, "TRAE SOLO CN", "User", "mcp.json"),
76941
77484
  path53.join(appSupport, "TRAE SOLO", "User", "mcp.json")
@@ -76943,14 +77486,14 @@ function getTraeSoloMcpConfigPaths() {
76943
77486
  }
76944
77487
  function getTraeUnverifiedMcpConfigPaths() {
76945
77488
  if (process.platform === "win32") {
76946
- const roaming = process.env.APPDATA || path53.join(os12.homedir(), "AppData", "Roaming");
77489
+ const roaming = process.env.APPDATA || path53.join(os13.homedir(), "AppData", "Roaming");
76947
77490
  return [
76948
77491
  path53.join(roaming, "Trae", "User", "mcp.json"),
76949
77492
  path53.join(roaming, "TRAE", "User", "mcp.json"),
76950
77493
  path53.join(roaming, "Trae CN", "User", "mcp.json")
76951
77494
  ];
76952
77495
  }
76953
- const appSupport = path53.join(os12.homedir(), "Library", "Application Support");
77496
+ const appSupport = path53.join(os13.homedir(), "Library", "Application Support");
76954
77497
  return [
76955
77498
  path53.join(appSupport, "Trae", "User", "mcp.json"),
76956
77499
  path53.join(appSupport, "TRAE", "User", "mcp.json"),
@@ -76958,10 +77501,10 @@ function getTraeUnverifiedMcpConfigPaths() {
76958
77501
  ];
76959
77502
  }
76960
77503
  function getOpenCodeMcpConfigPath() {
76961
- return path53.join(os12.homedir(), ".config", "opencode", "opencode.jsonc");
77504
+ return path53.join(os13.homedir(), ".config", "opencode", "opencode.jsonc");
76962
77505
  }
76963
77506
  function getWorkBuddyHome() {
76964
- return path53.join(os12.homedir(), ".workbuddy");
77507
+ return path53.join(os13.homedir(), ".workbuddy");
76965
77508
  }
76966
77509
  function getWorkBuddyMcpInstallPaths(options3 = {}) {
76967
77510
  const primary = path53.join(getWorkBuddyHome(), "mcp.json");
@@ -77139,7 +77682,7 @@ function mergeCodexMcpConfig(configPath, options3) {
77139
77682
  );
77140
77683
  }
77141
77684
  function tryClaudeMcpAdd(options3) {
77142
- const configPath = path53.join(os12.homedir(), ".claude.json");
77685
+ const configPath = path53.join(os13.homedir(), ".claude.json");
77143
77686
  try {
77144
77687
  const existing = readJsonObject(configPath);
77145
77688
  const server = asObject(asObject(existing.mcpServers)[options3.mcpName]);