@craft_eco/craft-mcp 0.1.34-beta.2 → 0.1.34-beta.3

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.
Files changed (61) hide show
  1. package/README.md +4 -17
  2. package/bin/craft-mcp.mjs +28 -2
  3. package/dist-server/game-workflow/art-previews.mjs +71 -71
  4. package/dist-server/game-workflow/local-context.mjs +64 -64
  5. package/dist-server/game-workflow/project-art-previews.mjs +63 -63
  6. package/dist-server/game-workflow/project-context.mjs +7 -6
  7. package/dist-server/game-workflow/project-install.mjs +2 -1
  8. package/dist-server/integrations/config.mjs +41 -18
  9. package/dist-server/integrations/connect.mjs +18 -9
  10. package/dist-server/integrations/connection-handoff.mjs +9 -8
  11. package/dist-server/integrations/dsh-config.mjs +30 -14
  12. package/dist-server/integrations/fixed-launcher.mjs +1 -0
  13. package/dist-server/integrations/host-config-scope.mjs +4 -3
  14. package/dist-server/integrations/hosts.mjs +3 -1
  15. package/dist-server/integrations/install.mjs +99 -33
  16. package/dist-server/integrations/installation-state.mjs +2 -1
  17. package/dist-server/integrations/instance-skill.mjs +26 -0
  18. package/dist-server/integrations/instance.mjs +29 -0
  19. package/dist-server/integrations/launcher-start.mjs +1 -1
  20. package/dist-server/integrations/login-task-command.mjs +3 -3
  21. package/dist-server/integrations/opencode-config.mjs +13 -6
  22. package/dist-server/integrations/project-setup.mjs +46 -18
  23. package/dist-server/integrations/runtime.mjs +2 -1
  24. package/dist-server/integrations/uninstall.mjs +160 -0
  25. package/dist-server/integrations/updates.mjs +42 -24
  26. package/dist-server/launcher.mjs +18 -2
  27. package/dist-server/mcp/server.mjs +13 -5
  28. package/dist-server/mcp/update-session.mjs +9 -6
  29. package/package.json +4 -2
  30. package/resources/context-filter-report.json +1 -1
  31. package/resources/craft-create/SKILL.md +25 -23
  32. package/resources/craft-update/SKILL.md +27 -25
  33. package/resources/targets/claude/js/context-filter-report.json +1 -1
  34. package/resources/targets/claude/js3d/context-filter-report.json +1 -1
  35. package/resources/targets/codebuddy/js/context-filter-report.json +1 -1
  36. package/resources/targets/codebuddy/js3d/context-filter-report.json +1 -1
  37. package/resources/targets/codex/js/context-filter-report.json +1 -1
  38. package/resources/targets/codex/js3d/context-filter-report.json +1 -1
  39. package/resources/targets/comate/js/context-filter-report.json +1 -1
  40. package/resources/targets/comate/js3d/context-filter-report.json +1 -1
  41. package/resources/targets/cursor/js/context-filter-report.json +1 -1
  42. package/resources/targets/cursor/js3d/context-filter-report.json +1 -1
  43. package/resources/targets/dsh/js/context-filter-report.json +1 -1
  44. package/resources/targets/dsh/js3d/context-filter-report.json +1 -1
  45. package/resources/targets/kimi/js/context-filter-report.json +1 -1
  46. package/resources/targets/kimi/js3d/context-filter-report.json +1 -1
  47. package/resources/targets/opencode/js/context-filter-report.json +1 -1
  48. package/resources/targets/opencode/js3d/context-filter-report.json +1 -1
  49. package/resources/targets/qoder/js/context-filter-report.json +1 -1
  50. package/resources/targets/qoder/js3d/context-filter-report.json +1 -1
  51. package/resources/targets/qoder-cn/js/context-filter-report.json +1 -1
  52. package/resources/targets/qoder-cn/js3d/context-filter-report.json +1 -1
  53. package/resources/targets/qwen/js/context-filter-report.json +1 -1
  54. package/resources/targets/qwen/js3d/context-filter-report.json +1 -1
  55. package/resources/targets/trae/js/context-filter-report.json +1 -1
  56. package/resources/targets/trae/js3d/context-filter-report.json +1 -1
  57. package/resources/targets/workbuddy/js/context-filter-report.json +1 -1
  58. package/resources/targets/workbuddy/js3d/context-filter-report.json +1 -1
  59. package/resources/targets/zcode/js/context-filter-report.json +1 -1
  60. package/resources/targets/zcode/js3d/context-filter-report.json +1 -1
  61. package/vendor/craft-runtime/SOURCE.json +1 -1
package/README.md CHANGED
@@ -10,24 +10,11 @@ Craft MCP 是面向支持本地 stdio MCP 的 AI IDE 的游戏制作服务,例
10
10
 
11
11
  选择当前宿主;只有同时接入时才用逗号列出多个宿主。安装完整 MCP 程序包、固定启动入口及全局 craft-create、craft-update Skill,保留已有平台和工作区。
12
12
 
13
- 保留原命令中 guide 之前的全部内容,把 guide 换为 install --ide <当前宿主>。用户明确指定渠道时,追加 --channel <目标标签>,由执行本次 guide 的 CLI 下载并核验目标包。比如用新版管理 CLI 给已装 beta 的 WorkBuddy 切换到 ue-test,只需把 guide 换为 install --ide workbuddy --channel ue-test。即使 ue-test 指向旧包,仍由本次管理 CLI 完成安装。
14
-
15
- 用户直接用 @标签 运行本版 guide 并要求安装该渠道时,保留原 @标签,并传同名 --channel。直接执行尚未包含此功能的旧包时,guide 和 install 均按该包版本工作。
16
-
17
- ```sh
18
- # 原命令使用 @ue-test guide,目标也是 ue-test
19
- npx --yes --registry=https://registry.npmjs.org/ @craft_eco/craft-mcp@ue-test install --ide workbuddy --channel ue-test
20
- ```
21
-
22
- 已有安装切换到用户指定的其他渠道时,目标版本可以低于原渠道版本。同渠道安装和自动更新保留防降级。用户只给了具体版本时保留该版本。用户只写包名且未指定渠道时,install 也只写包名,省略 --channel。已有安装继续跟踪原渠道,首次安装默认跟踪 stable。
13
+ 使用本次 guide 命令中的包选择器,将 guide 换为 install --ide <当前宿主>。正式安装使用 @stable。只有用户明确给出了其他渠道时,才沿用该标签并传同名 --channel;安装器为它创建独立的命名服务、工作区和 Skill。同一标签再次安装会复用自己的实例。明确指定版本时保留版本号。
23
14
 
