dsh-unity-mcp 0.0.9 → 0.0.10

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
@@ -17,7 +17,7 @@
17
17
  需要 Node.js 22+、DSH `>=0.2.1-rc.3 <0.3.0`。在 DSH 插件管理中安装:
18
18
 
19
19
  ```text
20
- dsh-unity-mcp
20
+ dsh-unity-mcp@0.0.10
21
21
  ```
22
22
 
23
23
  本地工程管理目前只支持 Windows。上游声明 Unity 2022.3+;本插件已在独立团结工程中验证,但不能保证所有 Unity / Tuanjie 版本都兼容。
@@ -110,3 +110,9 @@ npm run pack:check
110
110
  测试覆盖服务器发现、配置边界、就绪等待、安装保护、保存关闭和 Agent 隔离。上下文大小测试比较 UTF-8 schema 字节数,不把字节数当作模型 token 数。
111
111
 
112
112
  本适配插件采用 MIT 许可证。上游 [CoderGamester/mcp-unity](https://github.com/CoderGamester/mcp-unity) 也采用 MIT 许可证;本包不分发上游引擎或服务器源码。图标由 Krea 2 Turbo 生成,不使用 Unity 官方标志。许可与素材说明见 [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)。
113
+
114
+ ## 按需技能目录
115
+
116
+ - [unity-safe-verification](skills/unity-safe-verification/SKILL.md):安全操作、回读和 Play 验收。
117
+
118
+ 这些技能随 npm 包分发,由插件启用时注册,禁用或卸载时撤销;正文仍按需加载,资源路径指向包内目录。无需另建用户级副本或目录联接。旧版已有的同名本地入口应核对来源后移到技能扫描范围之外备份,不删除技能正文。独立用户技能不会被插件改写或删除;同名条目遵循宿主优先级,禁用插件后用户条目仍可使用。跨插件技能引用需要启用对应插件。
package/index.mjs CHANGED
@@ -6,8 +6,9 @@ import { projectTool } from './lib/project.mjs';
6
6
  import { installationTool } from './lib/install-codergamester.mjs';
7
7
  import { screenshotTool } from './lib/capture-window.mjs';
8
8
  import { configurationTool } from './lib/configure-project.mjs';
9
+ import { installPackagedSkills } from './lib/packaged-skills.mjs';
9
10
  export const name = 'dsh-unity-mcp';
10
- export const inject = ['tools', 'agents', 'configEditor', 'attachments'];
11
+ export const inject = ['tools', 'agents', 'configEditor', 'attachments', 'skills'];
11
12
  export const Config = z.object({
12
13
  projectPath: z.string().default('').description('Unity / Tuanjie 项目绝对路径 / Absolute project directory'),
13
14
  serverPath: z.string().default('').description('CoderGamester Server~/build/index.js 绝对路径;留空从项目发现 / Built server path; blank discovers in project'),
@@ -18,6 +19,7 @@ export const Config = z.object({
18
19
  toolCallTimeoutMs: z.number().min(1000).max(600000).step(1).default(120000).description('工具超时(毫秒) / Tool timeout (ms)')
19
20
  });
20
21
  export async function apply(ctx, config) {
22
+ installPackagedSkills(ctx, new URL('./skills/', import.meta.url));
21
23
  // Install the loader even before configuration, so discovery explains setup.
22
24
  installLazyTools(ctx, config.lazyTools, [projectTool(ctx), screenshotTool(ctx), installationTool(), configurationTool(ctx)]);
23
25
  if (!config.projectPath && !config.serverPath) {
@@ -0,0 +1,27 @@
1
+ import { readFileSync, readdirSync } from 'node:fs';
2
+ import { fileURLToPath } from 'node:url';
3
+
4
+ export function readPackagedSkills(directory) {
5
+ return readdirSync(directory, { withFileTypes: true })
6
+ .filter(entry => entry.isDirectory()).map(entry => entry.name).sort().map(name => {
7
+ const base = new URL(`${name}/`, directory);
8
+ const path = new URL('SKILL.md', base);
9
+ const source = readFileSync(path, 'utf8');
10
+ const match = /^---\r?\nname: ([^\r\n]+)\r?\ndescription: ([^\r\n]+)\r?\n---\r?\n([\s\S]*)$/u.exec(source);
11
+ if (!match || match[1] !== name || !match[2].trim()) {
12
+ throw new Error(`Invalid packaged skill frontmatter: ${name}`);
13
+ }
14
+ return {
15
+ name, description: match[2], content: match[3], source: 'runtime',
16
+ path: fileURLToPath(path),
17
+ resourceBase: { kind: 'directory', path: fileURLToPath(base) },
18
+ invocation: { modelInvocable: true, userInvocable: true },
19
+ };
20
+ });
21
+ }
22
+
23
+ export function installPackagedSkills(ctx, directory) {
24
+ // Validate all plain name/description frontmatter before registering any entry.
25
+ const skills = readPackagedSkills(directory);
26
+ for (const skill of skills) ctx.effect(() => ctx.skills.register(skill));
27
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-unity-mcp",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "Unity and Tuanjie editor tools for DSH, powered by CoderGamester/mcp-unity with per-agent lazy loading.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -23,6 +23,7 @@
23
23
  "./locale/*.json": "./locale/*.json"
24
24
  },
25
25
  "files": [
26
+ "skills",
26
27
  "index.mjs",
27
28
  "lib",
28
29
  "engine",
@@ -39,7 +40,7 @@
39
40
  }
40
41
  },
41
42
  "scripts": {
42
- "check": "node --check index.mjs && node --check lib/capture-window.mjs && node --check lib/project.mjs && node --check lib/connection.mjs && node --check lib/engine-tools.mjs && node --check lib/lazy-tools.mjs && node --check lib/configure-project.mjs && node --check lib/open-project.mjs && node --check lib/project-lifecycle.mjs && node --check lib/install-codergamester.mjs",
43
+ "check": "node --check index.mjs && node --check lib/capture-window.mjs && node --check lib/project.mjs && node --check lib/connection.mjs && node --check lib/engine-tools.mjs && node --check lib/lazy-tools.mjs && node --check lib/configure-project.mjs && node --check lib/open-project.mjs && node --check lib/project-lifecycle.mjs && node --check lib/install-codergamester.mjs && node --check lib/packaged-skills.mjs",
43
44
  "test": "node --test test/*.test.mjs",
44
45
  "build": "npm run check",
45
46
  "pack:check": "npm pack --dry-run --json"
@@ -0,0 +1,32 @@
1
+ ---
2
+ name: unity-safe-verification
3
+ description: 操作 Unity 或团结工程、修改场景资产或交付可玩版本时使用;确认工程就绪、回读目标并在 Play 中验收。
4
+ ---
5
+
6
+ # Unity/团结安全操作与实机验收
7
+
8
+ ## 确认目标
9
+
10
+ 加载当前工具目录,枚举工程后固定绝对路径。分别确认编辑器就绪、MCP 连接、场景和 Play/Prefab 状态。进程、目录、握手只证明各自一层;只读场景查询需与工程一致。超时不重复启动或切换全局连接。
11
+
12
+ ## 修改前
13
+
14
+ 读取目标、受影响场景、Prefab、共享材质和引用,记录定位与原值,不按脚本类名猜对象名。明确世界/本地坐标、共享/实例资源、活动场景/另存目标。参数与枚举按当前 schema 核验。
15
+
16
+ 保存用户修改后再复制工程,磁盘副本不包含未保存状态。安装包、升级编辑器、切换连接、打开不可信项目均在授权范围内处理。
17
+
18
+ ## 写后回读
19
+
20
+ 小范围写入后查询对象实际值、组件、引用并检查控制台。回执不保证最终值;部分修改可能已发生,批量回滚按实际契约判断。修改共享资源前核对其他引用。超时先查状态,特别是播放切换、删除与父级变更。
21
+
22
+ ## 分层验收
23
+
24
+ 1. 文件:diff、资产与 meta 配对及引用;哈希只证明字节。
25
+ 2. 导入编译:等待完成,读取相关堆栈,不清日志掩盖错误。
26
+ 3. 场景:加载明确场景,核对层级和画面;默认空场景不证明工程损坏。
27
+ 4. Play:按需求走主路径及失败分支,检查输入、状态、真实画面和运行错误。静态测试不代替游玩。
28
+ 5. 持久化:退出 Play,确认编辑态结果并保存具名场景及资源,核对磁盘;运行态修改可能被丢弃。
29
+
30
+ 测试使用隔离对象或夹具,只清理自己的对象。报告各层验证范围;不能进入 Play 就列出未验证功能。
31
+
32
+ 例:位置修改后读取 Transform,再在目标场景检查落脚点;编译通过不证明角色没有悬空。