@taptap/maker 0.0.19 → 0.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -30,4 +30,4 @@ This package contains only the Maker CLI/MCP bundle and Maker workflow skills.
30
30
  It does not include the legacy TapTap Open API MCP server, proxy, native signer,
31
31
  or OpenClaw plugin package contents.
32
32
 
33
- Version: 0.0.19
33
+ Version: 0.0.20
package/dist/maker.js CHANGED
@@ -13005,6 +13005,7 @@ var require_cross_spawn = __commonJS({
13005
13005
  import { execFileSync, spawn as spawn4, spawnSync as spawnSync6 } from "node:child_process";
13006
13006
  import fs13 from "node:fs";
13007
13007
  import path14 from "node:path";
13008
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
13008
13009
 
13009
13010
  // node_modules/zod/v3/helpers/util.js
13010
13011
  var util;
@@ -33640,8 +33641,151 @@ function extensionFromUrl(url2) {
33640
33641
  }
33641
33642
  }
33642
33643
 
33644
+ // src/mcp-proxy/config.ts
33645
+ var DEFAULT_TOOL_CALL_TIMEOUT_MS = 60 * 60 * 1e3;
33646
+ function readStdin() {
33647
+ return new Promise((resolve, reject) => {
33648
+ const chunks = [];
33649
+ process.stdin.on("data", (chunk) => {
33650
+ chunks.push(chunk);
33651
+ });
33652
+ process.stdin.on("end", () => {
33653
+ resolve(Buffer.concat(chunks).toString("utf-8"));
33654
+ });
33655
+ process.stdin.on("error", reject);
33656
+ setTimeout(() => {
33657
+ reject(new Error("Timeout reading from stdin"));
33658
+ }, 5e3);
33659
+ });
33660
+ }
33661
+ async function loadConfig() {
33662
+ let configJson;
33663
+ let source;
33664
+ if (process.argv[2]) {
33665
+ configJson = process.argv[2];
33666
+ source = "command line argument";
33667
+ } else if (process.env.PROXY_CONFIG) {
33668
+ configJson = process.env.PROXY_CONFIG;
33669
+ source = "PROXY_CONFIG environment variable";
33670
+ } else if (!process.stdin.isTTY) {
33671
+ configJson = await readStdin();
33672
+ source = "stdin";
33673
+ } else {
33674
+ throw new Error(
33675
+ `No configuration provided. Please use one of:
33676
+ 1. Command line: node index.js '{"server":{...}}'
33677
+ 2. Env var: PROXY_CONFIG='{"server":{...}}' node index.js
33678
+ 3. Stdin: echo '{"server":{...}}' | node index.js
33679
+
33680
+ See config.example.json for configuration format.`
33681
+ );
33682
+ }
33683
+ console.error(`[Proxy] Loading config from ${source}`);
33684
+ let config2;
33685
+ try {
33686
+ config2 = JSON.parse(configJson);
33687
+ } catch (error2) {
33688
+ throw new Error(
33689
+ `Failed to parse configuration JSON: ${error2 instanceof Error ? error2.message : String(error2)}
33690
+ Received: ${configJson.substring(0, 100)}...`
33691
+ );
33692
+ }
33693
+ validateConfig(config2);
33694
+ return applyDefaults(config2);
33695
+ }
33696
+ function validateConfig(config2) {
33697
+ var _a3;
33698
+ const errors = [];
33699
+ if (!config2.server) {
33700
+ errors.push("- Missing required field: server");
33701
+ } else {
33702
+ if (!config2.server.url) {
33703
+ errors.push("- Missing required field: server.url");
33704
+ }
33705
+ if (config2.server.env && !["rnd", "production"].includes(config2.server.env)) {
33706
+ errors.push('- Invalid server.env: must be "rnd" or "production"');
33707
+ }
33708
+ }
33709
+ if (!config2.tenant) {
33710
+ errors.push("- Missing required field: tenant");
33711
+ } else {
33712
+ if (config2.tenant.custom_fields !== void 0) {
33713
+ const cf = config2.tenant.custom_fields;
33714
+ if (typeof cf !== "object" || cf === null || Array.isArray(cf) || Object.getPrototypeOf(cf) !== Object.prototype) {
33715
+ errors.push("- tenant.custom_fields must be a plain object (Record<string, string>)");
33716
+ } else if (!Object.values(cf).every((v) => typeof v === "string")) {
33717
+ errors.push("- tenant.custom_fields values must all be strings");
33718
+ }
33719
+ }
33720
+ }
33721
+ if (!config2.auth) {
33722
+ errors.push("- Missing required field: auth");
33723
+ } else {
33724
+ if (!config2.auth.kid) {
33725
+ errors.push("- Missing required field: auth.kid");
33726
+ }
33727
+ if (!config2.auth.mac_key) {
33728
+ errors.push("- Missing required field: auth.mac_key");
33729
+ }
33730
+ if (config2.auth.token_type !== "mac") {
33731
+ errors.push('- Invalid auth.token_type: must be "mac"');
33732
+ }
33733
+ if (config2.auth.mac_algorithm !== "hmac-sha-1") {
33734
+ errors.push('- Invalid auth.mac_algorithm: must be "hmac-sha-1"');
33735
+ }
33736
+ }
33737
+ if (((_a3 = config2.options) == null ? void 0 : _a3.exposed_tools) !== void 0) {
33738
+ const exposedTools = config2.options.exposed_tools;
33739
+ if (!Array.isArray(exposedTools)) {
33740
+ errors.push("- options.exposed_tools must be an array of tool names");
33741
+ } else if (!exposedTools.every((toolName) => typeof toolName === "string" && toolName.trim().length > 0)) {
33742
+ errors.push("- options.exposed_tools values must be non-empty strings");
33743
+ }
33744
+ }
33745
+ if (errors.length > 0) {
33746
+ throw new Error("Invalid configuration:\n" + errors.join("\n"));
33747
+ }
33748
+ }
33749
+ var DEFAULT_LOG_ROOT = "/tmp/taptap-mcp/logs";
33750
+ function applyDefaults(config2) {
33751
+ var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
33752
+ const verbose = ((_a3 = config2.options) == null ? void 0 : _a3.verbose) ?? false;
33753
+ return {
33754
+ server: {
33755
+ url: config2.server.url,
33756
+ env: config2.server.env || "rnd"
33757
+ },
33758
+ tenant: {
33759
+ project_path: config2.tenant.project_path || ".",
33760
+ user_id: config2.tenant.user_id,
33761
+ project_id: config2.tenant.project_id,
33762
+ custom_fields: config2.tenant.custom_fields
33763
+ },
33764
+ auth: config2.auth,
33765
+ options: {
33766
+ verbose,
33767
+ reconnect_interval: ((_b = config2.options) == null ? void 0 : _b.reconnect_interval) ?? 5e3,
33768
+ request_timeout: ((_c = config2.options) == null ? void 0 : _c.request_timeout) ?? 3e4,
33769
+ tool_call_timeout: ((_d = config2.options) == null ? void 0 : _d.tool_call_timeout) ?? DEFAULT_TOOL_CALL_TIMEOUT_MS,
33770
+ reset_timeout_on_progress: ((_e = config2.options) == null ? void 0 : _e.reset_timeout_on_progress) ?? true,
33771
+ health_check_interval: ((_f = config2.options) == null ? void 0 : _f.health_check_interval) ?? 3e4,
33772
+ enable_cookie_sticky: ((_g = config2.options) == null ? void 0 : _g.enable_cookie_sticky) ?? true,
33773
+ inject_params_per_call: ((_h = config2.options) == null ? void 0 : _h.inject_params_per_call) ?? true,
33774
+ force_inject_progress_token: ((_i = config2.options) == null ? void 0 : _i.force_inject_progress_token) ?? false,
33775
+ exposed_tools: (_j = config2.options) == null ? void 0 : _j.exposed_tools,
33776
+ log: {
33777
+ root: ((_l = (_k = config2.options) == null ? void 0 : _k.log) == null ? void 0 : _l.root) ?? DEFAULT_LOG_ROOT,
33778
+ enabled: ((_n = (_m = config2.options) == null ? void 0 : _m.log) == null ? void 0 : _n.enabled) ?? false,
33779
+ // verbose=true 时自动使用 debug 级别
33780
+ level: verbose ? "debug" : ((_p = (_o = config2.options) == null ? void 0 : _o.log) == null ? void 0 : _p.level) ?? "info",
33781
+ max_days: ((_r = (_q = config2.options) == null ? void 0 : _q.log) == null ? void 0 : _r.max_days) ?? 7
33782
+ }
33783
+ }
33784
+ };
33785
+ }
33786
+
33643
33787
  // src/maker/server/mcp.ts
33644
- var VERSION = true ? "0.0.19" : "dev";
33788
+ var VERSION = true ? "0.0.20" : "dev";
33645
33789
  var DEFAULT_BUILD_TIMEOUT_MS = 10 * 60 * 1e3;
33646
33790
  var DEFAULT_PROXY_RETRY_ATTEMPTS = 5;
33647
33791
  var DEFAULT_PROXY_RETRY_DELAY_MS = 30 * 1e3;
@@ -33671,7 +33815,7 @@ var MakerCloneFailedError = class extends Error {
33671
33815
  var tools = [
33672
33816
  {
33673
33817
  name: "maker_status_lite",
33674
- description: "Compatibility status surface for clients using tool output instead of the maker://status resource. Prefer reading maker://status when resources are available. Shows local Maker status for the user current working directory, including Git, Python runtime readiness, maker-lua-lsp readiness for local Lua diagnostics, PAT/TapTap auth, project binding, AI dev kit status, Maker proxy tools status and failures, Maker Git Workflow Policy guidance, Maker Creative Asset Tool Policy guidance to prefer Maker MCP proxy tools for bound game assets, supported local path/remote URL/data URL inputs, and bundled workflow guide document paths. Maker initialization next_step: taptap-maker init. If the user explicitly asks to create a project/game in an unbound directory, prioritize taptap-maker init --create over same-name app matching.",
33818
+ description: "Compatibility status surface for clients using tool output instead of the maker://status resource. Prefer reading maker://status when resources are available. Shows local Maker status for the user current working directory, including Git, Python runtime readiness, maker-lua-lsp readiness for local Lua diagnostics, PAT/TapTap auth, project binding, AI dev kit status, Maker proxy tools status and failures, Maker Git Workflow Policy guidance, Maker Creative Asset Tool Policy guidance to prefer Maker MCP proxy tools for bound game assets, supported local path/remote URL/data URL inputs, and bundled workflow guide document paths. Maker initialization next_step: taptap-maker init. Standard init/clone/download flow: show the Maker app list first and let the user choose an existing app or 0/new. Create-new-project flow: use taptap-maker init --create only when the user clearly asks to create a new Maker project.",
33675
33819
  inputSchema: {
33676
33820
  type: "object",
33677
33821
  properties: {
@@ -33750,22 +33894,30 @@ var resources = [
33750
33894
  {
33751
33895
  uri: "maker://status",
33752
33896
  name: "Maker status",
33753
- description: "Local TapTap Maker project status, including Git, PAT/TapTap auth, project binding, AI dev kit status, and bundled workflow guide document paths. Maker initialization next_step: taptap-maker init. If the user explicitly asks to create a project/game in an unbound directory, prioritize taptap-maker init --create over same-name app matching.",
33897
+ description: "Local TapTap Maker project status, including Git, PAT/TapTap auth, project binding, AI dev kit status, and bundled workflow guide document paths. Maker initialization next_step: taptap-maker init. Standard init/clone/download flow: show the Maker app list first and let the user choose an existing app or 0/new. Create-new-project flow: use taptap-maker init --create only when the user clearly asks to create a new Maker project.",
33754
33898
  mimeType: "text/plain"
33755
33899
  }
33756
33900
  ];
33757
33901
  async function listMakerTools(options) {
33758
33902
  let remoteTools = [];
33759
33903
  try {
33904
+ const context = await resolveMakerProjectContext({
33905
+ targetDir: options.targetDir,
33906
+ listClientRoots: options.listClientRoots,
33907
+ allowFallbackOnAmbiguousRoots: false
33908
+ });
33760
33909
  const listedRemoteTools = options.listRemoteTools ?? (() => listRemoteProxyTools({
33761
- targetDir: resolveMakerToolTargetDir(options.targetDir),
33910
+ targetDir: context.targetDir,
33762
33911
  serverUrl: options.serverUrl,
33763
33912
  env: options.env
33764
33913
  }));
33765
33914
  remoteTools = filterExposedRemoteProxyTools(await listedRemoteTools()).map(
33766
33915
  decorateRemoteProxyToolDefinition
33767
33916
  );
33768
- } catch {
33917
+ } catch (error2) {
33918
+ if (isMakerProjectContextAmbiguousError(error2)) {
33919
+ logLifecycleEvent("maker-tools-list-roots-ambiguous", String(error2));
33920
+ }
33769
33921
  remoteTools = [];
33770
33922
  }
33771
33923
  return {
@@ -33778,14 +33930,30 @@ function filterExposedRemoteProxyTools(toolsToFilter) {
33778
33930
  }
33779
33931
  function decorateRemoteProxyToolDefinition(tool) {
33780
33932
  const guidance = remoteProxyToolGuidance(tool.name);
33781
- if (!guidance) {
33782
- return tool;
33783
- }
33784
33933
  return {
33785
33934
  ...tool,
33935
+ inputSchema: decorateRemoteProxyToolInputSchema(tool.inputSchema),
33786
33936
  description: [tool.description, guidance].filter(Boolean).join("\n\n")
33787
33937
  };
33788
33938
  }
33939
+ function decorateRemoteProxyToolInputSchema(inputSchema) {
33940
+ const schema = isPlainRecord(inputSchema) ? inputSchema : {};
33941
+ const properties = isPlainRecord(schema.properties) ? schema.properties : {};
33942
+ return {
33943
+ ...schema,
33944
+ type: schema.type || "object",
33945
+ properties: {
33946
+ ...properties,
33947
+ target_dir: {
33948
+ type: "string",
33949
+ description: "Optional local Maker project directory. This is a local Maker MCP private parameter used to resolve the current project for asset materialization and reference rewriting; it is not forwarded to the remote Maker generation tool."
33950
+ }
33951
+ }
33952
+ };
33953
+ }
33954
+ function isPlainRecord(value) {
33955
+ return typeof value === "object" && value !== null && !Array.isArray(value);
33956
+ }
33789
33957
  function remoteProxyToolGuidance(toolName) {
33790
33958
  const failurePolicy = "If this Maker proxy tool fails or returns isError, include the full remote_result/error payload from the server so developers can diagnose the issue.";
33791
33959
  const localMediaSizeHint = "Large local/data URL media can be slow or fail: image inputs are commonly limited to about 10 MB, video-task image inputs to about 30 MB, video inputs to about 50 MB, and audio inputs to about 15 MB.";
@@ -33942,6 +34110,8 @@ function createRemoteProxyProgressHandler(progressToken, extra) {
33942
34110
  }
33943
34111
  function createRemoteProxyCallToolOptions(progressToken, extra) {
33944
34112
  return {
34113
+ timeout: DEFAULT_TOOL_CALL_TIMEOUT_MS,
34114
+ resetTimeoutOnProgress: true,
33945
34115
  onprogress: createRemoteProxyProgressHandler(progressToken, extra)
33946
34116
  };
33947
34117
  }
@@ -33958,10 +34128,8 @@ async function startMakerMcpServer() {
33958
34128
  }
33959
34129
  }
33960
34130
  );
33961
- server.setRequestHandler(
33962
- ListToolsRequestSchema,
33963
- async () => listMakerTools({ targetDir: process.cwd() })
33964
- );
34131
+ const listClientRoots = createServerClientRootsProvider(server);
34132
+ server.setRequestHandler(ListToolsRequestSchema, async () => listMakerTools({ listClientRoots }));
33965
34133
  server.setRequestHandler(ListResourcesRequestSchema, async () => ({ resources }));
33966
34134
  server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
33967
34135
  const uri = request.params.uri;
@@ -33973,7 +34141,7 @@ async function startMakerMcpServer() {
33973
34141
  {
33974
34142
  uri,
33975
34143
  mimeType: "text/plain",
33976
- text: await formatStatus()
34144
+ text: await formatStatus({ listClientRoots })
33977
34145
  }
33978
34146
  ]
33979
34147
  };
@@ -33990,7 +34158,8 @@ async function startMakerMcpServer() {
33990
34158
  type: "text",
33991
34159
  text: await formatStatus({
33992
34160
  targetDir: args.target_dir,
33993
- skipRemoteSync: args.skip_remote_sync
34161
+ skipRemoteSync: args.skip_remote_sync,
34162
+ listClientRoots
33994
34163
  })
33995
34164
  }
33996
34165
  ]
@@ -34006,8 +34175,13 @@ async function startMakerMcpServer() {
34006
34175
  let result;
34007
34176
  let progressSummary;
34008
34177
  try {
34178
+ const context = await resolveMakerProjectContext({
34179
+ targetDir: args.target_dir,
34180
+ listClientRoots,
34181
+ allowFallbackOnAmbiguousRoots: false
34182
+ });
34009
34183
  result = await buildCurrentDirectory({
34010
- targetDir: resolveMakerToolTargetDir(args.target_dir),
34184
+ targetDir: context.targetDir,
34011
34185
  entry: args.entry,
34012
34186
  scriptsPath: args.scriptsPath,
34013
34187
  entryClient: args.entry_client,
@@ -34036,10 +34210,18 @@ async function startMakerMcpServer() {
34036
34210
  };
34037
34211
  }
34038
34212
  if (isExposedRemoteProxyTool(name)) {
34213
+ const { targetDir, remoteArgs } = splitRemoteProxyToolPrivateArgs(
34214
+ request.params.arguments || {}
34215
+ );
34216
+ const context = await resolveMakerProjectContext({
34217
+ targetDir,
34218
+ listClientRoots,
34219
+ allowFallbackOnAmbiguousRoots: false
34220
+ });
34039
34221
  return await callRemoteProxyTool({
34040
- targetDir: process.cwd(),
34222
+ targetDir: context.targetDir,
34041
34223
  name,
34042
- args: request.params.arguments || {},
34224
+ args: remoteArgs,
34043
34225
  progressToken: (_b = request.params._meta) == null ? void 0 : _b.progressToken,
34044
34226
  extra
34045
34227
  });
@@ -34093,7 +34275,12 @@ function installMakerServerExitHandlers() {
34093
34275
  }
34094
34276
  async function formatStatus(options = {}) {
34095
34277
  var _a3;
34096
- const targetDir = resolveMakerToolTargetDir(options.targetDir);
34278
+ const projectContext = await resolveMakerProjectContext({
34279
+ targetDir: options.targetDir,
34280
+ listClientRoots: options.listClientRoots,
34281
+ allowFallbackOnAmbiguousRoots: true
34282
+ });
34283
+ const targetDir = projectContext.targetDir;
34097
34284
  const env = getMakerEnvironment(void 0, targetDir);
34098
34285
  const identify = identifyMakerProject({ cwd: targetDir });
34099
34286
  const mcpCwd = process.cwd();
@@ -34136,6 +34323,7 @@ async function formatStatus(options = {}) {
34136
34323
  `- tap_auth: ${tapAuth ? "found" : "missing"} (${getTapAuthPath()})`,
34137
34324
  `- pat: ${pat ? "found" : "missing"} (${getPatPath()})`,
34138
34325
  `- target_dir: ${targetDir}`,
34326
+ `- project_context_source: ${projectContext.source}`,
34139
34327
  `- project_source: ${identify.source}`,
34140
34328
  `- project_id: ${identify.projectId || "(none)"}`,
34141
34329
  identify.configPath ? `- config: ${identify.configPath}` : "",
@@ -34151,7 +34339,9 @@ async function formatStatus(options = {}) {
34151
34339
  "",
34152
34340
  formatMakerGitDirectoryStatus(gitDirectoryStatus),
34153
34341
  "",
34154
- formatMakerToolRegistrationCwdStatus({
34342
+ formatMakerClientRootsStatus(projectContext.roots),
34343
+ "",
34344
+ projectContext.source === "client_roots" ? "" : formatMakerToolRegistrationCwdStatus({
34155
34345
  mcpCwd,
34156
34346
  targetDir,
34157
34347
  projectRoot: identify.projectRoot,
@@ -34382,11 +34572,180 @@ function formatAiDialogueDirectoryHint(targetDir) {
34382
34572
  "- do_not_show_app_selection_here: yes"
34383
34573
  ].join("\n");
34384
34574
  }
34385
- function resolveMakerToolTargetDir(targetDir) {
34386
- if (targetDir) {
34387
- return path14.resolve(targetDir);
34575
+ function createServerClientRootsProvider(server) {
34576
+ return async () => {
34577
+ const capabilities = server.getClientCapabilities();
34578
+ if (!(capabilities == null ? void 0 : capabilities.roots)) {
34579
+ return void 0;
34580
+ }
34581
+ const result = await server.listRoots(void 0, { timeout: 2e3 });
34582
+ return result.roots;
34583
+ };
34584
+ }
34585
+ async function resolveMakerProjectContext(options = {}) {
34586
+ if (options.targetDir) {
34587
+ return {
34588
+ targetDir: path14.resolve(options.targetDir),
34589
+ source: "explicit_target_dir",
34590
+ roots: { status: "not_requested", roots: [] }
34591
+ };
34592
+ }
34593
+ const roots = await resolveMakerClientRoots(options.listClientRoots);
34594
+ if (roots.status === "selected") {
34595
+ return {
34596
+ targetDir: roots.selectedProjectRoot || roots.selectedRoot,
34597
+ source: "client_roots",
34598
+ roots
34599
+ };
34600
+ }
34601
+ if (roots.status === "ambiguous" && !options.allowFallbackOnAmbiguousRoots) {
34602
+ throw new MakerProjectContextAmbiguousError(
34603
+ [
34604
+ "Multiple Maker project roots are attached to this MCP session.",
34605
+ `maker_project_roots: ${roots.makerProjectRoots.join(", ") || "(none)"}`,
34606
+ "Open a single Maker workspace, or pass target_dir explicitly for this call."
34607
+ ].join("\n")
34608
+ );
34609
+ }
34610
+ return {
34611
+ targetDir: process.cwd(),
34612
+ source: "mcp_cwd_fallback",
34613
+ roots
34614
+ };
34615
+ }
34616
+ var MakerProjectContextAmbiguousError = class extends Error {
34617
+ constructor(message) {
34618
+ super(message);
34619
+ this.name = "MakerProjectContextAmbiguousError";
34620
+ }
34621
+ };
34622
+ function isMakerProjectContextAmbiguousError(error2) {
34623
+ return error2 instanceof MakerProjectContextAmbiguousError;
34624
+ }
34625
+ async function resolveMakerClientRoots(listClientRoots) {
34626
+ if (!listClientRoots) {
34627
+ return { status: "not_requested", roots: [] };
34628
+ }
34629
+ let roots;
34630
+ try {
34631
+ roots = await listClientRoots();
34632
+ } catch (error2) {
34633
+ return {
34634
+ status: "unavailable",
34635
+ roots: [],
34636
+ message: error2 instanceof Error ? error2.message : String(error2)
34637
+ };
34638
+ }
34639
+ if (!roots) {
34640
+ return { status: "unsupported", roots: [] };
34641
+ }
34642
+ const rootPaths = uniquePaths(
34643
+ roots.map(rootToLocalPath).filter((item) => Boolean(item))
34644
+ );
34645
+ if (rootPaths.length === 0) {
34646
+ return { status: "no_roots", roots: [] };
34647
+ }
34648
+ if (rootPaths.length === 1) {
34649
+ const identify = identifyMakerProject({ cwd: rootPaths[0] });
34650
+ return {
34651
+ status: "selected",
34652
+ roots: rootPaths,
34653
+ selectedRoot: rootPaths[0],
34654
+ selectedProjectRoot: identify.projectRoot,
34655
+ reason: "single_root"
34656
+ };
34657
+ }
34658
+ const makerProjectRoots = uniquePaths(
34659
+ rootPaths.map((rootPath) => identifyMakerProject({ cwd: rootPath }).projectRoot).filter((item) => Boolean(item))
34660
+ );
34661
+ if (makerProjectRoots.length === 1) {
34662
+ return {
34663
+ status: "selected",
34664
+ roots: rootPaths,
34665
+ selectedRoot: makerProjectRoots[0],
34666
+ selectedProjectRoot: makerProjectRoots[0],
34667
+ reason: "single_maker_project"
34668
+ };
34669
+ }
34670
+ return {
34671
+ status: "ambiguous",
34672
+ roots: rootPaths,
34673
+ makerProjectRoots,
34674
+ message: makerProjectRoots.length > 1 ? "Multiple attached roots are bound Maker projects." : "Multiple attached roots are present and none is a bound Maker project."
34675
+ };
34676
+ }
34677
+ function rootToLocalPath(root) {
34678
+ try {
34679
+ const url2 = new URL(root.uri);
34680
+ if (url2.protocol !== "file:") {
34681
+ return void 0;
34682
+ }
34683
+ return path14.resolve(fileURLToPath2(url2));
34684
+ } catch {
34685
+ return void 0;
34686
+ }
34687
+ }
34688
+ function uniquePaths(values) {
34689
+ const seen = /* @__PURE__ */ new Set();
34690
+ const result = [];
34691
+ for (const value of values) {
34692
+ const normalized = normalizePathForCompare2(value);
34693
+ if (seen.has(normalized)) {
34694
+ continue;
34695
+ }
34696
+ seen.add(normalized);
34697
+ result.push(path14.resolve(value));
34388
34698
  }
34389
- return process.cwd();
34699
+ return result;
34700
+ }
34701
+ function normalizePathForCompare2(value) {
34702
+ const resolved = path14.resolve(value);
34703
+ try {
34704
+ return fs13.realpathSync.native(resolved);
34705
+ } catch {
34706
+ return resolved;
34707
+ }
34708
+ }
34709
+ function formatMakerClientRootsStatus(roots) {
34710
+ if (roots.status === "not_requested") {
34711
+ return "";
34712
+ }
34713
+ const lines = [
34714
+ "MCP client roots",
34715
+ "",
34716
+ `- status: ${roots.status}`,
34717
+ `- roots: ${roots.roots.join(", ") || "(none)"}`
34718
+ ];
34719
+ if (roots.status === "selected") {
34720
+ lines.push(`- selected_root: ${roots.selectedRoot}`);
34721
+ lines.push(`- selected_project_root: ${roots.selectedProjectRoot || "(none)"}`);
34722
+ lines.push(`- reason: ${roots.reason}`);
34723
+ lines.push("- next_action: Continue using the client workspace root as the Maker target.");
34724
+ } else if (roots.status === "ambiguous") {
34725
+ lines.push(`- maker_project_roots: ${roots.makerProjectRoots.join(", ") || "(none)"}`);
34726
+ lines.push(`- issue: ${roots.message}`);
34727
+ lines.push(
34728
+ "- next_action: Open a single Maker workspace, or pass target_dir explicitly for this call."
34729
+ );
34730
+ } else if (roots.status === "unsupported") {
34731
+ lines.push("- next_action: This client did not advertise MCP roots; falling back to MCP cwd.");
34732
+ } else if (roots.status === "unavailable") {
34733
+ lines.push(`- failure_message: ${roots.message || "(unknown)"}`);
34734
+ lines.push("- next_action: Could not read MCP roots; falling back to MCP cwd.");
34735
+ }
34736
+ return lines.join("\n");
34737
+ }
34738
+ function splitRemoteProxyToolPrivateArgs(args) {
34739
+ const remoteArgs = { ...args };
34740
+ const targetDir = remoteArgs.target_dir;
34741
+ delete remoteArgs.target_dir;
34742
+ if (targetDir === void 0) {
34743
+ return { remoteArgs };
34744
+ }
34745
+ if (typeof targetDir !== "string") {
34746
+ throw new Error("target_dir must be a string when provided.");
34747
+ }
34748
+ return { targetDir, remoteArgs };
34390
34749
  }
34391
34750
  async function formatAiDevKitStatus(projectRoot, options = {}) {
34392
34751
  const devKitStatus = inspectAiDevKit(projectRoot);
@@ -34427,6 +34786,7 @@ async function formatAutoProjectListFromPat() {
34427
34786
  return [
34428
34787
  "本地已有 Maker PAT,当前目录尚未绑定 Maker 项目。",
34429
34788
  "绑定项目时必须先提醒用户:0,创建新项目 / 0. Create a new Maker project。",
34789
+ "普通初始化、clone、拉取远端项目的标准流程:先展示 app 列表,让用户选择已有 app;用户明确选择 0/new 或明确要求创建时再创建新项目。",
34430
34790
  "即使发现和当前目录同名的 Maker app,也不能只推荐同名 app;必须同时展示创建新项目选项。",
34431
34791
  "当前目录未绑定时,先展示下面的 Maker Apps 预览和总数;选择、解释和 clone 顺序请参考 taptap-maker-local workflow guide document。",
34432
34792
  "用户选择 0/new 或已有 app 后,next_step: 执行 `taptap-maker init`。",
@@ -34477,6 +34837,7 @@ function formatStatusProjectList(projects) {
34477
34837
  hiddenCount > 0 ? "如需完整列表,请运行 taptap-maker apps --json 查看全部 app。" : void 0,
34478
34838
  "0,创建新项目 / 0. Create a new Maker project",
34479
34839
  "AI 必须把上面这一行作为可选项展示给用户;即使压缩 app 列表,也不要删除创建项目入口。",
34840
+ "AI 标准流程:先让用户从 app 列表选择已有 app;当用户选择 0/new 或明确要求创建新项目时,再进入创建流程。",
34480
34841
  "AI 展示建议:如果聊天或客户端宽度足够,可把 app 预览整理成两列紧凑布局;每个 app 保留序号、app_id、名称,以及可用的最近活跃时间或 user_id。窄屏保持单列。选择 app 前先获取用户确认。",
34481
34842
  "",
34482
34843
  ...visibleProjects.map(
@@ -35217,7 +35578,7 @@ async function refreshMakerPreview(buildResult) {
35217
35578
  clearTimeout(timeout);
35218
35579
  }
35219
35580
  }
35220
- function createRemoteRuntimeLogClient(proxy, timeoutMs = 60 * 1e3, options = {}) {
35581
+ function createRemoteRuntimeLogClient(proxy, timeoutMs = DEFAULT_TOOL_CALL_TIMEOUT_MS, options = {}) {
35221
35582
  let client;
35222
35583
  const createTransport = options.createTransport || (() => trackMakerChildTransport(
35223
35584
  new HiddenStdioClientTransport({
@@ -36025,8 +36386,7 @@ async function runInit(parsed, ctx) {
36025
36386
  ides,
36026
36387
  env,
36027
36388
  pkg: MAKER_NPM_PACKAGE,
36028
- mcpName: DEFAULT_MCP_NAME,
36029
- cwd: targetDir
36389
+ mcpName: DEFAULT_MCP_NAME
36030
36390
  });
36031
36391
  for (const result of installResults) {
36032
36392
  emit(ctx, "mcp_install", result.message, result);
@@ -36164,9 +36524,9 @@ function formatMakerMcpToolsAvailability(availability) {
36164
36524
  return lines.join("\n");
36165
36525
  }
36166
36526
  function samePath2(left, right) {
36167
- return normalizePathForCompare2(left) === normalizePathForCompare2(right);
36527
+ return normalizePathForCompare3(left) === normalizePathForCompare3(right);
36168
36528
  }
36169
- function normalizePathForCompare2(value) {
36529
+ function normalizePathForCompare3(value) {
36170
36530
  const resolved = path15.resolve(value);
36171
36531
  try {
36172
36532
  return fs14.realpathSync.native(resolved);
@@ -36594,7 +36954,8 @@ async function runAgentsUpdate(parsed, ctx) {
36594
36954
  }
36595
36955
  async function runUpgrade(parsed, ctx) {
36596
36956
  rejectPackageOption(parsed);
36597
- const targetDir = path15.resolve(stringOption(parsed, "target_dir") || process.cwd());
36957
+ const explicitTargetDir = stringOption(parsed, "target_dir");
36958
+ const targetDir = path15.resolve(explicitTargetDir || process.cwd());
36598
36959
  const env = makerEnvOption(parsed);
36599
36960
  const ides = parseIdeList(stringOption(parsed, "ide") || stringOption(parsed, "ides") || "");
36600
36961
  const installResults = installMcpConfigs({
@@ -36602,7 +36963,7 @@ async function runUpgrade(parsed, ctx) {
36602
36963
  env,
36603
36964
  pkg: MAKER_NPM_PACKAGE,
36604
36965
  mcpName: stringOption(parsed, "name") || DEFAULT_MCP_NAME,
36605
- cwd: targetDir
36966
+ cwd: explicitTargetDir ? targetDir : void 0
36606
36967
  });
36607
36968
  const identify = identifyMakerProject({ cwd: targetDir });
36608
36969
  const agentsResult = identify.projectRoot ? updateMakerAgentsPolicy(identify.projectRoot) : void 0;
@@ -36693,7 +37054,7 @@ async function runDevKitUpdate(parsed, ctx) {
36693
37054
  async function runLogsWatch(parsed, ctx) {
36694
37055
  const targetDir = path15.resolve(stringOption(parsed, "target_dir") || process.cwd());
36695
37056
  const intervalMs = parseDurationMs(stringOption(parsed, "interval") || "5s");
36696
- const timeoutMs = numberOption(parsed, "timeout_ms") ?? 60 * 1e3;
37057
+ const timeoutMs = numberOption(parsed, "timeout_ms") ?? DEFAULT_TOOL_CALL_TIMEOUT_MS;
36697
37058
  const maxPolls = numberOption(parsed, "max_polls");
36698
37059
  const maxConsecutiveFailures = numberOption(parsed, "max_consecutive_failures");
36699
37060
  const proxy = createRemoteProxyContext({
@@ -37473,6 +37834,13 @@ function printHelp() {
37473
37834
  " [--create --name NAME]",
37474
37835
  " [--skip-confirm] [--skip-mcp-install] [--register-mcp codex,cursor,claude]",
37475
37836
  " [--json]",
37837
+ "",
37838
+ "Init flows:",
37839
+ " Standard init/clone/download flow: run `taptap-maker init`; the CLI shows",
37840
+ " the Maker app list, then the user chooses an existing app or 0/new.",
37841
+ " Create-new-project flow: add `--create --name NAME` only when the user",
37842
+ " clearly asks to create a new Maker project; NAME is the requested project name.",
37843
+ "",
37476
37844
  " taptap-maker doctor [--target-dir DIR] [--env rnd|production] [--json]",
37477
37845
  " taptap-maker python doctor [--json]",
37478
37846
  " taptap-maker python setup [--json]",
@@ -37512,149 +37880,6 @@ function formatCliError(error2) {
37512
37880
  return error2 instanceof Error ? error2.message : String(error2);
37513
37881
  }
37514
37882
 
37515
- // src/mcp-proxy/config.ts
37516
- var DEFAULT_TOOL_CALL_TIMEOUT_MS = 60 * 60 * 1e3;
37517
- function readStdin() {
37518
- return new Promise((resolve, reject) => {
37519
- const chunks = [];
37520
- process.stdin.on("data", (chunk) => {
37521
- chunks.push(chunk);
37522
- });
37523
- process.stdin.on("end", () => {
37524
- resolve(Buffer.concat(chunks).toString("utf-8"));
37525
- });
37526
- process.stdin.on("error", reject);
37527
- setTimeout(() => {
37528
- reject(new Error("Timeout reading from stdin"));
37529
- }, 5e3);
37530
- });
37531
- }
37532
- async function loadConfig() {
37533
- let configJson;
37534
- let source;
37535
- if (process.argv[2]) {
37536
- configJson = process.argv[2];
37537
- source = "command line argument";
37538
- } else if (process.env.PROXY_CONFIG) {
37539
- configJson = process.env.PROXY_CONFIG;
37540
- source = "PROXY_CONFIG environment variable";
37541
- } else if (!process.stdin.isTTY) {
37542
- configJson = await readStdin();
37543
- source = "stdin";
37544
- } else {
37545
- throw new Error(
37546
- `No configuration provided. Please use one of:
37547
- 1. Command line: node index.js '{"server":{...}}'
37548
- 2. Env var: PROXY_CONFIG='{"server":{...}}' node index.js
37549
- 3. Stdin: echo '{"server":{...}}' | node index.js
37550
-
37551
- See config.example.json for configuration format.`
37552
- );
37553
- }
37554
- console.error(`[Proxy] Loading config from ${source}`);
37555
- let config2;
37556
- try {
37557
- config2 = JSON.parse(configJson);
37558
- } catch (error2) {
37559
- throw new Error(
37560
- `Failed to parse configuration JSON: ${error2 instanceof Error ? error2.message : String(error2)}
37561
- Received: ${configJson.substring(0, 100)}...`
37562
- );
37563
- }
37564
- validateConfig(config2);
37565
- return applyDefaults(config2);
37566
- }
37567
- function validateConfig(config2) {
37568
- var _a3;
37569
- const errors = [];
37570
- if (!config2.server) {
37571
- errors.push("- Missing required field: server");
37572
- } else {
37573
- if (!config2.server.url) {
37574
- errors.push("- Missing required field: server.url");
37575
- }
37576
- if (config2.server.env && !["rnd", "production"].includes(config2.server.env)) {
37577
- errors.push('- Invalid server.env: must be "rnd" or "production"');
37578
- }
37579
- }
37580
- if (!config2.tenant) {
37581
- errors.push("- Missing required field: tenant");
37582
- } else {
37583
- if (config2.tenant.custom_fields !== void 0) {
37584
- const cf = config2.tenant.custom_fields;
37585
- if (typeof cf !== "object" || cf === null || Array.isArray(cf) || Object.getPrototypeOf(cf) !== Object.prototype) {
37586
- errors.push("- tenant.custom_fields must be a plain object (Record<string, string>)");
37587
- } else if (!Object.values(cf).every((v) => typeof v === "string")) {
37588
- errors.push("- tenant.custom_fields values must all be strings");
37589
- }
37590
- }
37591
- }
37592
- if (!config2.auth) {
37593
- errors.push("- Missing required field: auth");
37594
- } else {
37595
- if (!config2.auth.kid) {
37596
- errors.push("- Missing required field: auth.kid");
37597
- }
37598
- if (!config2.auth.mac_key) {
37599
- errors.push("- Missing required field: auth.mac_key");
37600
- }
37601
- if (config2.auth.token_type !== "mac") {
37602
- errors.push('- Invalid auth.token_type: must be "mac"');
37603
- }
37604
- if (config2.auth.mac_algorithm !== "hmac-sha-1") {
37605
- errors.push('- Invalid auth.mac_algorithm: must be "hmac-sha-1"');
37606
- }
37607
- }
37608
- if (((_a3 = config2.options) == null ? void 0 : _a3.exposed_tools) !== void 0) {
37609
- const exposedTools = config2.options.exposed_tools;
37610
- if (!Array.isArray(exposedTools)) {
37611
- errors.push("- options.exposed_tools must be an array of tool names");
37612
- } else if (!exposedTools.every((toolName) => typeof toolName === "string" && toolName.trim().length > 0)) {
37613
- errors.push("- options.exposed_tools values must be non-empty strings");
37614
- }
37615
- }
37616
- if (errors.length > 0) {
37617
- throw new Error("Invalid configuration:\n" + errors.join("\n"));
37618
- }
37619
- }
37620
- var DEFAULT_LOG_ROOT = "/tmp/taptap-mcp/logs";
37621
- function applyDefaults(config2) {
37622
- var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
37623
- const verbose = ((_a3 = config2.options) == null ? void 0 : _a3.verbose) ?? false;
37624
- return {
37625
- server: {
37626
- url: config2.server.url,
37627
- env: config2.server.env || "rnd"
37628
- },
37629
- tenant: {
37630
- project_path: config2.tenant.project_path || ".",
37631
- user_id: config2.tenant.user_id,
37632
- project_id: config2.tenant.project_id,
37633
- custom_fields: config2.tenant.custom_fields
37634
- },
37635
- auth: config2.auth,
37636
- options: {
37637
- verbose,
37638
- reconnect_interval: ((_b = config2.options) == null ? void 0 : _b.reconnect_interval) ?? 5e3,
37639
- request_timeout: ((_c = config2.options) == null ? void 0 : _c.request_timeout) ?? 3e4,
37640
- tool_call_timeout: ((_d = config2.options) == null ? void 0 : _d.tool_call_timeout) ?? DEFAULT_TOOL_CALL_TIMEOUT_MS,
37641
- reset_timeout_on_progress: ((_e = config2.options) == null ? void 0 : _e.reset_timeout_on_progress) ?? true,
37642
- health_check_interval: ((_f = config2.options) == null ? void 0 : _f.health_check_interval) ?? 3e4,
37643
- enable_cookie_sticky: ((_g = config2.options) == null ? void 0 : _g.enable_cookie_sticky) ?? true,
37644
- inject_params_per_call: ((_h = config2.options) == null ? void 0 : _h.inject_params_per_call) ?? true,
37645
- force_inject_progress_token: ((_i = config2.options) == null ? void 0 : _i.force_inject_progress_token) ?? false,
37646
- exposed_tools: (_j = config2.options) == null ? void 0 : _j.exposed_tools,
37647
- log: {
37648
- root: ((_l = (_k = config2.options) == null ? void 0 : _k.log) == null ? void 0 : _l.root) ?? DEFAULT_LOG_ROOT,
37649
- enabled: ((_n = (_m = config2.options) == null ? void 0 : _m.log) == null ? void 0 : _n.enabled) ?? false,
37650
- // verbose=true 时自动使用 debug 级别
37651
- level: verbose ? "debug" : ((_p = (_o = config2.options) == null ? void 0 : _o.log) == null ? void 0 : _p.level) ?? "info",
37652
- max_days: ((_r = (_q = config2.options) == null ? void 0 : _q.log) == null ? void 0 : _r.max_days) ?? 7
37653
- }
37654
- }
37655
- };
37656
- }
37657
-
37658
37883
  // node_modules/@modelcontextprotocol/sdk/dist/esm/shared/transport.js
37659
37884
  function normalizeHeaders(headers) {
37660
37885
  if (!headers)
@@ -40141,6 +40366,13 @@ function printHelp2() {
40141
40366
  " [--create --name NAME]",
40142
40367
  " [--skip-confirm] [--skip-mcp-install] [--register-mcp codex,cursor,claude]",
40143
40368
  " [--json]",
40369
+ "",
40370
+ "Init flows:",
40371
+ " Standard init/clone/download flow: run `taptap-maker init`; the CLI shows",
40372
+ " the Maker app list, then the user chooses an existing app or 0/new.",
40373
+ " Create-new-project flow: add `--create --name NAME` only when the user",
40374
+ " clearly asks to create a new Maker project; NAME is the requested project name.",
40375
+ "",
40144
40376
  " taptap-maker doctor [--target-dir DIR] [--env rnd|production] [--json]",
40145
40377
  " taptap-maker python doctor [--json]",
40146
40378
  " taptap-maker python setup [--json]",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taptap/maker",
3
- "version": "0.0.19",
3
+ "version": "0.0.20",
4
4
  "type": "module",
5
5
  "description": "TapTap Maker local development CLI and MCP server",
6
6
  "main": "dist/maker.js",
@@ -56,6 +56,10 @@ exists.
56
56
 
57
57
  ## Create New Maker Project Intent
58
58
 
59
+ Standard initialization, clone, download, continue, or "pull remote project" requests use
60
+ `taptap-maker init`; the CLI shows the Maker app list and asks the user to choose an existing app
61
+ or `0`/`new`. Add `--create` only when the user clearly asks to create a new Maker project.
62
+
59
63
  Treat these user phrases as an explicit request to create a new Maker project:
60
64
 
61
65
  - 创建新项目
@@ -241,13 +245,17 @@ Workflow:
241
245
  5. Run `taptap-maker init` in the user's intended Maker directory. The CLI will request PAT if
242
246
  missing, fetch TapTap token, show a paged app preview, ask the user to choose or create a Maker
243
247
  project, clone the Maker project, prepare the AI dev kit, and install/verify MCP config.
248
+ For ordinary init/clone/download requests, use `taptap-maker init` so the CLI shows the app
249
+ list first. Add `--create` only when the user clearly asks to create a new Maker project.
244
250
  The app preview always includes `0,创建新项目 / 0. Create a new Maker project`. This row must
245
251
  remain visible when an AI summarizes or truncates a long app list, even if another app name
246
252
  appears to match the current directory. Users can choose `0`/`new` and enter a project name,
247
253
  or use `taptap-maker init --create --name "my-local-game"` for non-interactive runs.
248
- The generated MCP config pins the selected Maker project directory as `cwd` when the target
249
- client supports it. If a user manually reinstalls MCP config later, prefer
250
- `taptap-maker mcp install --target-dir <PROJECT_DIR>`.
254
+ The generated user-level MCP config does not pin the selected Maker project directory as `cwd`
255
+ by default. Clients that support MCP Roots should let the current workspace root identify the
256
+ Maker project, so multiple AI clients or Maker projects do not overwrite one shared cwd. If a
257
+ client does not support MCP Roots, the user can explicitly run
258
+ `taptap-maker mcp install --target-dir <PROJECT_DIR>` as a compatibility fix.
251
259
  Tell the user that the first Maker clone can take 20+ seconds because the server may be
252
260
  preparing the repository, and that they should keep the command running while the CLI retries
253
261
  transient 503/5xx failures.