24
15
  ```sh
25
- # 用户只写包名,在 WorkBuddy 中安装
26
- npx --yes --registry=https://registry.npmjs.org/ @craft_eco/craft-mcp install --ide workbuddy
27
- # 指定当前包版本,在 Codex 中安装
28
- npx --yes --registry=https://registry.npmjs.org/ @craft_eco/craft-mcp@0.1.34-beta.2 install --ide codex
29
- # 指定当前包版本,在 WorkBuddy 中安装
30
- npx --yes --registry=https://registry.npmjs.org/ @craft_eco/craft-mcp@0.1.34-beta.2 install --ide workbuddy
16
+ # 正式版,在 Codex 中安装
17
+ npx --yes --registry=https://registry.npmjs.org/ @craft_eco/craft-mcp@stable install --ide codex
31
18
  ```
32
19
 
33
20
  其他宿主将 --ide 改为 cursor、codebuddy、claude、dsh、zcode、kimi、trae、qoder-cn、qoder、comate、opencode 或 qwen。TRAE 与国际版 Qoder IDE 还须 --host-config <宿主设置中打开的 MCP 配置绝对路径>;TRAE CN 加 --trae-region cn,国际版默认 global。这两个选项也适用于 doctor/check/update/connect/project-setup,可由 CRAFT_HOST_CONFIG、CRAFT_TRAE_REGION 环境变量提供。kimi 指当前 Kimi Code CLI,不写旧 Python Kimi CLI 的 ~/.kimi。可用 --workspace <绝对游戏父目录> 和 --platform <HTTPS origin> 指定目录与平台;未提供时保留现有配置,新安装默认 ~/CraftGames 和本包平台。安装不创建游戏、不修改信任权限。
@@ -45,7 +32,7 @@ Claude Code 使用 ~/.claude.json 与 ~/.claude/skills;DSH 使用 ~/.dsh/cordi
45
32
  执行本包 guide,根据当前宿主调用上面的标准 install。十四种宿主使用同一安装流程,无需选择连接模式。当前进程不会因安装新版而切换版本;固定入口在下次启动时读取已安装目标。
46
33
 
47
34
  ```sh
48
- npx --yes --registry=https://registry.npmjs.org/ @craft_eco/craft-mcp guide
35
+ npx --yes --registry=https://registry.npmjs.org/ @craft_eco/craft-mcp@stable guide
49
36
  ```
50
37
 
51
38
  专家和连接器只通过 connect --ide workbuddy 解析标准安装并启动同一受管入口,首次使用也须先执行标准 install。connect 不安装程序、不改宿主配置、不创建游戏;安装缺失、禁用或平台/工作区不一致时明确失败。不要用无参数 npx 直接启动业务包来替代标准安装。未适配宿主的原始 stdio 调试不包含自动更新和 Skill 安装。
package/bin/craft-mcp.mjs CHANGED
@@ -14,7 +14,33 @@ if (args.length === 0 || (args.length === 2 && args[0] === '--workspace' && path
14
14
  if (args.length) process.env.CLIENT_WORKSPACE_ROOT = path.resolve(args[1]);
15
15
  await import('../dist-server/mcp/start.mjs');
16
16
  } else if (args.length === 1 && args[0] === 'guide') {
17
- process.stdout.write(await readFile(new URL('../README.md', import.meta.url), 'utf8'));
17
+ let guide = await readFile(new URL('../README.md', import.meta.url), 'utf8');
18
+ if (process.env.npm_command === 'exec' && process.env.npm_lifecycle_event === 'npx') {
19
+ const { npmInstallSelector } = await import('../dist-server/integrations/install-source.mjs');
20
+ const { serverIdForChannel } = await import('../dist-server/integrations/instance.mjs');
21
+ const pkg = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8'));
22
+ const selector = await npmInstallSelector(fileURLToPath(new URL('..', import.meta.url)), pkg.name);
23
+ if (selector?.kind === 'tag' && !['stable', 'latest'].includes(selector.tag)) {
24
+ const tag = selector.tag;
25
+ const server = serverIdForChannel(tag);
26
+ guide = [
27
+ '# 安装用户指定的 Craft 实例', '',
28
+ '保留本次 npx 命令的 registry 和包选择器,将 guide 换为下列参数,并将占位符替换为当前宿主。', '',
29
+ ' install --ide <当前宿主> --channel ' + tag + ' --instance ' + server, '',
30
+ '该服务拥有独立的工作区和 Skill。同一命令再次安装时更新该实例。安装完成后等待宿主连接 ' + server +
31
+ ',在当前聊天用它的 craft_game_info 核对 server_id、channel、version、build_id、workspace 和 active_verified。',
32
+ 'TRAE 和国际版 Qoder IDE 需追加 --host-config <从该宿主设置中打开的配置绝对路径>。TRAE 国内版另加 --trae-region cn。',
33
+ '新安装默认游戏目录为 ~/CraftTestGames/' + server + ',平台为 ' + pkg.craft.platform + '。安装器会保留该实例已有的平台和工作区。',
34
+ '在 CLI 中检查、更新、诊断或卸载时传 --ide <当前宿主> --instance ' + server + '。', '',
35
+ ].join('\n');
36
+ } else if (selector?.kind === 'package') {
37
+ guide = guide.replaceAll(pkg.name + '@stable ', pkg.name + '@' + pkg.version + ' ');
38
+ }
39
+ }
40
+ process.stdout.write(guide);
41
+ } else if (args[0] === 'uninstall') {
42
+ try { const { runUninstallCommand } = await import('../dist-server/integrations/uninstall.mjs'); await runUninstallCommand(args); }
43
+ catch (error) { process.stderr.write('Craft uninstall failed: ' + error.message + '\n'); process.exitCode = 1; }
18
44
  } else if (args[0] === 'connect') {
19
45
  try { const { runConnectCommand } = await import('../dist-server/integrations/connect.mjs'); await runConnectCommand(args); }
20
46
  catch (error) { process.stderr.write('Craft connect failed: ' + error.message + '\n'); process.exitCode = 1; }
@@ -37,7 +63,7 @@ if (args.length === 0 || (args.length === 2 && args[0] === '--workspace' && path
37
63
  } else if (args.length === 1 && ['--help', '-h', 'help'].includes(args[0])) {
38
64
  process.stdout.write('Windows local login: craft-mcp login-task --setup|--remove --ide workbuddy [--host-config <absolute MCP config file>]\n');
39
65
  process.stdout.write('Windows game preview: craft-mcp preview-task --setup|--remove --ide workbuddy [--host-config <absolute MCP config file>]\n');
40
- process.stdout.write('Usage: craft-mcp [--workspace <absolute games directory>|guide|--help]\n craft-mcp install --ide <host[,host]> [--workspace <absolute games directory>] [--platform <HTTPS origin>] [--registry <HTTPS registry>] [--channel <npm tag>] [--updates auto|off]\n craft-mcp project-setup --project <absolute game directory> --ide <host> [--install]\n craft-mcp connect --ide <host>\n craft-mcp doctor --ide <host[,host]>\n craft-mcp check --ide <host[,host]>\n craft-mcp update --ide <host[,host]>\nHosts: codex, workbuddy, codebuddy, cursor, claude, dsh, zcode, kimi, trae, qoder-cn, qoder, comate, opencode, qwen.\nHost options: --host-config <absolute MCP config file> (one host only); --trae-region global|cn. TRAE and Qoder IDE require the path opened by their settings UI. Environment equivalents: CRAFT_HOST_CONFIG, CRAFT_TRAE_REGION.\n\nNo arguments: start the stdio MCP server from this package.\n--workspace: override CLIENT_WORKSPACE_ROOT; games are created under <workspace>/<name>.\nDefault workspace: ~/CraftGames. The host current directory is not used.\nguide: print AI IDE installation instructions and exit.\ninstall: install and verify Craft, merge selected host configurations and install managed Skills. Omit --channel to retain the existing channel (stable on first install). An explicitly different --channel selects its tagged package even if its version is lower. Reinstalling the same channel and automatic updates retain downgrade protection. Preserve the workspace, platform and update policy; new installations enable automatic updates.\nconnect: start the existing standard installation; never installs or rewrites host settings.\ncheck: inspect the configured npm channel without installing a new runtime.\nupdate: install a verified newer compatible runtime and update the host configuration, including when automatic updates are off. The current process stays on its original package. Load the target at the next MCP start or user-requested reconnect, verify its identity, then prepare the current project to update context and Skills.\nproject-setup: inspect portable project installation requirements and the selected host; --install installs only a missing registration. Verify the current host connection before resuming.\ndoctor: verify configured files and candidate MCP in an isolated process; does not confirm the current host connection.\n');
66
+ process.stdout.write('Usage: craft-mcp [--workspace <absolute games directory>|guide|--help]\n craft-mcp install --ide <host[,host]> [--workspace <absolute games directory>] [--platform <HTTPS origin>] [--registry <HTTPS registry>] [--channel <npm tag>] [--updates auto|off]\n craft-mcp project-setup --project <absolute game directory> --ide <host> [--install]\n craft-mcp connect --ide <host>\n craft-mcp doctor --ide <host[,host]>\n craft-mcp check --ide <host[,host]>\n craft-mcp update --ide <host[,host]>\nHosts: codex, workbuddy, codebuddy, cursor, claude, dsh, zcode, kimi, trae, qoder-cn, qoder, comate, opencode, qwen.\nInstance selection: --instance <registered Craft server> for install, doctor, connect, project-setup, check, update or uninstall.\n craft-mcp uninstall --ide <host> [--instance <server>]\nHost options: --host-config <absolute MCP config file> (one host only); --trae-region global|cn. TRAE and Qoder IDE require the path opened by their settings UI. Environment equivalents: CRAFT_HOST_CONFIG, CRAFT_TRAE_REGION.\n\nNo arguments: start the stdio MCP server from this package.\n--workspace: override CLIENT_WORKSPACE_ROOT; games are created under <workspace>/<name>.\nDefault workspace: ~/CraftGames. The host current directory is not used.\nguide: print AI IDE installation instructions and exit.\ninstall: install and verify Craft, merge selected host configurations and install managed Skills. The default server is craft on stable. An explicit test tag selects its separate installation. Use --instance to target a specific managed registration. Reinstalling the same channel and automatic updates retain downgrade protection. Preserve the workspace, platform and update policy; new installations enable automatic updates.\nconnect: start the existing standard installation; never installs or rewrites host settings.\ncheck: inspect the configured npm channel without installing a new runtime.\nupdate: install a verified newer compatible runtime and update the host configuration, including when automatic updates are off. The current process stays on its original package. Load the target at the next MCP start or user-requested reconnect, verify its identity, then prepare the current project to update context and Skills.\nproject-setup: inspect portable project installation requirements and the selected host; --install installs only a missing registration. Verify the current host connection before resuming.\ndoctor: verify configured files and candidate MCP in an isolated process; does not confirm the current host connection.\n');
41
67
  } else {
42
68
  process.stderr.write('Unknown command or extra arguments. Use craft-mcp --help.\n');
43
69
  process.exitCode = 1;
@@ -1,71 +1,71 @@
1
- import path from 'node:path';
2
- import { createHash } from 'node:crypto';
3
- import { mkdir, readFile, writeFile, lstat } from 'node:fs/promises';
4
- import { resolveBundleTemplate, sharedTemplatePath } from './bundle-template.mjs';
5
-
6
- export const archiveArtPreviews = 'shared-art-previews';
7
- export const projectArtPreviews = '.craft/art-previews';
8
-
9
- export function previewHash(name) {
10
- const match = typeof name === 'string' && /^[a-z][a-z0-9-]*-([a-f0-9]{64})\.webp$/.exec(name);
11
- if (!match) throw new Error('Invalid Craft preview file name: '+name);
12
- return match[1];
13
- }
14
-
15
- export function checkArtPreview(name, bytes) {
16
- if (createHash('sha256').update(bytes).digest('hex') !== previewHash(name)) throw new Error('Craft preview checksum mismatch: '+name);
17
- }
18
-
19
- // Skill Markdown carries the final game-relative link verbatim. Only this
20
- // content-addressed destination can cross the boundary of a native host tree.
21
- export function artPreviewLink(file, target) {
22
- if (!target.includes('.craft/art-previews/')) return;
23
- const parts = file.replaceAll('\\','/').split('/');
24
- const skills = parts.lastIndexOf('skills'), name = path.posix.basename(target);
25
- previewHash(name);
26
- const expected = path.posix.relative(path.posix.dirname(['host',...parts.slice(skills)].join('/')),projectArtPreviews+'/'+name);
27
- if (skills < 0 || target !== expected) throw new Error('Invalid project-relative Craft preview link: '+target);
28
- return name;
29
- }
30
-
31
- export function collectArtPreviews(file, bytes, names) {
32
- if (!file.endsWith('.md') || !bytes.includes('.craft/art-previews/')) return;
33
- for (const [,target] of bytes.toString('utf8').matchAll(/\[[^\]\n]*\]\(([^)\n]+)\)/g)) {
34
- const name = artPreviewLink(file,target);
35
- if (name) names.add(name);
36
- }
37
- }
38
-
39
- export function bundleArtPreviewDirectory(root, engine, host, template) {
40
- const target = path.resolve(root), hostRoot = path.dirname(target), targets = path.dirname(hostRoot);
41
- const resources = path.dirname(targets);
42
- // A standalone --out may happen to end in targets/<host>/<engine>. Only a
43
- // verified shared distribution template opts into the sibling resource pool.
44
- const shared = template && host && path.basename(target) === engine && path.basename(hostRoot) === host &&
45
- path.basename(targets) === 'targets' && path.resolve(template) === path.join(resources,sharedTemplatePath(engine));
46
- return path.join(shared ? resources : root,archiveArtPreviews);
47
- }
48
-
49
- export async function readArtPreview(directory,name) {
50
- previewHash(name);
51
- const file=path.join(directory,name);
52
- if (!(await lstat(directory)).isDirectory() || !(await lstat(file)).isFile()) throw new Error('Craft preview must be a regular file: '+name);
53
- const bytes = await readFile(file);
54
- checkArtPreview(name,bytes);
55
- return bytes;
56
- }
57
-
58
- export async function copyArtPreview(source,destination,name) {
59
- const bytes = await readArtPreview(source,name);
60
- await mkdir(destination,{recursive:true});
61
- try {await writeFile(path.join(destination,name),bytes,{flag:'wx'});}
62
- catch (error) {if (error.code !== 'EEXIST') throw error; await readArtPreview(destination,name);}
63
- }
64
-
65
- export async function copyBundleArtPreviews(source,destination,bundle) {
66
- if (!bundle.art_previews?.length) return;
67
- const template = await resolveBundleTemplate(source,bundle.engine,bundle.host);
68
- for (const name of bundle.art_previews ?? []) {
69
- await copyArtPreview(bundleArtPreviewDirectory(source,bundle.engine,bundle.host,template),path.join(destination,archiveArtPreviews),name);
70
- }
71
- }
1
+ import path from 'node:path';
2
+ import { createHash } from 'node:crypto';
3
+ import { mkdir, readFile, writeFile, lstat } from 'node:fs/promises';
4
+ import { resolveBundleTemplate, sharedTemplatePath } from './bundle-template.mjs';
5
+
6
+ export const archiveArtPreviews = 'shared-art-previews';
7
+ export const projectArtPreviews = '.craft/art-previews';
8
+
9
+ export function previewHash(name) {
10
+ const match = typeof name === 'string' && /^[a-z][a-z0-9-]*-([a-f0-9]{64})\.webp$/.exec(name);
11
+ if (!match) throw new Error('Invalid Craft preview file name: '+name);
12
+ return match[1];
13
+ }
14
+
15
+ export function checkArtPreview(name, bytes) {
16
+ if (createHash('sha256').update(bytes).digest('hex') !== previewHash(name)) throw new Error('Craft preview checksum mismatch: '+name);
17
+ }
18
+
19
+ // Skill Markdown carries the final game-relative link verbatim. Only this
20
+ // content-addressed destination can cross the boundary of a native host tree.
21
+ export function artPreviewLink(file, target) {
22
+ if (!target.includes('.craft/art-previews/')) return;
23
+ const parts = file.replaceAll('\\','/').split('/');
24
+ const skills = parts.lastIndexOf('skills'), name = path.posix.basename(target);
25
+ previewHash(name);
26
+ const expected = path.posix.relative(path.posix.dirname(['host',...parts.slice(skills)].join('/')),projectArtPreviews+'/'+name);
27
+ if (skills < 0 || target !== expected) throw new Error('Invalid project-relative Craft preview link: '+target);
28
+ return name;
29
+ }
30
+
31
+ export function collectArtPreviews(file, bytes, names) {
32
+ if (!file.endsWith('.md') || !bytes.includes('.craft/art-previews/')) return;
33
+ for (const [,target] of bytes.toString('utf8').matchAll(/\[[^\]\n]*\]\(([^)\n]+)\)/g)) {
34
+ const name = artPreviewLink(file,target);
35
+ if (name) names.add(name);
36
+ }
37
+ }
38
+
39
+ export function bundleArtPreviewDirectory(root, engine, host, template) {
40
+ const target = path.resolve(root), hostRoot = path.dirname(target), targets = path.dirname(hostRoot);
41
+ const resources = path.dirname(targets);
42
+ // A standalone --out may happen to end in targets/<host>/<engine>. Only a
43
+ // verified shared distribution template opts into the sibling resource pool.
44
+ const shared = template && host && path.basename(target) === engine && path.basename(hostRoot) === host &&
45
+ path.basename(targets) === 'targets' && path.resolve(template) === path.join(resources,sharedTemplatePath(engine));
46
+ return path.join(shared ? resources : root,archiveArtPreviews);
47
+ }
48
+
49
+ export async function readArtPreview(directory,name) {
50
+ previewHash(name);
51
+ const file=path.join(directory,name);
52
+ if (!(await lstat(directory)).isDirectory() || !(await lstat(file)).isFile()) throw new Error('Craft preview must be a regular file: '+name);
53
+ const bytes = await readFile(file);
54
+ checkArtPreview(name,bytes);
55
+ return bytes;
56
+ }
57
+
58
+ export async function copyArtPreview(source,destination,name) {
59
+ const bytes = await readArtPreview(source,name);
60
+ await mkdir(destination,{recursive:true});
61
+ try {await writeFile(path.join(destination,name),bytes,{flag:'wx'});}
62
+ catch (error) {if (error.code !== 'EEXIST') throw error; await readArtPreview(destination,name);}
63
+ }
64
+
65
+ export async function copyBundleArtPreviews(source,destination,bundle) {
66
+ if (!bundle.art_previews?.length) return;
67
+ const template = await resolveBundleTemplate(source,bundle.engine,bundle.host);
68
+ for (const name of bundle.art_previews ?? []) {
69
+ await copyArtPreview(bundleArtPreviewDirectory(source,bundle.engine,bundle.host,template),path.join(destination,archiveArtPreviews),name);
70
+ }
71
+ }
@@ -1,64 +1,64 @@
1
- import path from 'node:path';
2
- import { mkdir, mkdtemp, readFile, readdir, writeFile, lstat, rename, rm } from 'node:fs/promises';
3
- import { randomUUID } from 'node:crypto';
4
- import { safeProjectFile } from './asset-import.mjs';
5
- import { verifyBundle } from './bundle-files.mjs';
6
- import { loadEngineResource } from './engines.mjs';
7
- import { copyBundleArtPreviews } from './art-previews.mjs';
8
-
9
- export const localContextPath = (host,engine,id)=>`.craft/contexts/${host}/${engine}/${id}`;
10
-
11
- // All parent components are checked using the same project boundary as game files.
12
- async function directory(project, relative) {
13
- const marker = await safeProjectFile(project,relative+'/.directory-check',true);
14
- return path.dirname(marker);
15
- }
16
- async function noLinks(root) {
17
- for (const entry of await readdir(root,{withFileTypes:true})) {
18
- if (entry.isSymbolicLink() || (!entry.isDirectory() && !entry.isFile())) throw new Error('Project context contains a link or special file');
19
- if (entry.isDirectory()) await noLinks(path.join(root,entry.name));
20
- }
21
- }
22
-
23
- // Immutable version directories keep an in-flight operation on the exact files it selected.
24
- // Only the sync record switches after the new snapshot is complete and verified.
25
- export async function materializeContext(project, current, previous) {
26
- const {host,engine,bundle,resources} = current;
27
- const relative = localContextPath(host,engine,bundle.id);
28
- const parent = await directory(project,`.craft/contexts/${host}/${engine}`);
29
- const target = path.join(parent,bundle.id);
30
- let present = false, backup;
31
- try {
32
- const stat = await lstat(target);
33
- if (!stat.isDirectory() || stat.isSymbolicLink()) throw new Error('Project context target must be a regular directory');
34
- await noLinks(target);
35
- present = true;
36
- } catch (error) { if (error.code !== 'ENOENT') throw error; }
37
- if (present) {
38
- try {
39
- const selected = await loadEngineResource(target,engine,bundle.id,host,{contextOnly:true});
40
- return {selected,relative,materialized:false};
41
- } catch (error) {
42
- // Do not claim an arbitrary pre-existing directory as an owned context.
43
- if (previous?.path !== relative) throw new Error('Unmanaged or incomplete project context at '+relative+'; preserve it before retrying', {cause:error});
44
- }
45
- }
46
- const staging = await mkdtemp(path.join(parent,'.staging-'));
47
- try {
48
- const files = [...Object.keys(bundle.files).filter(name=>!name.startsWith(engine+'/project/')),engine+'/bundle.json'];
49
- for (const name of files) {
50
- const output = await safeProjectFile(staging,name,true);
51
- await writeFile(output,await readFile(path.join(resources,name)),{flag:'wx'});
52
- }
53
- await copyBundleArtPreviews(resources,staging,bundle);
54
- await verifyBundle(staging,engine,bundle.id,{contextOnly:true});
55
- if (present) {
56
- const backups = await directory(project,`.craft/context-backups/${host}/${engine}`);
57
- backup = path.join(backups,bundle.id+'-'+randomUUID());
58
- await rename(target,backup);
59
- }
60
- await rename(staging,target);
61
- const selected = await loadEngineResource(target,engine,bundle.id,host,{contextOnly:true});
62
- return {selected,relative,materialized:true,...(backup ? {backup} : {})};
63
- } finally { await rm(staging,{recursive:true,force:true}); }
64
- }
1
+ import path from 'node:path';
2
+ import { mkdir, mkdtemp, readFile, readdir, writeFile, lstat, rename, rm } from 'node:fs/promises';
3
+ import { randomUUID } from 'node:crypto';
4
+ import { safeProjectFile } from './asset-import.mjs';
5
+ import { verifyBundle } from './bundle-files.mjs';
6
+ import { loadEngineResource } from './engines.mjs';
7
+ import { copyBundleArtPreviews } from './art-previews.mjs';
8
+
9
+ export const localContextPath = (host,engine,id)=>`.craft/contexts/${host}/${engine}/${id}`;
10
+
11
+ // All parent components are checked using the same project boundary as game files.
12
+ async function directory(project, relative) {
13
+ const marker = await safeProjectFile(project,relative+'/.directory-check',true);
14
+ return path.dirname(marker);
15
+ }
16
+ async function noLinks(root) {
17
+ for (const entry of await readdir(root,{withFileTypes:true})) {
18
+ if (entry.isSymbolicLink() || (!entry.isDirectory() && !entry.isFile())) throw new Error('Project context contains a link or special file');
19
+ if (entry.isDirectory()) await noLinks(path.join(root,entry.name));
20
+ }
21
+ }
22
+
23
+ // Immutable version directories keep an in-flight operation on the exact files it selected.
24
+ // Only the sync record switches after the new snapshot is complete and verified.
25
+ export async function materializeContext(project, current, previous) {
26
+ const {host,engine,bundle,resources} = current;
27
+ const relative = localContextPath(host,engine,bundle.id);
28
+ const parent = await directory(project,`.craft/contexts/${host}/${engine}`);
29
+ const target = path.join(parent,bundle.id);
30
+ let present = false, backup;
31
+ try {
32
+ const stat = await lstat(target);
33
+ if (!stat.isDirectory() || stat.isSymbolicLink()) throw new Error('Project context target must be a regular directory');
34
+ await noLinks(target);
35
+ present = true;
36
+ } catch (error) { if (error.code !== 'ENOENT') throw error; }
37
+ if (present) {
38
+ try {
39
+ const selected = await loadEngineResource(target,engine,bundle.id,host,{contextOnly:true});
40
+ return {selected,relative,materialized:false};
41
+ } catch (error) {
42
+ // Do not claim an arbitrary pre-existing directory as an owned context.
43
+ if (previous?.path !== relative) throw new Error('Unmanaged or incomplete project context at '+relative+'; preserve it before retrying', {cause:error});
44
+ }
45
+ }
46
+ const staging = await mkdtemp(path.join(parent,'.staging-'));
47
+ try {
48
+ const files = [...Object.keys(bundle.files).filter(name=>!name.startsWith(engine+'/project/')),engine+'/bundle.json'];
49
+ for (const name of files) {
50
+ const output = await safeProjectFile(staging,name,true);
51
+ await writeFile(output,await readFile(path.join(resources,name)),{flag:'wx'});
52
+ }
53
+ await copyBundleArtPreviews(resources,staging,bundle);
54
+ await verifyBundle(staging,engine,bundle.id,{contextOnly:true});
55
+ if (present) {
56
+ const backups = await directory(project,`.craft/context-backups/${host}/${engine}`);
57
+ backup = path.join(backups,bundle.id+'-'+randomUUID());
58
+ await rename(target,backup);
59
+ }
60
+ await rename(staging,target);
61
+ const selected = await loadEngineResource(target,engine,bundle.id,host,{contextOnly:true});
62
+ return {selected,relative,materialized:true,...(backup ? {backup} : {})};
63
+ } finally { await rm(staging,{recursive:true,force:true}); }
64
+ }
@@ -1,63 +1,63 @@
1
- import { readFile, writeFile, rename, rm } from 'node:fs/promises';
2
- import { randomUUID } from 'node:crypto';
3
- import { digest } from './bundle-files.mjs';
4
- import { safeProjectFile } from './asset-import.mjs';
5
- import { previewHash, projectArtPreviews, bundleArtPreviewDirectory, readArtPreview } from './art-previews.mjs';
6
-
7
- async function projectPreviewBytes(project,name) {
8
- previewHash(name);
9
- try {return await readFile(await safeProjectFile(project,projectArtPreviews+'/'+name));}
10
- catch (error) {if (error.code !== 'ENOENT') throw error; return null;}
11
- }
12
-
13
- export async function projectArtPreviewsCurrent(project,names,checks=new Map()) {
14
- for (const name of names ?? []) {
15
- if (!checks.has(name)) checks.set(name,projectPreviewBytes(project,name).then(bytes=>bytes !== null && digest(bytes) === previewHash(name)));
16
- if (!await checks.get(name)) return false;
17
- }
18
- return true;
19
- }
20
-
21
- // Keep the old lock until retirement finishes. An interrupted migration can
22
- // retry: an already archived file is absent, and unrelated files are untouched.
23
- export async function retireArtPreviews(project,previous,current,guard) {
24
- const active = new Set(current);
25
- for (const name of previous) {
26
- if (active.has(name)) continue;
27
- await guard();
28
- const bytes = await projectPreviewBytes(project,name);
29
- if (bytes === null || digest(bytes) !== previewHash(name)) continue;
30
- const file = await safeProjectFile(project,projectArtPreviews+'/'+name);
31
- const backup = await safeProjectFile(project,'.craft/context-backups/art-previews/'+randomUUID()+'/'+name,true);
32
- await rename(file,backup);
33
- }
34
- }
35
-
36
- export async function prepareArtPreviews(project,current,guard) {
37
- for (const name of current.bundle.art_previews ?? []) {
38
- const original = await projectPreviewBytes(project,name);
39
- if (original !== null && digest(original) === previewHash(name)) continue;
40
- const bytes = await readArtPreview(bundleArtPreviewDirectory(current.resources,current.engine,current.host,current.template),name);
41
- await guard();
42
- // This namespace is reserved for immutable, digest-named reference images.
43
- // Preserve unexpected local content before repairing its official counterpart.
44
- const token = randomUUID(), relative = projectArtPreviews+'/'+name;
45
- if (original !== null) {
46
- const backup = await safeProjectFile(project,'.craft/context-backups/art-previews/'+token+'/'+name,true);
47
- await writeFile(backup,original,{flag:'wx'});
48
- }
49
- const destination = await safeProjectFile(project,relative,true);
50
- // Prepare owns the project lock. Reuse its private staging slot on retry
51
- // so a terminated writer cannot strand a partial image in the asset pool.
52
- const temporary = await safeProjectFile(project,'.craft/context-staging/art-previews/'+name+'.tmp',true);
53
- await rm(temporary,{force:true});
54
- try {
55
- await writeFile(temporary,bytes,{flag:'wx'});
56
- await guard();
57
- const latest = await projectPreviewBytes(project,name);
58
- if (latest !== null && digest(latest) === previewHash(name)) continue;
59
- if (latest === null ? original !== null : !original?.equals(latest)) throw new Error('Project art preview changed during restoration: '+name);
60
- await rename(temporary,destination);
61
- } finally {await rm(temporary,{force:true});}
62
- }
63
- }
1
+ import { readFile, writeFile, rename, rm } from 'node:fs/promises';
2
+ import { randomUUID } from 'node:crypto';
3
+ import { digest } from './bundle-files.mjs';
4
+ import { safeProjectFile } from './asset-import.mjs';
5
+ import { previewHash, projectArtPreviews, bundleArtPreviewDirectory, readArtPreview } from './art-previews.mjs';
6
+
7
+ async function projectPreviewBytes(project,name) {
8
+ previewHash(name);
9
+ try {return await readFile(await safeProjectFile(project,projectArtPreviews+'/'+name));}
10
+ catch (error) {if (error.code !== 'ENOENT') throw error; return null;}
11
+ }
12
+
13
+ export async function projectArtPreviewsCurrent(project,names,checks=new Map()) {
14
+ for (const name of names ?? []) {
15
+ if (!checks.has(name)) checks.set(name,projectPreviewBytes(project,name).then(bytes=>bytes !== null && digest(bytes) === previewHash(name)));
16
+ if (!await checks.get(name)) return false;
17
+ }
18
+ return true;
19
+ }
20
+
21
+ // Keep the old lock until retirement finishes. An interrupted migration can
22
+ // retry: an already archived file is absent, and unrelated files are untouched.
23
+ export async function retireArtPreviews(project,previous,current,guard) {
24
+ const active = new Set(current);
25
+ for (const name of previous) {
26
+ if (active.has(name)) continue;
27
+ await guard();
28
+ const bytes = await projectPreviewBytes(project,name);
29
+ if (bytes === null || digest(bytes) !== previewHash(name)) continue;
30
+ const file = await safeProjectFile(project,projectArtPreviews+'/'+name);
31
+ const backup = await safeProjectFile(project,'.craft/context-backups/art-previews/'+randomUUID()+'/'+name,true);
32
+ await rename(file,backup);
33
+ }
34
+ }
35
+
36
+ export async function prepareArtPreviews(project,current,guard) {
37
+ for (const name of current.bundle.art_previews ?? []) {
38
+ const original = await projectPreviewBytes(project,name);
39
+ if (original !== null && digest(original) === previewHash(name)) continue;
40
+ const bytes = await readArtPreview(bundleArtPreviewDirectory(current.resources,current.engine,current.host,current.template),name);
41
+ await guard();
42
+ // This namespace is reserved for immutable, digest-named reference images.
43
+ // Preserve unexpected local content before repairing its official counterpart.
44
+ const token = randomUUID(), relative = projectArtPreviews+'/'+name;
45
+ if (original !== null) {
46
+ const backup = await safeProjectFile(project,'.craft/context-backups/art-previews/'+token+'/'+name,true);
47
+ await writeFile(backup,original,{flag:'wx'});
48
+ }
49
+ const destination = await safeProjectFile(project,relative,true);
50
+ // Prepare owns the project lock. Reuse its private staging slot on retry
51
+ // so a terminated writer cannot strand a partial image in the asset pool.
52
+ const temporary = await safeProjectFile(project,'.craft/context-staging/art-previews/'+name+'.tmp',true);
53
+ await rm(temporary,{force:true});
54
+ try {
55
+ await writeFile(temporary,bytes,{flag:'wx'});
56
+ await guard();
57
+ const latest = await projectPreviewBytes(project,name);
58
+ if (latest !== null && digest(latest) === previewHash(name)) continue;
59
+ if (latest === null ? original !== null : !original?.equals(latest)) throw new Error('Project art preview changed during restoration: '+name);
60
+ await rename(temporary,destination);
61
+ } finally {await rm(temporary,{force:true});}
62
+ }
63
+ }
@@ -9,8 +9,9 @@ import { hosts, clientIde, projectSkillPath, hostRecoveryEntry } from '../integr
9
9
  const start = '<!-- craft-mcp:project:start -->';
10
10
  const end = '<!-- craft-mcp:project:end -->';
11
11
  // Independent of engine bundle versions: generated recovery instructions evolve too.
12
- export const entryPolicyVersion = 14;
12
+ export const entryPolicyVersion = 15;
13
13
  const hash = value => createHash('sha256').update(value).digest('hex');
14
+ const instanceGuide = '先读取已有的 `.craft/project-install.json`。若宿主暴露多组 Craft 工具,用各服务的只读 `craft_game_info` 核对工作区是当前项目父目录、平台和渠道符合清单,再按项目名核对绝对路径与引擎。记录唯一匹配的工具命名空间和 server_id;后续制作、上传、检查更新和重连核验沿用该服务。多个服务都匹配时请用户选定,缺少匹配时按项目接入指引处理。';
14
15
  const turnUpdateGuide = '进入 Craft 工作流后,每条用户消息使用新的检查 key。同一轮调用支持 `update_request_key` 的业务工具时传这个 key,工具会顺带检查;本轮仅答疑、编辑本地文件或只用轮询等工具时,补一次只读 `craft_update_check`(request_key=本轮 key,已有工程传 name)。制作时,业务回执的 update_notice 或显式检查返回 update_available=true 且 automatic_update_enabled=true,就用同一 key 调用 `craft_update`(mode=auto,已有工程传 name)。纯查看只检查,未发现更新直接继续。同一目标版本待重连时只提示一次。';
15
16
  const normalizeLines = value => value.replace(/\r\n/g,'\n');
16
17
  const uploadGuide = '上传游戏、更新云端版本或发布时,使用 Craft MCP。纯上传用 `craft_game_check` 的 `purpose="upload"` 构建并冻结源码和 dist,安全检查通过后用 `craft_game_upload` 上传。更新原项目时先用 `craft_game_upload_status({name})` 核对云端绑定,上传传 `expected_appid`。收到 `draft_ready` 后报告版本、appid 和项目链接,由用户进入项目页提审。遇到阻塞时报告工具名和原始错误,改用 Computer Use、GM 或网页编辑器上传须另获用户同意。';
@@ -24,10 +25,10 @@ export function projectContextPaths(project, ide = 'generic', schema = 5) {
24
25
 
25
26
  function recovery(name, engine) {
26
27
  return `Craft 工程名:\`${name}\`;引擎:\`${engine}\`。保持已有引擎与用户源码。\n\n`
27
- + turnUpdateGuide + '\n\n'
28
+ + instanceGuide + '\n\n' + turnUpdateGuide + '\n\n'
28
29
  + '先读 `SPEC/PROGRESS.md` 和已有的 SPEC 设计文件,核对已完成玩法、待办及最近验收;缺少记录时检查源码与工具回执,不根据旧聊天猜测。\n\n'
29
30
  + `继续本工程前调用 \`craft_game_info({"name":"${name}"})\`,核对返回的 project 是当前目录、context_binding.status 为 bound。读取返回的 \`context.workflow\`、\`context.engine.entrypoint\` 和 \`context.engine.skills_index\`;按索引 description 选择技能,相对于 context.engine.directory 读取 entrypoint,再按需读取引用。\n\n`
30
- + `MCP 的 workspace 是游戏父目录,工程位于 \`workspace/${name}\`,不自动跟随宿主当前目录。若不匹配,先在宿主 MCP 设置中将 \`--workspace\` 参数(优先)或 \`CLIENT_WORKSPACE_ROOT\` 指向当前游戏的父目录并重连;不要在错误目录创建同名工程。\n\n`
31
+ + `MCP 的 workspace 是游戏父目录,工程位于 \`workspace/${name}\`,不自动跟随宿主当前目录。若不匹配,先通过项目接入检查确认正确连接,保留其他工作区及其工程。\n\n`
31
32
  + `迁移目录或首次恢复时若提示尚未 prepare,确认 workspace 后调用 \`craft_game_prepare({"name":"${name}","engine":"${engine}","mode":"resume","request_key":"resume-unique-key"})\` 并轮询任务完成;已有合法工程只会被接管,不重置模板。目录更名后使用当前目录名(须符合工具的英文 name 规则)。\n\n`
32
33
  + '项目以 `.craft/context-lock.json` 绑定引擎上下文版本,随项目保存;实际路径每次通过工具查询。缺少绑定时由 prepare 核验后建立,缺包或不兼容时按诊断恢复匹配版本,不删除锁文件来绕过检查。上下文、模板和技能脚本由 Craft 版本包提供,不复制到游戏中;MCP 未连接时先连接项目使用的 Craft 服务。\n\n'
33
34
  + '验收使用 `craft_game_check` → `craft_game_review` → `craft_game_deliver`;宿主按返回命令启动预览,再核对当前快照已运行。构建成功不代表预览自动开启。\n\n'
@@ -91,11 +92,11 @@ function mergeRuleMetadata(original,prefix) {
91
92
  function projectConnectionGuide(host) {
92
93
  const target = host === 'generic' ? '<当前宿主>' : host;
93
94
  return '首次接手或切换 Agent 时,先通过当前宿主实际提供的工具发现能力查找 Craft 工具;工具可能延迟暴露或带命名空间前缀,不能因裸工具名不存在、resources 为空就判断未安装。项目文件和 Skill 可用也不代表 MCP 已连接。\n\n'
94
- + '无论是否已连接,都先读取存在的 `.craft/project-install.json` 并与实际连接核对;实际程序低于 minimum_mcp_version、平台或工作目录不符时先处理接入,不能直接开始制作。\n\n'
95
+ + instanceGuide + ' 实际程序低于 minimum_mcp_version 时先处理版本要求。\n\n'
95
96
  + '若没有可用的 Craft 连接,读取 `.craft/project-install.json`,确认 package_name、minimum_mcp_version、registry、channel、platform 和 engine。使用当前宿主终端执行下面的项目接入检查,将占位值替换为文件中的值及当前游戏绝对目录,并按终端规则引用参数:\n\n'
96
97
  + '```text\nnpx -y --registry "<registry>" "@craft_eco/craft-mcp@<minimum_mcp_version>" project-setup --project "<当前游戏绝对目录>" --ide '+target+'\n```\n\n'
97
98
  + 'TRAE 和国际版 Qoder IDE 的接入命令需加 `--host-config "<宿主 MCP 设置界面打开的配置文件绝对路径>"`;不要猜测配置路径。TRAE CN 另加 `--trae-region cn`,国际版使用 global。已有安装检查、更新及恢复沿用相同路径和地区。\n\n'
98
- + '检查命令只读;仅返回 `missing_installation` 且用户正在请求继续制作时,在同一命令末尾加 `--install`,自动下载并标准安装到当前宿主。所选包必须满足项目最低 MCP 版本;随后按已有更新策略检查渠道。安装包尚未发布或网络/终端权限不可用时报告准确原因;用户提供本地候选包时可用该包的同一 CLI,不降低项目版本。\n\n'
99
+ + '检查命令只读。返回 `instance_required` 或 `multiple_installations` 时请用户选定服务,以 `--instance <服务名>` 重新检查。仅返回 `missing_installation` 且用户正在请求继续制作时,在同一命令末尾加 `--install`;非 stable 渠道新装须由用户明确选择命名实例。所选包必须满足项目最低 MCP 版本;随后按已有更新策略检查渠道。安装包尚未发布或网络/终端权限不可用时报告准确原因;用户提供本地候选包时可用该包的同一 CLI,不降低项目版本。\n\n'
99
100
  + '已有配置被禁用、范围不匹配、旧版或连接失败时按检查结果修复,不当作缺失重复安装,不自行启用用户禁用的服务或覆盖其他工作区/平台。`--workspace` 必须是当前游戏父目录,不跟随默认目录。旧项目缺少安装信息时,先使用已连接且目录/平台明确的 Craft 完成 resume 以补齐;无可靠来源则询问缺失的平台/版本信息,不猜默认环境。\n\n'
100
101
  + '安装回执和 doctor 只证明配置及独立探测。等待宿主实际加载 Craft;需要时提示重连或重启,只有宿主提示信任/登录时由用户处理。连接后必须由当前会话调用 `craft_game_info`,核对实际 version/build_id、host、workspace、platform、project 和原引擎,标准安装确认 active_verified 后再 prepare(resume)。不要使用另一个终端探测代替当前会话验收,不重建已有工程。纯查看不安装或更新,打开文件夹本身不触发安装。\n\n';
101
102
  }
@@ -120,7 +121,7 @@ function recoveryEntries(name, engine, ide = 'generic', isolated = false) {
120
121
  + start + '\n# 继续当前 Craft 游戏\n\n'
121
122
  + '首次接手先读根 AGENTS.md 的接入流程,确认当前宿主及项目安装信息;缺失 Craft MCP 时先检查、按需安装并核验当前会话连接,再调用下面的工具。不要因延迟工具尚未发现而误判未安装。\n\n'
122
123
  + (isolated ? '本入口适用于 '+host+',project-setup 使用 `--ide '+host+'`;当前 Agent 不属于该宿主时按根路由读取自身入口。\n\n' : '')
123
- + `1. 读取项目根 \`AGENTS.md\`,确认工程 \`${name}\` 和引擎 \`${engine}\`。\n`
124
+ + `1. 读取项目根 \`AGENTS.md\`,确认工程 \`${name}\` 和引擎 \`${engine}\`。` + instanceGuide + '\n'
124
125
  + turnUpdateGuide + '\n\n'
125
126
  + (isolated ? '2. 当前连接仍持有本工程有效 work 时沿用 work_id/context_revision。新会话先调用只读 `craft_game_info` 核对项目和工作区。核对实际版本后,尚无有效 work 且可继续时调用 `craft_game_prepare`(mode=resume,同一 request_key)。轮询完成并保留 work_id/context_revision,重新读取本 Skill 相邻的 [引擎入口](../../AGENTS.md)、[恢复说明](../../recovery.md)、[工作流](../../workflow.md) 和 [技能索引](../index.json),按任务读取当前宿主 skills/ 下的正文。\n' : '2. 按根 AGENTS.md 查询 `craft_game_info`,读取返回的引擎入口、工作流与技能索引。\n')
126
127
  + (isolated ? ' 新版安装后等待下次 MCP 启动或用户重连。确认实际 version、build_id、active_verified 后,prepare(resume) 按游戏原引擎更新各已绑定宿主有变化的官方 Skill。完成后重新读取本宿主的索引和正文。\n' : '')
@@ -44,11 +44,12 @@ export async function readProjectInstall(project, { required = false } = {}) {
44
44
  return manifest;
45
45
  }
46
46
 
47
- export function assertProjectInstallConnection(manifest, { engine, version, platform, registry, channel }) {
47
+ export function assertProjectInstallConnection(manifest, { engine, version, platform, registry, channel, requireKnownChannel = false }) {
48
48
  if (manifest.engine !== engine) throw new Error('Project installation engine differs from the existing game; keep its original engine');
49
49
  if (compareVersions(version, manifest.minimum_mcp_version) < 0) throw new Error('Project requires Craft MCP >= ' + manifest.minimum_mcp_version + '; the current runtime cannot downgrade its installation contract');
50
50
  if (httpsUrl(platform, { origin: true }) !== manifest.platform) throw new Error('Project installation platform differs from the current Craft connection; reconnect to the project platform before resuming');
51
51
  if (registry !== undefined && httpsUrl(registry) !== manifest.registry) throw new Error('Project installation registry differs from the current Craft installation; preserve the project source and reconnect with its registry');
52
+ if (requireKnownChannel && !channel && manifest.channel !== 'stable') throw new Error('This project requires a verified Craft installation for its configured channel: ' + manifest.channel);
52
53
  if (channel !== undefined && channel !== manifest.channel) throw new Error('Project installation channel differs from the current Craft installation; preserve the project source and reconnect with its channel');
53
54
  }
54
55